summaryrefslogtreecommitdiffstats
path: root/src/plugins/perfmon/perfmon.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-26 13:06:13 +0100
committerDamjan Marion <damarion@cisco.com>2021-03-26 16:33:21 +0100
commit6ffb7c61899eb782416cbd2f117042a583f189f7 (patch)
treef6bd132d53b0aded6b235d13200dba2864afc7d8 /src/plugins/perfmon/perfmon.c
parent83f13e45bcd4b1018aa29bb6f32324c32f3a11a8 (diff)
vlib: introduce vlib_get_main_by_index(), vlib_get_n_threads()
Type: improvement Change-Id: If3da7d4338470912f37ff1794620418d928fb77f Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/perfmon/perfmon.c')
-rw-r--r--src/plugins/perfmon/perfmon.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/plugins/perfmon/perfmon.c b/src/plugins/perfmon/perfmon.c
index 7a69d454fd0..316e7a5d60a 100644
--- a/src/plugins/perfmon/perfmon.c
+++ b/src/plugins/perfmon/perfmon.c
@@ -48,8 +48,8 @@ perfmon_reset (vlib_main_t *vm)
uword page_size = clib_mem_get_page_size ();
if (pm->is_running)
- for (int i = 0; i < vec_len (vlib_mains); i++)
- vlib_node_set_dispatch_wrapper (vlib_mains[i], 0);
+ for (int i = 0; i < vlib_get_n_threads (); i++)
+ vlib_node_set_dispatch_wrapper (vlib_get_main_by_index (i), 0);
for (int i = 0; i < vec_len (pm->fds_to_close); i++)
close (pm->fds_to_close[i]);
@@ -104,7 +104,7 @@ perfmon_set (vlib_main_t *vm, perfmon_bundle_t *b)
{
vec_add2 (pm->default_instance_type, it, 1);
it->name = is_node ? "Thread/Node" : "Thread";
- for (int i = 0; i < vec_len (vlib_mains); i++)
+ for (int i = 0; i < vlib_get_n_threads (); i++)
{
vlib_worker_thread_t *w = vlib_worker_threads + i;
perfmon_instance_t *in;
@@ -114,7 +114,7 @@ perfmon_set (vlib_main_t *vm, perfmon_bundle_t *b)
in->name = (char *) format (0, "%s (%u)%c", w->name, i, 0);
}
if (is_node)
- vec_validate (pm->thread_runtimes, vec_len (vlib_mains) - 1);
+ vec_validate (pm->thread_runtimes, vlib_get_n_threads () - 1);
}
else
{
@@ -234,8 +234,8 @@ perfmon_start (vlib_main_t *vm)
}
if (pm->active_bundle->type == PERFMON_BUNDLE_TYPE_NODE)
{
- for (int i = 0; i < vec_len (vlib_mains); i++)
- vlib_node_set_dispatch_wrapper (vlib_mains[i],
+ for (int i = 0; i < vlib_get_n_threads (); i++)
+ vlib_node_set_dispatch_wrapper (vlib_get_main_by_index (i),
perfmon_dispatch_wrapper);
}
pm->sample_time = vlib_time_now (vm);
@@ -254,8 +254,8 @@ perfmon_stop (vlib_main_t *vm)
if (pm->active_bundle->type == PERFMON_BUNDLE_TYPE_NODE)
{
- for (int i = 0; i < vec_len (vlib_mains); i++)
- vlib_node_set_dispatch_wrapper (vlib_mains[i], 0);
+ for (int i = 0; i < vlib_get_n_threads (); i++)
+ vlib_node_set_dispatch_wrapper (vlib_get_main_by_index (i), 0);
}
for (int i = 0; i < n_groups; i++)