[PATCH] D58718: [Memory] Add basic support for large/huge memory pages

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 27 13:56:15 PST 2019


aganea added inline comments.


================
Comment at: lib/Support/Windows/Memory.inc:105-115
   // While we'd be happy to allocate single pages, the Windows allocation
   // granularity may be larger than a single page (in practice, it is 64K)
   // so mapping less than that will create an unreachable fragment of memory.
   // Avoid using one-time initialization of static locals here, since they
   // aren't thread safe with MSVC.
   static volatile size_t GranularityCached;
   size_t Granularity = GranularityCached;
----------------
zturner wrote:
> FWIW, this comment about static locals is no longer accurate.  I wonder if we could write this as:
> 
> ```
> static size_t DefaultGranularity = getAllocationGranularity();
> static Optional<size_t> LargePageGranularity = getLargePargeGranularity();
> 
> DWORD Flags = MEM_RESERVE | MEM_COMMIT;
> 
> size_t Granularity = DefaultGranularity;
> if ((Flags & MF_HUGE_HINT) && LargePageGranularity.hasValue()) {
>   Flags |= MEM_LARGE_PAGES;
>   Granularity = *LargePageGranularity;
> }
> ```
I was tempted to change that code at first, but I said maybe in a later commit. Looks much better now - thank you!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58718/new/

https://reviews.llvm.org/D58718





More information about the llvm-commits mailing list