From 32dcd3b2f227dec638c39ade0c58d6741d83ec30 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Mon, 8 Jul 2019 12:25:38 -0400 Subject: vppinfra: allocate bihash virtual space on demand Reduces the vpp image virtual size by multiple gigabytes Add a "show bihash" command which displays configured and current virtual space in use by bihash tables. Modify the .py test framework to call "show bihash" on test tear-down Type: refactor Change-Id: Ifc1b7e2c43d29bbef645f6802fa29ff8ef09940c Signed-off-by: Dave Barach --- src/vppinfra/bihash_template.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/vppinfra/bihash_template.h') diff --git a/src/vppinfra/bihash_template.h b/src/vppinfra/bihash_template.h index d145b61952a..2e2ba911b7c 100644 --- a/src/vppinfra/bihash_template.h +++ b/src/vppinfra/bihash_template.h @@ -129,6 +129,7 @@ BVS (clib_bihash) u32 nbuckets; u32 log2_nbuckets; + u64 memory_size; u8 *name; u64 *freelists; @@ -157,6 +158,8 @@ BVS (clib_bihash) } BVT (clib_bihash); +extern void **clib_all_bihashes; + #if BIHASH_32_64_SVM #undef alloc_arena_next #undef alloc_arena_size @@ -313,6 +316,8 @@ int BV (clib_bihash_search) (BVT (clib_bihash) * h, void BV (clib_bihash_foreach_key_value_pair) (BVT (clib_bihash) * h, void *callback, void *arg); +void *clib_all_bihash_set_heap (void); +void clib_bihash_copied (void *dst, void *src); format_function_t BV (format_bihash); format_function_t BV (format_bihash_kvp); @@ -326,6 +331,9 @@ static inline int BV (clib_bihash_search_inline_with_hash) BVT (clib_bihash_bucket) * b; int i, limit; + if (PREDICT_FALSE (alloc_arena (h) == 0)) + return -1; + bucket_index = hash & (h->nbuckets - 1); b = &h->buckets[bucket_index]; @@ -389,6 +397,9 @@ static inline void BV (clib_bihash_prefetch_data) BVT (clib_bihash_value) * v; BVT (clib_bihash_bucket) * b; + if (PREDICT_FALSE (alloc_arena (h) == 0)) + return; + bucket_index = hash & (h->nbuckets - 1); b = &h->buckets[bucket_index]; @@ -414,6 +425,9 @@ static inline int BV (clib_bihash_search_inline_2_with_hash) ASSERT (valuep); + if (PREDICT_FALSE (alloc_arena (h) == 0)) + return -1; + bucket_index = hash & (h->nbuckets - 1); b = &h->buckets[bucket_index]; -- cgit 1.2.3-korg