mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-18 21:19:31 +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
|
#ifdef MAP_ALIGNED_SUPER
|
||||||
lflags |= MAP_ALIGNED_SUPER;
|
lflags |= MAP_ALIGNED_SUPER;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MAP_HUGETLB
|
|
||||||
lflags |= MAP_HUGETLB;
|
|
||||||
#endif
|
|
||||||
#ifdef MAP_HUGE_2MB
|
#ifdef MAP_HUGE_2MB
|
||||||
lflags |= MAP_HUGE_2MB;
|
lflags |= MAP_HUGE_2MB;
|
||||||
#endif
|
#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)
|
// Should we check this in _mi_os_init? (as on Windows)
|
||||||
p = mi_unix_mmapx(size, try_alignment, protect_flags, lflags, fd);
|
p = mi_unix_mmapx(size, try_alignment, protect_flags, lflags, fd);
|
||||||
#ifdef MADV_HUGEPAGE
|
#ifdef MADV_HUGEPAGE
|
||||||
if (p == MAP_FAILED) {
|
if (p != MAP_FAILED) {
|
||||||
lflags = flags; // large page could be set to madvise only
|
int err = madvise(p, size, MADV_HUGEPAGE);
|
||||||
p = mi_unix_mmapx(size, try_alignment, protect_flags, lflags, fd);
|
if (err != 0) {
|
||||||
if (p == MAP_FAILED) return NULL; // we did what we could at this stage
|
// page will be just a regular mapping no need to trash it
|
||||||
else madvise(p, size, MADV_HUGEPAGE);
|
_mi_warning_message("madvise thp error: address: 0x%p, size: 0x%x, errno: %i\n", p, size, errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (p == MAP_FAILED) p = NULL; // fall back to regular mmap if large is exhausted or no permission
|
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