diff options
author | Tom Jones <thj@freebsd.org> | 2024-01-29 15:16:27 +0000 |
---|---|---|
committer | Damjan Marion <dmarion@0xa5.net> | 2024-02-18 16:06:31 +0000 |
commit | 67e7f016d21c36778b22f8c2c2480868bf603cd8 (patch) | |
tree | 1d13bbb39a57eedb5d4d141fab28b0b283ee438b /src | |
parent | 9bf4f8fb5823f108601b50ba4b787f17b854abdc (diff) |
vppinfra: Place hugepage MMAP call behind linux specific ifdef
Type: improvement
Change-Id: I3a48ec4fd4a4063b6e3792b87def7bb796fc947c
Signed-off-by: Tom Jones <thj@freebsd.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/vppinfra/bihash_template.c | 6 |
1 files changed, 6 insertions, 0 deletions
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) |