From 8973b07eecbbfe23a5267975f8052a5c6339c756 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 1 Mar 2022 15:51:18 +0100 Subject: stats: refactor Type: refactor Change-Id: Ifd533a095d979dc55bfbe5fac7e0b7510a4d900c Signed-off-by: Damjan Marion --- src/vlib/counter.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/vlib/counter.c') diff --git a/src/vlib/counter.c b/src/vlib/counter.c index 186b48d869e..ceaf0132e64 100644 --- a/src/vlib/counter.c +++ b/src/vlib/counter.c @@ -38,7 +38,7 @@ */ #include -#include +#include void vlib_clear_simple_counters (vlib_simple_counter_main_t * cm) @@ -80,7 +80,7 @@ vlib_validate_simple_counter (vlib_simple_counter_main_t * cm, u32 index) { vlib_thread_main_t *tm = vlib_get_thread_main (); int i, resized = 0; - void *oldheap = vlib_stats_push_heap (cm->counters); + void *oldheap = vlib_stats_set_heap (); vec_validate (cm->counters, tm->n_vlib_mains - 1); for (i = 0; i < tm->n_vlib_mains; i++) @@ -93,12 +93,10 @@ vlib_validate_simple_counter (vlib_simple_counter_main_t * cm, u32 index) vec_validate_aligned (cm->counters[i], index, CLIB_CACHE_LINE_BYTES); } + clib_mem_set_heap (oldheap); /* Avoid the epoch increase when there was no counter vector resize. */ if (resized) - vlib_stats_pop_heap (cm, oldheap, index, - 2 /* STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE */); - else - clib_mem_set_heap (oldheap); + vlib_stats_update_counter (cm, index, STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE); } void @@ -108,7 +106,7 @@ vlib_free_simple_counter (vlib_simple_counter_main_t * cm) vlib_stats_delete_cm (cm); - void *oldheap = vlib_stats_push_heap (cm->counters); + void *oldheap = vlib_stats_set_heap (); for (i = 0; i < vec_len (cm->counters); i++) vec_free (cm->counters[i]); vec_free (cm->counters); @@ -120,7 +118,7 @@ vlib_validate_combined_counter (vlib_combined_counter_main_t * cm, u32 index) { vlib_thread_main_t *tm = vlib_get_thread_main (); int i, resized = 0; - void *oldheap = vlib_stats_push_heap (cm->counters); + void *oldheap = vlib_stats_set_heap (); vec_validate (cm->counters, tm->n_vlib_mains - 1); for (i = 0; i < tm->n_vlib_mains; i++) @@ -133,12 +131,11 @@ vlib_validate_combined_counter (vlib_combined_counter_main_t * cm, u32 index) vec_validate_aligned (cm->counters[i], index, CLIB_CACHE_LINE_BYTES); } + clib_mem_set_heap (oldheap); /* Avoid the epoch increase when there was no counter vector resize. */ if (resized) - vlib_stats_pop_heap (cm, oldheap, index, - 3 /*STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED */); - else - clib_mem_set_heap (oldheap); + vlib_stats_update_counter (cm, index, + STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED); } int @@ -147,7 +144,7 @@ int { vlib_thread_main_t *tm = vlib_get_thread_main (); int i; - void *oldheap = vlib_stats_push_heap (cm->counters); + void *oldheap = vlib_stats_set_heap (); /* Possibly once in recorded history */ if (PREDICT_FALSE (vec_len (cm->counters) == 0)) @@ -180,7 +177,7 @@ vlib_free_combined_counter (vlib_combined_counter_main_t * cm) vlib_stats_delete_cm (cm); - void *oldheap = vlib_stats_push_heap (cm->counters); + void *oldheap = vlib_stats_set_heap (); for (i = 0; i < vec_len (cm->counters); i++) vec_free (cm->counters[i]); vec_free (cm->counters); -- cgit 1.2.3-korg