From a5a6d1be22ec8eb4c4e24de6f945662fb1c93ab6 Mon Sep 17 00:00:00 2001 From: lizzie Date: Mon, 30 Mar 2026 09:07:08 +0000 Subject: [PATCH] madvise() ifdef --- src/core/address_space.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/address_space.cpp b/src/core/address_space.cpp index 394201cf0..4830f65a5 100644 --- a/src/core/address_space.cpp +++ b/src/core/address_space.cpp @@ -681,15 +681,14 @@ struct AddressSpace::Impl { throw std::bad_alloc{}; } shm_unlink(shm_path.c_str()); -#elif defined(__FreeBSD__) - backing_fd = memfd_create("BackingDmem", 0); - if (backing_fd < 0) { - LOG_CRITICAL(Kernel_Vmm, "memfd_create failed: {}", strerror(errno)); - throw std::bad_alloc{}; - } #else +#ifndef __FreeBSD__ madvise(virtual_base, virtual_size, MADV_HUGEPAGE); - +#endif + // NOTE: If you add MFD_HUGETLB or whatever, remember that FBSD will break (libc bug) + // so please, do not, add MFD_* whatever unless you ifdef it away (must be 0 for FBSD) + // using sized pages as well causes incessant vm_reclaim calls in kernel, do not use on FBSD + // under any circumstances. backing_fd = memfd_create("BackingDmem", 0); if (backing_fd < 0) { LOG_CRITICAL(Kernel_Vmm, "memfd_create failed: {}", strerror(errno));