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 <dave@barachs.net>
diff --git a/src/vppinfra/bihash_template.h b/src/vppinfra/bihash_template.h
index d145b61..2e2ba91 100644
--- a/src/vppinfra/bihash_template.h
+++ b/src/vppinfra/bihash_template.h
@@ -129,6 +129,7 @@
u32 nbuckets;
u32 log2_nbuckets;
+ u64 memory_size;
u8 *name;
u64 *freelists;
@@ -157,6 +158,8 @@
} 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 @@
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 @@
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 @@
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 @@
ASSERT (valuep);
+ if (PREDICT_FALSE (alloc_arena (h) == 0))
+ return -1;
+
bucket_index = hash & (h->nbuckets - 1);
b = &h->buckets[bucket_index];