From 67e7f016d21c36778b22f8c2c2480868bf603cd8 Mon Sep 17 00:00:00 2001 From: Tom Jones Date: Mon, 29 Jan 2024 15:16:27 +0000 Subject: vppinfra: Place hugepage MMAP call behind linux specific ifdef Type: improvement Change-Id: I3a48ec4fd4a4063b6e3792b87def7bb796fc947c Signed-off-by: Tom Jones --- src/vppinfra/bihash_template.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/vppinfra') diff --git a/src/vppinfra/bihash_template.c b/src/vppinfra/bihash_template.c index 38354a12992..8094321bc89 100644 --- a/src/vppinfra/bihash_template.c +++ b/src/vppinfra/bihash_template.c @@ -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) -- cgit 1.2.3-korg