mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-18 13:09:32 +03:00
Using thp mode only instead as best as we can
This commit is contained in:
parent
3f894c9bf6
commit
ffd0ae314b
1 changed files with 6 additions and 8 deletions
14
src/os.c
14
src/os.c
|
@ -277,9 +277,6 @@ static void* mi_unix_mmap(size_t size, size_t try_alignment, int protect_flags)
|
|||
#ifdef MAP_ALIGNED_SUPER
|
||||
lflags |= MAP_ALIGNED_SUPER;
|
||||
#endif
|
||||
#ifdef MAP_HUGETLB
|
||||
lflags |= MAP_HUGETLB;
|
||||
#endif
|
||||
#ifdef MAP_HUGE_2MB
|
||||
lflags |= MAP_HUGE_2MB;
|
||||
#endif
|
||||
|
@ -292,11 +289,12 @@ static void* mi_unix_mmap(size_t size, size_t try_alignment, int protect_flags)
|
|||
// 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 = flags; // large page could be set to madvise only
|
||||
p = mi_unix_mmapx(size, try_alignment, protect_flags, lflags, fd);
|
||||
if (p == MAP_FAILED) return NULL; // we did what we could at this stage
|
||||
else madvise(p, size, MADV_HUGEPAGE);
|
||||
if (p != MAP_FAILED) {
|
||||
int err = madvise(p, size, MADV_HUGEPAGE);
|
||||
if (err != 0) {
|
||||
// page will be just a regular mapping no need to trash it
|
||||
_mi_warning_message("madvise thp error: address: 0x%p, size: 0x%x, errno: %i\n", p, size, errno);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (p == MAP_FAILED) p = NULL; // fall back to regular mmap if large is exhausted or no permission
|
||||
|
|
Loading…
Add table
Reference in a new issue