summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-15 15:27:24 +0200
committerFlorin Coras <florin.coras@gmail.com>2022-04-15 17:53:11 +0000
commit4b922ff051f1e0adb27c9b4cd13c10069a657a98 (patch)
tree25a0ea663ac7ab123a3170c2370947ea506251dd
parent8cb5d36c7e7492d3cc314e6b78dea571bbcc4889 (diff)
stats: store heap in the directory_entry vector
Type: improvement Change-Id: I878803d14d1070ef5a00ed9d3f72022906d55191 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--src/vlib/stats/init.c9
-rw-r--r--src/vlib/stats/stats.c8
2 files changed, 2 insertions, 15 deletions
diff --git a/src/vlib/stats/init.c b/src/vlib/stats/init.c
index 2a7b6f53c53..16a47c2f78d 100644
--- a/src/vlib/stats/init.c
+++ b/src/vlib/stats/init.c
@@ -45,7 +45,6 @@ vlib_stats_init (vlib_main_t *vm)
vlib_stats_shared_header_t *shared_header;
vlib_stats_collector_reg_t reg = {};
- void *oldheap;
uword memory_size, sys_page_sz;
int mfd;
char *mem_name = "stat segment";
@@ -94,16 +93,14 @@ vlib_stats_init (vlib_main_t *vm)
sm->n_locks = 0;
clib_spinlock_init (sm->stat_segment_lockp);
- oldheap = clib_mem_set_heap (sm->heap);
-
/* Set up the name to counter-vector hash table */
- sm->directory_vector = 0;
+ sm->directory_vector =
+ vec_new_heap (typeof (sm->directory_vector[0]), STAT_COUNTERS, heap);
sm->dir_vector_first_free_elt = CLIB_U32_MAX;
shared_header->epoch = 1;
/* Scalar stats and node counters */
- vec_validate (sm->directory_vector, STAT_COUNTERS - 1);
#define _(E, t, n, p) \
strcpy (sm->directory_vector[STAT_COUNTER_##E].name, p "/" #n); \
sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t;
@@ -112,8 +109,6 @@ vlib_stats_init (vlib_main_t *vm)
/* Save the vector in the shared segment, for clients */
shared_header->directory_vector = sm->directory_vector;
- clib_mem_set_heap (oldheap);
-
vlib_stats_register_mem_heap (heap);
reg.collect_fn = vector_rate_collector_fn;
diff --git a/src/vlib/stats/stats.c b/src/vlib/stats/stats.c
index a19909d0dc4..61dadd74b1c 100644
--- a/src/vlib/stats/stats.c
+++ b/src/vlib/stats/stats.c
@@ -105,11 +105,8 @@ u32
vlib_stats_create_counter (vlib_stats_entry_t *e)
{
vlib_stats_segment_t *sm = vlib_stats_get_segment ();
- void *oldheap;
u32 index;
- oldheap = clib_mem_set_heap (sm->heap);
-
if (sm->dir_vector_first_free_elt != CLIB_U32_MAX)
{
index = sm->dir_vector_first_free_elt;
@@ -123,7 +120,6 @@ vlib_stats_create_counter (vlib_stats_entry_t *e)
sm->directory_vector[index] = *e;
- clib_mem_set_heap (oldheap);
hash_set_str_key_alloc (&sm->directory_vector_by_name, e->name, index);
return index;
@@ -134,7 +130,6 @@ vlib_stats_remove_entry (u32 entry_index)
{
vlib_stats_segment_t *sm = vlib_stats_get_segment ();
vlib_stats_entry_t *e = vlib_stats_get_entry (sm, entry_index);
- void *oldheap;
counter_t **c;
vlib_counter_t **vc;
u32 i;
@@ -142,8 +137,6 @@ vlib_stats_remove_entry (u32 entry_index)
if (entry_index >= vec_len (sm->directory_vector))
return;
- oldheap = clib_mem_set_heap (sm->heap);
-
vlib_stats_segment_lock ();
switch (e->type)
@@ -179,7 +172,6 @@ vlib_stats_remove_entry (u32 entry_index)
vlib_stats_segment_unlock ();
- clib_mem_set_heap (oldheap);
hash_unset_str_key_free (&sm->directory_vector_by_name, e->name);
memset (e, 0, sizeof (*e));