mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-18 13:09:32 +03:00
Linux transparent huge page support mode.
Most of the time distributions on non server machines are set to madvise only.
This commit is contained in:
parent
095a87be2e
commit
cf4eacf979
1 changed files with 9 additions and 0 deletions
9
src/os.c
9
src/os.c
|
@ -291,7 +291,16 @@ static void* mi_unix_mmap(size_t size, size_t try_alignment, int protect_flags)
|
|||
// TODO: if always failing due to permissions or no huge pages, try to avoid repeatedly trying?
|
||||
// Should we check this in _mi_os_init? (as on Windows)
|
||||
p = mi_unix_mmapx(size, try_alignment, protect_flags, lflags, fd);
|
||||
#ifdef MADV_HUGEPAGE
|
||||
if (p == MAP_FAILED) {
|
||||
lflags &= MAP_HUGETLB; // large page could be set to madvise only
|
||||
p = mi_unix_mmapx(size, try_alignment, protect_flags, lflags, fd);
|
||||
if (p == MAP_FAILED) p = NULL; // we did what we could at this stage
|
||||
else madvise(p, size, MADV_HUGEPAGE);
|
||||
}
|
||||
#else
|
||||
if (p == MAP_FAILED) p = NULL; // fall back to regular mmap if large is exhausted or no permission
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (p == NULL) {
|
||||
|
|
Loading…
Add table
Reference in a new issue