summaryrefslogtreecommitdiffstats
path: root/src/plugins/perfmon/perfmon.c
diff options
context:
space:
mode:
authorRay Kinsella <mdr@ashroe.eu>2021-03-10 15:12:02 +0000
committerDamjan Marion <dmarion@me.com>2021-04-01 13:07:09 +0000
commit7e3862927ec0fd92a1237a9b4286aaf410f34166 (patch)
tree242b9f604622270f830dc260e3edd0fc5e8d6296 /src/plugins/perfmon/perfmon.c
parent74a4a70efaa4a3af998cae32ff3612ad7a7fa879 (diff)
perfmon: combined set and start command.
Original set, start, stop, reset, show etc interface was somewhat cumbersome, we can improve slightly by combining set and start. Type: improvement Signed-off-by: Ray Kinsella <mdr@ashroe.eu> Change-Id: I7b865b2c29d2ab32adbd24d7f8a580da6990bb76
Diffstat (limited to 'src/plugins/perfmon/perfmon.c')
-rw-r--r--src/plugins/perfmon/perfmon.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/perfmon/perfmon.c b/src/plugins/perfmon/perfmon.c
index 316e7a5d60a..f9402f8f8e9 100644
--- a/src/plugins/perfmon/perfmon.c
+++ b/src/plugins/perfmon/perfmon.c
@@ -79,7 +79,7 @@ perfmon_reset (vlib_main_t *vm)
pm->active_bundle = 0;
}
-clib_error_t *
+static clib_error_t *
perfmon_set (vlib_main_t *vm, perfmon_bundle_t *b)
{
clib_error_t *err = 0;
@@ -212,17 +212,20 @@ error:
}
clib_error_t *
-perfmon_start (vlib_main_t *vm)
+perfmon_start (vlib_main_t *vm, perfmon_bundle_t *b)
{
+ clib_error_t *err = 0;
perfmon_main_t *pm = &perfmon_main;
- int n_groups = vec_len (pm->group_fds);
-
- if (n_groups == 0)
- return clib_error_return (0, "no bundle configured");
+ int n_groups;
if (pm->is_running == 1)
return clib_error_return (0, "already running");
+ if ((err = perfmon_set (vm, b)) != 0)
+ return err;
+
+ n_groups = vec_len (pm->group_fds);
+
for (int i = 0; i < n_groups; i++)
{
if (ioctl (pm->group_fds[i], PERF_EVENT_IOC_ENABLE,
@@ -238,8 +241,10 @@ perfmon_start (vlib_main_t *vm)
vlib_node_set_dispatch_wrapper (vlib_get_main_by_index (i),
perfmon_dispatch_wrapper);
}
+
pm->sample_time = vlib_time_now (vm);
pm->is_running = 1;
+
return 0;
}