perfmon: collect data on selected thread(s)
[vpp.git] / src / vlib / threads.c
index 45e4d89..e6ac6db 100644 (file)
@@ -801,7 +801,7 @@ start_workers (vlib_main_t * vm)
 
              /* fork the frame dispatch queue */
              nm_clone->pending_frames = 0;
-             vec_validate (nm_clone->pending_frames, 10);      /* $$$$$?????? */
+             vec_validate (nm_clone->pending_frames, 10);
              _vec_len (nm_clone->pending_frames) = 0;
 
              /* fork nodes */
@@ -850,6 +850,21 @@ start_workers (vlib_main_t * vm)
                                         n->runtime_data_bytes));
              }
 
+             nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT] =
+               vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT],
+                                CLIB_CACHE_LINE_BYTES);
+             vec_foreach (rt,
+                          nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT])
+             {
+               vlib_node_t *n = vlib_get_node (vm, rt->node_index);
+               rt->thread_index = vm_clone->thread_index;
+               /* copy initial runtime_data from node */
+               if (n->runtime_data && n->runtime_data_bytes > 0)
+                 clib_memcpy (rt->runtime_data, n->runtime_data,
+                              clib_min (VLIB_NODE_RUNTIME_DATA_SIZE,
+                                        n->runtime_data_bytes));
+             }
+
              nm_clone->processes = vec_dup_aligned (nm->processes,
                                                     CLIB_CACHE_LINE_BYTES);
 
@@ -1173,6 +1188,33 @@ vlib_worker_thread_node_refork (void)
 
   vec_free (old_rt);
 
+  /* re-clone pre-input nodes */
+  old_rt = nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT];
+  nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT] =
+    vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT],
+                    CLIB_CACHE_LINE_BYTES);
+
+  vec_foreach (rt, nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT])
+  {
+    vlib_node_t *n = vlib_get_node (vm, rt->node_index);
+    rt->thread_index = vm_clone->thread_index;
+    /* copy runtime_data, will be overwritten later for existing rt */
+    if (n->runtime_data && n->runtime_data_bytes > 0)
+      clib_memcpy_fast (rt->runtime_data, n->runtime_data,
+                       clib_min (VLIB_NODE_RUNTIME_DATA_SIZE,
+                                 n->runtime_data_bytes));
+  }
+
+  for (j = 0; j < vec_len (old_rt); j++)
+    {
+      rt = vlib_node_get_runtime (vm_clone, old_rt[j].node_index);
+      rt->state = old_rt[j].state;
+      clib_memcpy_fast (rt->runtime_data, old_rt[j].runtime_data,
+                       VLIB_NODE_RUNTIME_DATA_SIZE);
+    }
+
+  vec_free (old_rt);
+
   nm_clone->processes = vec_dup_aligned (nm->processes,
                                         CLIB_CACHE_LINE_BYTES);
 }