From ffd0ae314b69f45ee7672683fa0ff62c20a80566 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 23 Jul 2019 18:47:09 +0100 Subject: [PATCH] Using thp mode only instead as best as we can --- src/os.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/os.c b/src/os.c index ee9a91ad..e9566354 100644 --- a/src/os.c +++ b/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