vppinfra: Place hugepage MMAP call behind linux specific ifdef 45/40345/2
authorTom Jones <thj@freebsd.org>
Mon, 29 Jan 2024 15:16:27 +0000 (15:16 +0000)
committerDamjan Marion <dmarion@0xa5.net>
Sun, 18 Feb 2024 16:06:31 +0000 (16:06 +0000)
Type: improvement
Change-Id: I3a48ec4fd4a4063b6e3792b87def7bb796fc947c
Signed-off-by: Tom Jones <thj@freebsd.org>
src/vppinfra/bihash_template.c

index 38354a1..8094321 100644 (file)
@@ -106,8 +106,10 @@ static inline void *BV (alloc_aligned) (BVT (clib_bihash) * h, uword nbytes)
       void *base, *rv;
       uword alloc = alloc_arena_next (h) - alloc_arena_mapped (h);
       int mmap_flags = MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS;
+#if __linux__
       int mmap_flags_huge = (mmap_flags | MAP_HUGETLB | MAP_LOCKED |
                             BIHASH_LOG2_HUGEPAGE_SIZE << MAP_HUGE_SHIFT);
+#endif /* __linux__ */
 
       /* new allocation is 25% of existing one */
       if (alloc_arena_mapped (h) >> 2 > alloc)
@@ -118,7 +120,11 @@ static inline void *BV (alloc_aligned) (BVT (clib_bihash) * h, uword nbytes)
 
       base = (void *) (uword) (alloc_arena (h) + alloc_arena_mapped (h));
 
+#if __linux__
       rv = mmap (base, alloc, PROT_READ | PROT_WRITE, mmap_flags_huge, -1, 0);
+#elif __FreeBSD__
+      rv = MAP_FAILED;
+#endif /* __linux__ */
 
       /* fallback - maybe we are still able to allocate normal pages */
       if (rv == MAP_FAILED || mlock (base, alloc) != 0)