Add node, frame to vlib main loop perf analysis callback arguments 95/19295/2
authorDave Barach <dave@barachs.net>
Wed, 1 May 2019 15:30:13 +0000 (11:30 -0400)
committerFlorin Coras <florin.coras@gmail.com>
Wed, 1 May 2019 18:55:42 +0000 (18:55 +0000)
Change-Id: Iaa5cd89791b0dfdb56a75009c564581d10696d83
Signed-off-by: Dave Barach <dave@barachs.net>
src/plugins/perfmon/perfmon_periodic.c
src/vlib/main.c
src/vlib/main.h

index 944a8e3..d21b464 100644 (file)
@@ -33,7 +33,9 @@ perf_event_open (struct perf_event_attr *hw_event, pid_t pid, int cpu,
 }
 
 static void
-read_current_perf_counters (vlib_main_t * vm, u64 * c0, u64 * c1)
+read_current_perf_counters (vlib_main_t * vm, u64 * c0, u64 * c1,
+                           vlib_node_runtime_t * node,
+                           vlib_frame_t * frame, int before_or_after)
 {
   int i;
   u64 *cc;
index ecadc19..759c1d0 100644 (file)
@@ -680,13 +680,16 @@ vlib_node_runtime_update_stats (vlib_main_t * vm,
   return r;
 }
 
-static inline void
-vlib_node_runtime_perf_counter (vlib_main_t * vm, u64 * pmc0, u64 * pmc1)
+always_inline void
+vlib_node_runtime_perf_counter (vlib_main_t * vm, u64 * pmc0, u64 * pmc1,
+                               vlib_node_runtime_t * node,
+                               vlib_frame_t * frame, int before_or_after)
 {
   *pmc0 = 0;
   *pmc1 = 0;
   if (PREDICT_FALSE (vm->vlib_node_runtime_perf_counter_cb != 0))
-    (*vm->vlib_node_runtime_perf_counter_cb) (vm, pmc0, pmc1);
+    (*vm->vlib_node_runtime_perf_counter_cb) (vm, pmc0, pmc1, node,
+                                             frame, before_or_after);
 }
 
 always_inline void
@@ -1181,7 +1184,8 @@ dispatch_node (vlib_main_t * vm,
                             last_time_stamp, frame ? frame->n_vectors : 0,
                             /* is_after */ 0);
 
-  vlib_node_runtime_perf_counter (vm, &pmc_before[0], &pmc_before[1]);
+  vlib_node_runtime_perf_counter (vm, &pmc_before[0], &pmc_before[1],
+                                 node, frame, 0 /* before */ );
 
   /*
    * Turn this on if you run into
@@ -1215,7 +1219,8 @@ dispatch_node (vlib_main_t * vm,
    * To validate accounting: pmc_delta = t - pmc_before;
    * perf ticks should equal clocks/pkt...
    */
-  vlib_node_runtime_perf_counter (vm, &pmc_after[0], &pmc_after[1]);
+  vlib_node_runtime_perf_counter (vm, &pmc_after[0], &pmc_after[1], node,
+                                 frame, 1 /* after */ );
 
   pmc_delta[0] = pmc_after[0] - pmc_before[0];
   pmc_delta[1] = pmc_after[1] - pmc_before[1];
index d2c4213..42f0c51 100644 (file)
@@ -95,7 +95,9 @@ typedef struct vlib_main_t
 
   /* Main loop hw / sw performance counters */
   void (*vlib_node_runtime_perf_counter_cb) (struct vlib_main_t *,
-                                            u64 *, u64 *);
+                                            u64 *, u64 *,
+                                            vlib_node_runtime_t *,
+                                            vlib_frame_t *, int);
 
   /* Every so often we switch to the next counter. */
 #define VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE 7