summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/pmalloc.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-04-16 12:00:14 -0400
committerDamjan Marion <dmarion@me.com>2020-04-21 10:26:14 +0000
commit16e4a4a0ae39ebc1ded1b6dba2799b176aee1828 (patch)
tree14e21d5be2bb77b9301b5cb56118e3e9d8293811 /src/vppinfra/pmalloc.c
parentb9753540d2a69bbab807653fc3d0c1b43ec4d6d5 (diff)
vppinfra: bihash improvements
Template instances can allocate BIHASH_KVP_PER_PAGE data records tangent to the bucket, to remove a dependent read / prefetch. Template instances can ask for immediate memory allocation, to avoid several branches in the lookup path. Clean up l2 fib, gpb plugin codes: use clib_bihash_get_bucket(...) Use hugepages for bihash allocation arenas Type: improvement Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Damjan Marion <damarion@cisco.com> Change-Id: I92fc11bc58e48d84e2d61f44580916dd1c56361c
Diffstat (limited to 'src/vppinfra/pmalloc.c')
-rw-r--r--src/vppinfra/pmalloc.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c
index cca8039433d..e0f3f3a6585 100644
--- a/src/vppinfra/pmalloc.c
+++ b/src/vppinfra/pmalloc.c
@@ -63,9 +63,8 @@ pmalloc_validate_numa_node (u32 * numa_node)
int
clib_pmalloc_init (clib_pmalloc_main_t * pm, uword base_addr, uword size)
{
- uword off, pagesize;
+ uword base, pagesize;
u64 *pt = 0;
- int mmap_flags;
ASSERT (pm->error == 0);
@@ -84,32 +83,16 @@ clib_pmalloc_init (clib_pmalloc_main_t * pm, uword base_addr, uword size)
pm->max_pages = size >> pm->def_log2_page_sz;
- /* reserve VA space for future growth */
- mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
+ base = clib_mem_vm_reserve (base_addr, size, pm->def_log2_page_sz);
- if (base_addr)
- mmap_flags |= MAP_FIXED;
-
- pm->base = mmap (uword_to_pointer (base_addr, void *), size + pagesize,
- PROT_NONE, mmap_flags, -1, 0);
-
- if (pm->base == MAP_FAILED)
+ if (base == ~0)
{
- pm->error = clib_error_return_unix (0, "failed to reserve %u pages");
+ pm->error = clib_error_return (0, "failed to reserve %u pages",
+ pm->max_pages);
return -1;
}
- off = round_pow2 (pointer_to_uword (pm->base), pagesize) -
- pointer_to_uword (pm->base);
-
- /* trim start and end of reservation to be page aligned */
- if (off)
- {
- munmap (pm->base, off);
- pm->base += off;
- }
-
- munmap (pm->base + ((uword) pm->max_pages * pagesize), pagesize - off);
+ pm->base = uword_to_pointer (base, void *);
return 0;
}