Fix incorrect MAP_HUGE_1GB check

MAP_HUGE_1GB and MAP_HUGE_2MB are not single bit flags.

MAP_HUGE_1GB = 30 << 26.
MAP_HUGE_2MB = 21 << 26.
MAP_HUGE_1GB & MAP_HUGE_2MB != 0.
This commit is contained in:
Wenbo Wang 2023-07-27 10:28:45 +08:00
parent 4e50d6714d
commit 8e0eefda3b

View file

@ -276,7 +276,7 @@ static void* unix_mmap(void* addr, size_t size, size_t try_alignment, int protec
*is_large = true; *is_large = true;
p = unix_mmap_prim(addr, size, try_alignment, protect_flags, lflags, lfd); p = unix_mmap_prim(addr, size, try_alignment, protect_flags, lflags, lfd);
#ifdef MAP_HUGE_1GB #ifdef MAP_HUGE_1GB
if (p == NULL && (lflags & MAP_HUGE_1GB) != 0) { if (p == NULL && (lflags & MAP_HUGE_1GB) == MAP_HUGE_1GB) {
mi_huge_pages_available = false; // don't try huge 1GiB pages again mi_huge_pages_available = false; // don't try huge 1GiB pages again
_mi_warning_message("unable to allocate huge (1GiB) page, trying large (2MiB) pages instead (errno: %i)\n", errno); _mi_warning_message("unable to allocate huge (1GiB) page, trying large (2MiB) pages instead (errno: %i)\n", errno);
lflags = ((lflags & ~MAP_HUGE_1GB) | MAP_HUGE_2MB); lflags = ((lflags & ~MAP_HUGE_1GB) | MAP_HUGE_2MB);