FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
threads.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #define _GNU_SOURCE
16 
17 #include <signal.h>
18 #include <math.h>
19 #include <vppinfra/format.h>
20 #include <vppinfra/time_range.h>
21 #include <vppinfra/interrupt.h>
22 #include <vppinfra/linux/sysfs.h>
23 #include <vlib/vlib.h>
24 
25 #include <vlib/threads.h>
26 
27 #include <vlib/stat_weak_inlines.h>
28 
29 u32
30 vl (void *p)
31 {
32  return vec_len (p);
33 }
34 
37 
38 /*
39  * Barrier tracing can be enabled on a normal build to collect information
40  * on barrier use, including timings and call stacks. Deliberately not
41  * keyed off CLIB_DEBUG, because that can add significant overhead which
42  * imapacts observed timings.
43  */
44 
45 static inline void
46 barrier_trace_sync (f64 t_entry, f64 t_open, f64 t_closed)
47 {
49  return;
50 
51  ELOG_TYPE_DECLARE (e) = {
52  .format = "bar-trace-%s-#%d",
53  .format_args = "T4i4",
54  };
55 
56  struct
57  {
58  u32 caller, count, t_entry, t_open, t_closed;
59  } *ed = 0;
60 
62  ed->count = (int) vlib_worker_threads[0].barrier_sync_count;
63  ed->caller = elog_string (&vlib_global_main.elog_main,
65  ed->t_entry = (int) (1000000.0 * t_entry);
66  ed->t_open = (int) (1000000.0 * t_open);
67  ed->t_closed = (int) (1000000.0 * t_closed);
68 }
69 
70 static inline void
72 {
74  return;
75 
76  ELOG_TYPE_DECLARE (e) = {
77  .format = "bar-syncrec-%s-#%d",
78  .format_args = "T4i4",
79  };
80 
81  struct
82  {
83  u32 caller, depth;
84  } *ed = 0;
85 
87  ed->depth = (int) vlib_worker_threads[0].recursion_level - 1;
88  ed->caller = elog_string (&vlib_global_main.elog_main,
90 }
91 
92 static inline void
94 {
96  return;
97 
98  ELOG_TYPE_DECLARE (e) = {
99  .format = "bar-relrrec-#%d",
100  .format_args = "i4",
101  };
102 
103  struct
104  {
105  u32 depth;
106  } *ed = 0;
107 
109  ed->depth = (int) vlib_worker_threads[0].recursion_level;
110 }
111 
112 static inline void
113 barrier_trace_release (f64 t_entry, f64 t_closed_total, f64 t_update_main)
114 {
116  return;
117 
118  ELOG_TYPE_DECLARE (e) = {
119  .format = "bar-rel-#%d-e%d-u%d-t%d",
120  .format_args = "i4i4i4i4",
121  };
122 
123  struct
124  {
125  u32 count, t_entry, t_update_main, t_closed_total;
126  } *ed = 0;
127 
129  ed->t_entry = (int) (1000000.0 * t_entry);
130  ed->t_update_main = (int) (1000000.0 * t_update_main);
131  ed->t_closed_total = (int) (1000000.0 * t_closed_total);
132  ed->count = (int) vlib_worker_threads[0].barrier_sync_count;
133 
134  /* Reset context for next trace */
136 }
137 
138 uword
140 {
141  return vec_len (vlib_thread_stacks);
142 }
143 
144 void
146 {
147  int pthread_setname_np (pthread_t __target_thread, const char *__name);
148  int rv;
149  pthread_t thread = pthread_self ();
150 
151  if (thread)
152  {
153  rv = pthread_setname_np (thread, name);
154  if (rv)
155  clib_warning ("pthread_setname_np returned %d", rv);
156  }
157 }
158 
159 static int
160 sort_registrations_by_no_clone (void *a0, void *a1)
161 {
162  vlib_thread_registration_t **tr0 = a0;
163  vlib_thread_registration_t **tr1 = a1;
164 
165  return ((i32) ((*tr0)->no_data_structure_clone)
166  - ((i32) ((*tr1)->no_data_structure_clone)));
167 }
168 
169 
170 /* Called early in the init sequence */
171 
172 clib_error_t *
174 {
178  u32 n_vlib_mains = 1;
179  u32 first_index = 1;
180  u32 i;
181  uword *avail_cpu;
182 
183  /* get bitmaps of active cpu cores and sockets */
184  tm->cpu_core_bitmap =
185  clib_sysfs_list_to_bitmap ("/sys/devices/system/cpu/online");
186  tm->cpu_socket_bitmap =
187  clib_sysfs_list_to_bitmap ("/sys/devices/system/node/online");
188 
189  avail_cpu = clib_bitmap_dup (tm->cpu_core_bitmap);
190 
191  /* skip cores */
192  for (i = 0; i < tm->skip_cores; i++)
193  {
194  uword c = clib_bitmap_first_set (avail_cpu);
195  if (c == ~0)
196  return clib_error_return (0, "no available cpus to skip");
197 
198  avail_cpu = clib_bitmap_set (avail_cpu, c, 0);
199  }
200 
201  /* grab cpu for main thread */
202  if (tm->main_lcore == ~0)
203  {
204  /* if main-lcore is not set, we try to use lcore 1 */
205  if (clib_bitmap_get (avail_cpu, 1))
206  tm->main_lcore = 1;
207  else
208  tm->main_lcore = clib_bitmap_first_set (avail_cpu);
209  if (tm->main_lcore == (u8) ~ 0)
210  return clib_error_return (0, "no available cpus to be used for the"
211  " main thread");
212  }
213  else
214  {
215  if (clib_bitmap_get (avail_cpu, tm->main_lcore) == 0)
216  return clib_error_return (0, "cpu %u is not available to be used"
217  " for the main thread", tm->main_lcore);
218  }
219  avail_cpu = clib_bitmap_set (avail_cpu, tm->main_lcore, 0);
220 
221  /* assume that there is socket 0 only if there is no data from sysfs */
222  if (!tm->cpu_socket_bitmap)
223  tm->cpu_socket_bitmap = clib_bitmap_set (0, 0, 1);
224 
225  /* pin main thread to main_lcore */
227  {
229  }
230  else
231  {
232  cpu_set_t cpuset;
233  CPU_ZERO (&cpuset);
234  CPU_SET (tm->main_lcore, &cpuset);
235  pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
236  }
237 
238  /* Set up thread 0 */
240  _vec_len (vlib_worker_threads) = 1;
244  w->cpu_id = tm->main_lcore;
245  w->lwp = syscall (SYS_gettid);
246  w->thread_id = pthread_self ();
247  tm->n_vlib_mains = 1;
248 
250 
251  if (tm->sched_policy != ~0)
252  {
253  struct sched_param sched_param;
254  if (!sched_getparam (w->lwp, &sched_param))
255  {
256  if (tm->sched_priority != ~0)
257  sched_param.sched_priority = tm->sched_priority;
258  sched_setscheduler (w->lwp, tm->sched_policy, &sched_param);
259  }
260  }
261 
262  /* assign threads to cores and set n_vlib_mains */
263  tr = tm->next;
264 
265  while (tr)
266  {
267  vec_add1 (tm->registrations, tr);
268  tr = tr->next;
269  }
270 
272 
273  for (i = 0; i < vec_len (tm->registrations); i++)
274  {
275  int j;
276  tr = tm->registrations[i];
277  tr->first_index = first_index;
278  first_index += tr->count;
279  n_vlib_mains += (tr->no_data_structure_clone == 0) ? tr->count : 0;
280 
281  /* construct coremask */
282  if (tr->use_pthreads || !tr->count)
283  continue;
284 
285  if (tr->coremask)
286  {
287  uword c;
288  /* *INDENT-OFF* */
290  if (clib_bitmap_get(avail_cpu, c) == 0)
291  return clib_error_return (0, "cpu %u is not available to be used"
292  " for the '%s' thread",c, tr->name);
293 
294  avail_cpu = clib_bitmap_set(avail_cpu, c, 0);
295  }
296  /* *INDENT-ON* */
297  }
298  else
299  {
300  for (j = 0; j < tr->count; j++)
301  {
302  /* Do not use CPU 0 by default - leave it to the host and IRQs */
303  uword avail_c0 = clib_bitmap_get (avail_cpu, 0);
304  avail_cpu = clib_bitmap_set (avail_cpu, 0, 0);
305 
306  uword c = clib_bitmap_first_set (avail_cpu);
307  /* Use CPU 0 as a last resort */
308  if (c == ~0 && avail_c0)
309  {
310  c = 0;
311  avail_c0 = 0;
312  }
313 
314  if (c == ~0)
315  return clib_error_return (0,
316  "no available cpus to be used for"
317  " the '%s' thread", tr->name);
318 
319  avail_cpu = clib_bitmap_set (avail_cpu, 0, avail_c0);
320  avail_cpu = clib_bitmap_set (avail_cpu, c, 0);
321  tr->coremask = clib_bitmap_set (tr->coremask, c, 1);
322  }
323  }
324  }
325 
326  clib_bitmap_free (avail_cpu);
327 
328  tm->n_vlib_mains = n_vlib_mains;
329 
330  /*
331  * Allocate the remaining worker threads, and thread stack vector slots
332  * from now on, calls to os_get_nthreads() will return the correct
333  * answer.
334  */
335  vec_validate_aligned (vlib_worker_threads, first_index - 1,
338  return 0;
339 }
340 
343 {
344  vlib_frame_queue_t *fq;
345 
346  fq = clib_mem_alloc_aligned (sizeof (*fq), CLIB_CACHE_LINE_BYTES);
347  clib_memset (fq, 0, sizeof (*fq));
348  fq->nelts = nelts;
351 
352  if (nelts & (nelts - 1))
353  {
354  fformat (stderr, "FATAL: nelts MUST be a power of 2\n");
355  abort ();
356  }
357 
358  return (fq);
359 }
360 
361 void vl_msg_api_handler_no_free (void *) __attribute__ ((weak));
362 void
364 {
365 }
366 
367 /* To be called by vlib worker threads upon startup */
368 void
370 {
372 
373  /*
374  * Note: disabling signals in worker threads as follows
375  * prevents the api post-mortem dump scheme from working
376  * {
377  * sigset_t s;
378  * sigfillset (&s);
379  * pthread_sigmask (SIG_SETMASK, &s, 0);
380  * }
381  */
382 
384 
385  if (vec_len (tm->thread_prefix) && w->registration->short_name)
386  {
387  w->name = format (0, "%v_%s_%d%c", tm->thread_prefix,
388  w->registration->short_name, w->instance_id, '\0');
389  vlib_set_thread_name ((char *) w->name);
390  }
391 
392  if (!w->registration->use_pthreads)
393  {
394 
395  /* Initial barrier sync, for both worker and i/o threads */
397 
399  ;
400 
402  }
403 }
404 
405 void *
407 {
408  void *rv;
409  vlib_worker_thread_t *w = arg;
410  vlib_main_t *vm = 0;
411 
412  w->lwp = syscall (SYS_gettid);
413  w->thread_id = pthread_self ();
414 
415  __os_thread_index = w - vlib_worker_threads;
416 
417  vm = vlib_global_main.vlib_mains[__os_thread_index];
418 
420  rv = (void *) clib_calljmp
421  ((uword (*)(uword)) w->thread_function,
423  /* NOTREACHED, we hope */
424  return rv;
425 }
426 
427 void
429 {
430  const char *sys_cpu_path = "/sys/devices/system/cpu/cpu";
431  const char *sys_node_path = "/sys/devices/system/node/node";
432  clib_bitmap_t *nbmp = 0, *cbmp = 0;
433  u32 node;
434  u8 *p = 0;
435  int core_id = -1, numa_id = -1;
436 
437  p = format (p, "%s%u/topology/core_id%c", sys_cpu_path, cpu_id, 0);
438  clib_sysfs_read ((char *) p, "%d", &core_id);
439  vec_reset_length (p);
440 
441  /* *INDENT-OFF* */
442  clib_sysfs_read ("/sys/devices/system/node/online", "%U",
443  unformat_bitmap_list, &nbmp);
444  clib_bitmap_foreach (node, nbmp) {
445  p = format (p, "%s%u/cpulist%c", sys_node_path, node, 0);
446  clib_sysfs_read ((char *) p, "%U", unformat_bitmap_list, &cbmp);
447  if (clib_bitmap_get (cbmp, cpu_id))
448  numa_id = node;
449  vec_reset_length (cbmp);
450  vec_reset_length (p);
451  }
452  /* *INDENT-ON* */
453  vec_free (nbmp);
454  vec_free (cbmp);
455  vec_free (p);
456 
457  w->core_id = core_id;
458  w->numa_id = numa_id;
459 }
460 
461 static clib_error_t *
463 {
466  void *(*fp_arg) (void *) = fp;
467  void *numa_heap;
468 
469  w->cpu_id = cpu_id;
471 
472  /* Set up NUMA-bound heap if indicated */
473  if (mm->per_numa_mheaps[w->numa_id] == 0)
474  {
475  /* If the user requested a NUMA heap, create it... */
476  if (tm->numa_heap_size)
477  {
478  clib_mem_set_numa_affinity (w->numa_id, 1 /* force */ );
479  numa_heap = clib_mem_create_heap (0 /* DIY */ , tm->numa_heap_size,
480  1 /* is_locked */ ,
481  "numa %u heap", w->numa_id);
483  mm->per_numa_mheaps[w->numa_id] = numa_heap;
484  }
485  else
486  {
487  /* Or, use the main heap */
488  mm->per_numa_mheaps[w->numa_id] = w->thread_mheap;
489  }
490  }
491 
493  return tm->cb.vlib_launch_thread_cb (fp, (void *) w, cpu_id);
494  else
495  {
496  pthread_t worker;
497  cpu_set_t cpuset;
498  CPU_ZERO (&cpuset);
499  CPU_SET (cpu_id, &cpuset);
500 
501  if (pthread_create (&worker, NULL /* attr */ , fp_arg, (void *) w))
502  return clib_error_return_unix (0, "pthread_create");
503 
504  if (pthread_setaffinity_np (worker, sizeof (cpu_set_t), &cpuset))
505  return clib_error_return_unix (0, "pthread_setaffinity_np");
506 
507  return 0;
508  }
509 }
510 
511 static clib_error_t *
513 {
515  int i, j;
517  vlib_main_t *vm_clone;
518  void *oldheap;
522  u32 n_vlib_mains = tm->n_vlib_mains;
523  u32 worker_thread_index;
525  vlib_stats_register_mem_heap (main_heap);
526 
528 
529  /* Set up the main thread */
531  w->elog_track.name = "main thread";
533 
534  if (vec_len (tm->thread_prefix))
535  {
536  w->name = format (0, "%v_main%c", tm->thread_prefix, '\0');
537  vlib_set_thread_name ((char *) w->name);
538  }
539 
540  vgm->elog_main.lock =
542  vgm->elog_main.lock[0] = 0;
543 
546 
547  vec_validate_aligned (vgm->vlib_mains, n_vlib_mains - 1,
549  _vec_len (vgm->vlib_mains) = 0;
551 
552  if (n_vlib_mains > 1)
553  {
558 
561 
562  /* We'll need the rpc vector lock... */
564 
565  /* Ask for an initial barrier sync */
568 
569  /* Without update or refork */
572 
573  /* init timing */
574  vm->barrier_epoch = 0;
576 
577  worker_thread_index = 1;
579 
580  for (i = 0; i < vec_len (tm->registrations); i++)
581  {
582  vlib_node_main_t *nm, *nm_clone;
583  int k;
584 
585  tr = tm->registrations[i];
586 
587  if (tr->count == 0)
588  continue;
589 
590  for (k = 0; k < tr->count; k++)
591  {
592  vlib_node_t *n;
593 
595  /* Currently unused, may not really work */
596  if (tr->mheap_size)
598  /* unlocked */ 0,
599  "%s%d heap",
600  tr->name, k);
601  else
602  w->thread_mheap = main_heap;
603 
604  w->thread_stack =
606  w->thread_function = tr->function;
607  w->thread_function_arg = w;
608  w->instance_id = k;
609  w->registration = tr;
610 
611  w->elog_track.name =
612  (char *) format (0, "%s %d", tr->name, k + 1);
613  vec_add1 (w->elog_track.name, 0);
615 
616  if (tr->no_data_structure_clone)
617  continue;
618 
619  /* Fork vlib_global_main et al. Look for bugs here */
620  oldheap = clib_mem_set_heap (w->thread_mheap);
621 
622  vm_clone = clib_mem_alloc_aligned (sizeof (*vm_clone),
624  clib_memcpy (vm_clone, vlib_get_first_main (),
625  sizeof (*vm_clone));
626 
627  vm_clone->thread_index = worker_thread_index;
628  vm_clone->heap_base = w->thread_mheap;
629  vm_clone->heap_aligned_base = (void *)
630  (((uword) w->thread_mheap) & ~(VLIB_FRAME_ALIGN - 1));
631  vm_clone->pending_rpc_requests = 0;
632  vec_validate (vm_clone->pending_rpc_requests, 0);
633  _vec_len (vm_clone->pending_rpc_requests) = 0;
634  clib_memset (&vm_clone->random_buffer, 0,
635  sizeof (vm_clone->random_buffer));
641 
643  nm_clone = &vm_clone->node_main;
644  /* fork next frames array, preserving node runtime indices */
645  nm_clone->next_frames = vec_dup_aligned (nm->next_frames,
647  for (j = 0; j < vec_len (nm_clone->next_frames); j++)
648  {
649  vlib_next_frame_t *nf = &nm_clone->next_frames[j];
650  u32 save_node_runtime_index;
651  u32 save_flags;
652 
653  save_node_runtime_index = nf->node_runtime_index;
654  save_flags = nf->flags & VLIB_FRAME_NO_FREE_AFTER_DISPATCH;
656  nf->node_runtime_index = save_node_runtime_index;
657  nf->flags = save_flags;
658  }
659 
660  /* fork the frame dispatch queue */
661  nm_clone->pending_frames = 0;
662  vec_validate (nm_clone->pending_frames, 10);
663  _vec_len (nm_clone->pending_frames) = 0;
664 
665  /* fork nodes */
666  nm_clone->nodes = 0;
667 
668  /* Allocate all nodes in single block for speed */
669  n = clib_mem_alloc_no_fail (vec_len (nm->nodes) * sizeof (*n));
670 
671  for (j = 0; j < vec_len (nm->nodes); j++)
672  {
673  clib_memcpy (n, nm->nodes[j], sizeof (*n));
674  /* none of the copied nodes have enqueue rights given out */
676  clib_memset (&n->stats_total, 0, sizeof (n->stats_total));
678  sizeof (n->stats_last_clear));
679  vec_add1 (nm_clone->nodes, n);
680  n++;
681  }
683  vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_INTERNAL],
685  vec_foreach (rt,
687  {
688  vlib_node_t *n = vlib_get_node (vm, rt->node_index);
689  rt->thread_index = vm_clone->thread_index;
690  /* copy initial runtime_data from node */
691  if (n->runtime_data && n->runtime_data_bytes > 0)
692  clib_memcpy (rt->runtime_data, n->runtime_data,
694  n->runtime_data_bytes));
695  }
696 
698  vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_INPUT],
701  &nm_clone->interrupts,
704  {
705  vlib_node_t *n = vlib_get_node (vm, rt->node_index);
706  rt->thread_index = vm_clone->thread_index;
707  /* copy initial runtime_data from node */
708  if (n->runtime_data && n->runtime_data_bytes > 0)
709  clib_memcpy (rt->runtime_data, n->runtime_data,
711  n->runtime_data_bytes));
712  }
713 
717  vec_foreach (rt,
719  {
720  vlib_node_t *n = vlib_get_node (vm, rt->node_index);
721  rt->thread_index = vm_clone->thread_index;
722  /* copy initial runtime_data from node */
723  if (n->runtime_data && n->runtime_data_bytes > 0)
724  clib_memcpy (rt->runtime_data, n->runtime_data,
726  n->runtime_data_bytes));
727  }
728 
729  nm_clone->processes = vec_dup_aligned (nm->processes,
731 
732  /* Create per-thread frame freelist */
733  nm_clone->frame_sizes = vec_new (vlib_frame_size_t, 1);
734 #ifdef VLIB_SUPPORTS_ARBITRARY_SCALAR_SIZES
735  nm_clone->frame_size_hash = hash_create (0, sizeof (uword));
736 #endif
737  nm_clone->node_by_error = nm->node_by_error;
738 
739  /* Packet trace buffers are guaranteed to be empty, nothing to do here */
740 
741  clib_mem_set_heap (oldheap);
742  vec_add1_aligned (vgm->vlib_mains, vm_clone,
744 
745  /* Switch to the stats segment ... */
746  void *oldheap = vlib_stats_push_heap (0);
747  vm_clone->error_main.counters =
748  vec_dup_aligned (vlib_get_first_main ()->error_main.counters,
751  worker_thread_index, oldheap, 1);
752 
754  vlib_get_first_main ()->error_main.counters_last_clear,
756 
757  worker_thread_index++;
758  }
759  }
760  }
761  else
762  {
763  /* only have non-data-structure copy threads to create... */
764  for (i = 0; i < vec_len (tm->registrations); i++)
765  {
766  tr = tm->registrations[i];
767 
768  for (j = 0; j < tr->count; j++)
769  {
771  if (tr->mheap_size)
772  {
774  /* locked */ 0,
775  "%s%d heap",
776  tr->name, j);
777  }
778  else
779  w->thread_mheap = main_heap;
780  w->thread_stack =
782  w->thread_function = tr->function;
783  w->thread_function_arg = w;
784  w->instance_id = j;
785  w->elog_track.name =
786  (char *) format (0, "%s %d", tr->name, j + 1);
787  w->registration = tr;
788  vec_add1 (w->elog_track.name, 0);
790  }
791  }
792  }
793 
794  worker_thread_index = 1;
795 
796  for (i = 0; i < vec_len (tm->registrations); i++)
797  {
798  clib_error_t *err;
799  int j;
800 
801  tr = tm->registrations[i];
802 
803  if (tr->use_pthreads || tm->use_pthreads)
804  {
805  for (j = 0; j < tr->count; j++)
806  {
807  w = vlib_worker_threads + worker_thread_index++;
809  w, 0);
810  if (err)
811  clib_error_report (err);
812  }
813  }
814  else
815  {
816  uword c;
817  /* *INDENT-OFF* */
819  w = vlib_worker_threads + worker_thread_index++;
821  w, c);
822  if (err)
823  clib_error_report (err);
824  }
825  /* *INDENT-ON* */
826  }
827  }
830  return 0;
831 }
832 
834 
835 
836 static inline void
838 {
839  int i, j;
840  vlib_main_t *vm;
841  vlib_node_main_t *nm, *nm_clone;
842  vlib_main_t *vm_clone;
844 
845  ASSERT (vlib_get_thread_index () == 0);
846 
847  vm = vlib_get_first_main ();
848  nm = &vm->node_main;
849 
851 
852  /*
853  * Scrape all runtime stats, so we don't lose node runtime(s) with
854  * pending counts, or throw away worker / io thread counts.
855  */
856  for (j = 0; j < vec_len (nm->nodes); j++)
857  {
858  vlib_node_t *n;
859  n = nm->nodes[j];
861  }
862 
863  for (i = 1; i < vlib_get_n_threads (); i++)
864  {
865  vlib_node_t *n;
866 
867  vm_clone = vlib_get_main_by_index (i);
868  nm_clone = &vm_clone->node_main;
869 
870  for (j = 0; j < vec_len (nm_clone->nodes); j++)
871  {
872  n = nm_clone->nodes[j];
873 
874  rt = vlib_node_get_runtime (vm_clone, n->index);
875  vlib_node_runtime_sync_stats (vm_clone, rt, 0, 0, 0);
876  }
877  }
878 
879  /* Per-worker clone rebuilds are now done on each thread */
880 }
881 
882 
883 void
885 {
886  vlib_main_t *vm, *vm_clone;
887  vlib_node_main_t *nm, *nm_clone;
888  vlib_node_t **old_nodes_clone;
889  vlib_node_runtime_t *rt, *old_rt;
890 
891  vlib_node_t *new_n_clone;
892 
893  int j;
894 
895  vm = vlib_get_first_main ();
896  nm = &vm->node_main;
897  vm_clone = vlib_get_main ();
898  nm_clone = &vm_clone->node_main;
899 
900  /* Re-clone error heap */
901  u64 *old_counters = vm_clone->error_main.counters;
902  u64 *old_counters_all_clear = vm_clone->error_main.counters_last_clear;
903 
904  clib_memcpy_fast (&vm_clone->error_main, &vm->error_main,
905  sizeof (vm->error_main));
906  j = vec_len (vm->error_main.counters) - 1;
907 
908  /* Switch to the stats segment ... */
909  void *oldheap = vlib_stats_push_heap (0);
910  vec_validate_aligned (old_counters, j, CLIB_CACHE_LINE_BYTES);
911  vm_clone->error_main.counters = old_counters;
913  oldheap, 0);
914 
915  vec_validate_aligned (old_counters_all_clear, j, CLIB_CACHE_LINE_BYTES);
916  vm_clone->error_main.counters_last_clear = old_counters_all_clear;
917 
918  nm_clone = &vm_clone->node_main;
919  vec_free (nm_clone->next_frames);
920  nm_clone->next_frames = vec_dup_aligned (nm->next_frames,
922 
923  for (j = 0; j < vec_len (nm_clone->next_frames); j++)
924  {
925  vlib_next_frame_t *nf = &nm_clone->next_frames[j];
926  u32 save_node_runtime_index;
927  u32 save_flags;
928 
929  save_node_runtime_index = nf->node_runtime_index;
930  save_flags = nf->flags & VLIB_FRAME_NO_FREE_AFTER_DISPATCH;
932  nf->node_runtime_index = save_node_runtime_index;
933  nf->flags = save_flags;
934  }
935 
936  old_nodes_clone = nm_clone->nodes;
937  nm_clone->nodes = 0;
938 
939  /* re-fork nodes */
940 
941  /* Allocate all nodes in single block for speed */
942  new_n_clone =
943  clib_mem_alloc_no_fail (vec_len (nm->nodes) * sizeof (*new_n_clone));
944  for (j = 0; j < vec_len (nm->nodes); j++)
945  {
946  vlib_node_t *new_n = nm->nodes[j];
947 
948  clib_memcpy_fast (new_n_clone, new_n, sizeof (*new_n));
949  /* none of the copied nodes have enqueue rights given out */
951 
952  if (j >= vec_len (old_nodes_clone))
953  {
954  /* new node, set to zero */
955  clib_memset (&new_n_clone->stats_total, 0,
956  sizeof (new_n_clone->stats_total));
957  clib_memset (&new_n_clone->stats_last_clear, 0,
958  sizeof (new_n_clone->stats_last_clear));
959  }
960  else
961  {
962  vlib_node_t *old_n_clone = old_nodes_clone[j];
963  /* Copy stats if the old data is valid */
964  clib_memcpy_fast (&new_n_clone->stats_total,
965  &old_n_clone->stats_total,
966  sizeof (new_n_clone->stats_total));
967  clib_memcpy_fast (&new_n_clone->stats_last_clear,
968  &old_n_clone->stats_last_clear,
969  sizeof (new_n_clone->stats_last_clear));
970 
971  /* keep previous node state */
972  new_n_clone->state = old_n_clone->state;
973  new_n_clone->flags = old_n_clone->flags;
974  }
975  vec_add1 (nm_clone->nodes, new_n_clone);
976  new_n_clone++;
977  }
978  /* Free the old node clones */
979  clib_mem_free (old_nodes_clone[0]);
980 
981  vec_free (old_nodes_clone);
982 
983 
984  /* re-clone internal nodes */
985  old_rt = nm_clone->nodes_by_type[VLIB_NODE_TYPE_INTERNAL];
987  vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_INTERNAL],
989 
991  {
992  vlib_node_t *n = vlib_get_node (vm, rt->node_index);
993  rt->thread_index = vm_clone->thread_index;
994  /* copy runtime_data, will be overwritten later for existing rt */
995  if (n->runtime_data && n->runtime_data_bytes > 0)
996  clib_memcpy_fast (rt->runtime_data, n->runtime_data,
998  n->runtime_data_bytes));
999  }
1000 
1001  for (j = 0; j < vec_len (old_rt); j++)
1002  {
1003  rt = vlib_node_get_runtime (vm_clone, old_rt[j].node_index);
1004  rt->state = old_rt[j].state;
1005  rt->flags = old_rt[j].flags;
1006  clib_memcpy_fast (rt->runtime_data, old_rt[j].runtime_data,
1008  }
1009 
1010  vec_free (old_rt);
1011 
1012  /* re-clone input nodes */
1013  old_rt = nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT];
1014  nm_clone->nodes_by_type[VLIB_NODE_TYPE_INPUT] =
1015  vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_INPUT],
1018  &nm_clone->interrupts,
1020 
1022  {
1023  vlib_node_t *n = vlib_get_node (vm, rt->node_index);
1024  rt->thread_index = vm_clone->thread_index;
1025  /* copy runtime_data, will be overwritten later for existing rt */
1026  if (n->runtime_data && n->runtime_data_bytes > 0)
1027  clib_memcpy_fast (rt->runtime_data, n->runtime_data,
1029  n->runtime_data_bytes));
1030  }
1031 
1032  for (j = 0; j < vec_len (old_rt); j++)
1033  {
1034  rt = vlib_node_get_runtime (vm_clone, old_rt[j].node_index);
1035  rt->state = old_rt[j].state;
1036  rt->flags = old_rt[j].flags;
1037  clib_memcpy_fast (rt->runtime_data, old_rt[j].runtime_data,
1039  }
1040 
1041  vec_free (old_rt);
1042 
1043  /* re-clone pre-input nodes */
1044  old_rt = nm_clone->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT];
1046  vec_dup_aligned (nm->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT],
1048 
1050  {
1051  vlib_node_t *n = vlib_get_node (vm, rt->node_index);
1052  rt->thread_index = vm_clone->thread_index;
1053  /* copy runtime_data, will be overwritten later for existing rt */
1054  if (n->runtime_data && n->runtime_data_bytes > 0)
1055  clib_memcpy_fast (rt->runtime_data, n->runtime_data,
1057  n->runtime_data_bytes));
1058  }
1059 
1060  for (j = 0; j < vec_len (old_rt); j++)
1061  {
1062  rt = vlib_node_get_runtime (vm_clone, old_rt[j].node_index);
1063  rt->state = old_rt[j].state;
1064  rt->flags = old_rt[j].flags;
1065  clib_memcpy_fast (rt->runtime_data, old_rt[j].runtime_data,
1067  }
1068 
1069  vec_free (old_rt);
1070 
1071  nm_clone->processes = vec_dup_aligned (nm->processes,
1073  nm_clone->node_by_error = nm->node_by_error;
1074 }
1075 
1076 void
1078 {
1079  /*
1080  * Make a note that we need to do a node runtime update
1081  * prior to releasing the barrier.
1082  */
1084 }
1085 
1086 u32
1087 unformat_sched_policy (unformat_input_t * input, va_list * args)
1088 {
1089  u32 *r = va_arg (*args, u32 *);
1090 
1091  if (0);
1092 #define _(v,f,s) else if (unformat (input, s)) *r = SCHED_POLICY_##f;
1094 #undef _
1095  else
1096  return 0;
1097  return 1;
1098 }
1099 
1100 static clib_error_t *
1102 {
1104  uword *p;
1106  u8 *name;
1107  uword *bitmap;
1108  u32 count;
1109 
1111 
1112  tm->n_thread_stacks = 1; /* account for main thread */
1113  tm->sched_policy = ~0;
1114  tm->sched_priority = ~0;
1115  tm->main_lcore = ~0;
1116 
1117  tr = tm->next;
1118 
1119  while (tr)
1120  {
1122  tr = tr->next;
1123  }
1124 
1125  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1126  {
1127  if (unformat (input, "use-pthreads"))
1128  tm->use_pthreads = 1;
1129  else if (unformat (input, "thread-prefix %v", &tm->thread_prefix))
1130  ;
1131  else if (unformat (input, "main-core %u", &tm->main_lcore))
1132  ;
1133  else if (unformat (input, "skip-cores %u", &tm->skip_cores))
1134  ;
1135  else if (unformat (input, "numa-heap-size %U",
1137  ;
1138  else if (unformat (input, "coremask-%s %U", &name,
1139  unformat_bitmap_mask, &bitmap) ||
1140  unformat (input, "corelist-%s %U", &name,
1141  unformat_bitmap_list, &bitmap))
1142  {
1144  if (p == 0)
1145  return clib_error_return (0, "no such thread type '%s'", name);
1146 
1147  tr = (vlib_thread_registration_t *) p[0];
1148 
1149  if (tr->use_pthreads)
1150  return clib_error_return (0,
1151  "corelist cannot be set for '%s' threads",
1152  name);
1153  if (tr->count)
1154  return clib_error_return
1155  (0, "core placement of '%s' threads is already configured",
1156  name);
1157 
1158  tr->coremask = bitmap;
1160  }
1161  else
1162  if (unformat
1163  (input, "scheduler-policy %U", unformat_sched_policy,
1164  &tm->sched_policy))
1165  ;
1166  else if (unformat (input, "scheduler-priority %u", &tm->sched_priority))
1167  ;
1168  else if (unformat (input, "%s %u", &name, &count))
1169  {
1171  if (p == 0)
1172  return clib_error_return (0, "no such thread type 3 '%s'", name);
1173 
1174  tr = (vlib_thread_registration_t *) p[0];
1175 
1176  if (tr->fixed_count)
1177  return clib_error_return
1178  (0, "number of '%s' threads not configurable", name);
1179  if (tr->count)
1180  return clib_error_return
1181  (0, "number of '%s' threads is already configured", name);
1182 
1183  tr->count = count;
1184  }
1185  else
1186  break;
1187  }
1188 
1189  if (tm->sched_priority != ~0)
1190  {
1191  if (tm->sched_policy == SCHED_FIFO || tm->sched_policy == SCHED_RR)
1192  {
1193  u32 prio_max = sched_get_priority_max (tm->sched_policy);
1194  u32 prio_min = sched_get_priority_min (tm->sched_policy);
1195  if (tm->sched_priority > prio_max)
1196  tm->sched_priority = prio_max;
1197  if (tm->sched_priority < prio_min)
1198  tm->sched_priority = prio_min;
1199  }
1200  else
1201  {
1202  return clib_error_return
1203  (0,
1204  "scheduling priority (%d) is not allowed for `normal` scheduling policy",
1205  tm->sched_priority);
1206  }
1207  }
1208  tr = tm->next;
1209 
1210  if (!tm->thread_prefix)
1211  tm->thread_prefix = format (0, "vpp");
1212 
1213  while (tr)
1214  {
1215  tm->n_thread_stacks += tr->count;
1216  tm->n_pthreads += tr->count * tr->use_pthreads;
1217  tm->n_threads += tr->count * (tr->use_pthreads == 0);
1218  tr = tr->next;
1219  }
1220 
1221  return 0;
1222 }
1223 
1225 
1226  /*
1227  * Enforce minimum open time to minimize packet loss due to Rx overflow,
1228  * based on a test based heuristic that barrier should be open for at least
1229  * 3 time as long as it is closed (with an upper bound of 1ms because by that
1230  * point it is probably too late to make a difference)
1231  */
1232 
1233 #ifndef BARRIER_MINIMUM_OPEN_LIMIT
1234 #define BARRIER_MINIMUM_OPEN_LIMIT 0.001
1235 #endif
1236 
1237 #ifndef BARRIER_MINIMUM_OPEN_FACTOR
1238 #define BARRIER_MINIMUM_OPEN_FACTOR 3
1239 #endif
1240 
1241 void
1243 {
1244  f64 deadline;
1245  f64 now = vlib_time_now (vm);
1246  u32 count = vlib_get_n_threads () - 1;
1247 
1248  /* No worker threads? */
1249  if (count == 0)
1250  return;
1251 
1252  deadline = now + BARRIER_SYNC_TIMEOUT;
1255  {
1256  if ((now = vlib_time_now (vm)) > deadline)
1257  {
1258  fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__);
1259  os_panic ();
1260  }
1261  CLIB_PAUSE ();
1262  }
1264 }
1265 
1266 /**
1267  * Return true if the wroker thread barrier is held
1268  */
1269 u8
1271 {
1272  if (vlib_get_n_threads () < 2)
1273  return (1);
1274 
1275  return (*vlib_worker_threads->wait_at_barrier == 1);
1276 }
1277 
1278 void
1280 {
1281  f64 deadline;
1282  f64 now;
1283  f64 t_entry;
1284  f64 t_open;
1285  f64 t_closed;
1286  f64 max_vector_rate;
1287  u32 count;
1288  int i;
1289 
1290  if (vlib_get_n_threads () < 2)
1291  return;
1292 
1293  ASSERT (vlib_get_thread_index () == 0);
1294 
1295  vlib_worker_threads[0].barrier_caller = func_name;
1296  count = vlib_get_n_threads () - 1;
1297 
1298  /* Record entry relative to last close */
1299  now = vlib_time_now (vm);
1300  t_entry = now - vm->barrier_epoch;
1301 
1302  /* Tolerate recursive calls */
1303  if (++vlib_worker_threads[0].recursion_level > 1)
1304  {
1305  barrier_trace_sync_rec (t_entry);
1306  return;
1307  }
1308 
1311  vm->clib_time.last_cpu_time, 0 /* enter */ );
1312 
1313  /*
1314  * Need data to decide if we're working hard enough to honor
1315  * the barrier hold-down timer.
1316  */
1317  max_vector_rate = 0.0;
1318  for (i = 1; i < vlib_get_n_threads (); i++)
1319  {
1321  max_vector_rate = clib_max (max_vector_rate,
1323  }
1324 
1326 
1327  /* Enforce minimum barrier open time to minimize packet loss */
1329 
1330  /*
1331  * If any worker thread seems busy, which we define
1332  * as a vector rate above 10, we enforce the barrier hold-down timer
1333  */
1334  if (max_vector_rate > 10.0)
1335  {
1336  while (1)
1337  {
1338  now = vlib_time_now (vm);
1339  /* Barrier hold-down timer expired? */
1340  if (now >= vm->barrier_no_close_before)
1341  break;
1342  if ((vm->barrier_no_close_before - now)
1343  > (2.0 * BARRIER_MINIMUM_OPEN_LIMIT))
1344  {
1345  clib_warning
1346  ("clock change: would have waited for %.4f seconds",
1348  break;
1349  }
1350  }
1351  }
1352  /* Record time of closure */
1353  t_open = now - vm->barrier_epoch;
1354  vm->barrier_epoch = now;
1355 
1356  deadline = now + BARRIER_SYNC_TIMEOUT;
1357 
1360  {
1361  if ((now = vlib_time_now (vm)) > deadline)
1362  {
1363  fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__);
1364  os_panic ();
1365  }
1366  }
1367 
1368  t_closed = now - vm->barrier_epoch;
1369 
1370  barrier_trace_sync (t_entry, t_open, t_closed);
1371 
1372 }
1373 
1374 void
1376 {
1378  f64 deadline;
1379  f64 now;
1380  f64 minimum_open;
1381  f64 t_entry;
1382  f64 t_closed_total;
1383  f64 t_update_main = 0.0;
1384  int refork_needed = 0;
1385 
1386  if (vlib_get_n_threads () < 2)
1387  return;
1388 
1389  ASSERT (vlib_get_thread_index () == 0);
1390 
1391 
1392  now = vlib_time_now (vm);
1393  t_entry = now - vm->barrier_epoch;
1394 
1395  if (--vlib_worker_threads[0].recursion_level > 0)
1396  {
1397  barrier_trace_release_rec (t_entry);
1398  return;
1399  }
1400 
1401  /* Update (all) node runtimes before releasing the barrier, if needed */
1403  {
1404  /*
1405  * Lock stat segment here, so we's safe when
1406  * rebuilding the stat segment node clones from the
1407  * stat thread...
1408  */
1410 
1411  /* Do stats elements on main thread */
1414 
1415  /* Do per thread rebuilds in parallel */
1416  refork_needed = 1;
1418  (vlib_get_n_threads () - 1));
1419  now = vlib_time_now (vm);
1420  t_update_main = now - vm->barrier_epoch;
1421  }
1422 
1423  deadline = now + BARRIER_SYNC_TIMEOUT;
1424 
1425  /*
1426  * Note when we let go of the barrier.
1427  * Workers can use this to derive a reasonably accurate
1428  * time offset. See vlib_time_now(...)
1429  */
1432 
1434 
1436  {
1437  if ((now = vlib_time_now (vm)) > deadline)
1438  {
1439  fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__);
1440  os_panic ();
1441  }
1442  }
1443 
1444  /* Wait for reforks before continuing */
1445  if (refork_needed)
1446  {
1447  now = vlib_time_now (vm);
1448 
1449  deadline = now + BARRIER_SYNC_TIMEOUT;
1450 
1452  {
1453  if ((now = vlib_time_now (vm)) > deadline)
1454  {
1455  fformat (stderr, "%s: worker thread refork deadlock\n",
1456  __FUNCTION__);
1457  os_panic ();
1458  }
1459  }
1461  }
1462 
1463  t_closed_total = now - vm->barrier_epoch;
1464 
1465  minimum_open = t_closed_total * BARRIER_MINIMUM_OPEN_FACTOR;
1466 
1467  if (minimum_open > BARRIER_MINIMUM_OPEN_LIMIT)
1468  {
1469  minimum_open = BARRIER_MINIMUM_OPEN_LIMIT;
1470  }
1471 
1472  vm->barrier_no_close_before = now + minimum_open;
1473 
1474  /* Record barrier epoch (used to enforce minimum open time) */
1475  vm->barrier_epoch = now;
1476 
1477  barrier_trace_release (t_entry, t_closed_total, t_update_main);
1478 
1481  vm->clib_time.last_cpu_time, 1 /* leave */ );
1482 }
1483 
1484 /**
1485  * Wait until each of the workers has been once around the track
1486  */
1487 void
1489 {
1491  ASSERT (vlib_get_thread_index () == 0);
1492 
1493  if (vlib_get_n_threads () < 2)
1494  return;
1495 
1497  return;
1498 
1499  u32 *counts = 0;
1500  u32 ii;
1501 
1502  vec_validate (counts, vlib_get_n_threads () - 1);
1503 
1504  /* record the current loop counts */
1505  vec_foreach_index (ii, vgm->vlib_mains)
1506  counts[ii] = vgm->vlib_mains[ii]->main_loop_count;
1507 
1508  /* spin until each changes, apart from the main thread, or we'd be
1509  * a while */
1510  for (ii = 1; ii < vec_len (counts); ii++)
1511  {
1512  while (counts[ii] == vgm->vlib_mains[ii]->main_loop_count)
1513  CLIB_PAUSE ();
1514  }
1515 
1516  vec_free (counts);
1517  return;
1518 }
1519 
1520 void
1522 {
1527  clib_error_t *e;
1528 
1530 
1532 
1536 
1538 
1540  vm, &vgm->worker_init_function_registrations, 1 /* call_once */,
1541  0 /* is_global */);
1542  if (e)
1543  clib_error_report (e);
1544 
1545  /* Wait until the dpdk init sequence is complete */
1546  while (tm->extern_thread_mgmt && tm->worker_thread_release == 0)
1548 
1549  vlib_worker_loop (vm);
1550 }
1551 
1552 /* *INDENT-OFF* */
1553 VLIB_REGISTER_THREAD (worker_thread_reg, static) = {
1554  .name = "workers",
1555  .short_name = "wk",
1556  .function = vlib_worker_thread_fn,
1557 };
1558 /* *INDENT-ON* */
1559 
1560 u32
1562 {
1565  vlib_frame_queue_t *fq;
1566  int i;
1567  u32 num_threads;
1568 
1569  if (frame_queue_nelts == 0)
1570  frame_queue_nelts = FRAME_QUEUE_MAX_NELTS;
1571 
1572  num_threads = 1 /* main thread */ + tm->n_threads;
1573  ASSERT (frame_queue_nelts >= 8 + num_threads);
1574 
1575  vec_add2 (tm->frame_queue_mains, fqm, 1);
1576 
1577  fqm->node_index = node_index;
1578  fqm->frame_queue_nelts = frame_queue_nelts;
1579 
1581  _vec_len (fqm->vlib_frame_queues) = 0;
1582  for (i = 0; i < tm->n_vlib_mains; i++)
1583  {
1584  fq = vlib_frame_queue_alloc (frame_queue_nelts);
1585  vec_add1 (fqm->vlib_frame_queues, fq);
1586  }
1587 
1588  return (fqm - tm->frame_queue_mains);
1589 }
1590 
1591 int
1593 {
1595 
1596  if (tm->extern_thread_mgmt)
1597  return -1;
1598 
1600  tm->extern_thread_mgmt = 1;
1601  return 0;
1602 }
1603 
1604 void
1606  args)
1607 {
1608  ASSERT (vlib_get_thread_index () == 0);
1610  args->type_opaque, args->data);
1611 }
1612 
1614 
1615 void
1616 vlib_rpc_call_main_thread (void *callback, u8 * args, u32 arg_size)
1617 {
1619  {
1620  void (*fp) (void *, u8 *, u32) = rpc_call_main_thread_cb_fn;
1621  (*fp) (callback, args, arg_size);
1622  }
1623  else
1624  clib_warning ("BUG: rpc_call_main_thread_cb_fn NULL!");
1625 }
1626 
1627 clib_error_t *
1629 {
1630  return 0;
1631 }
1632 
1634 
1635 
1636 static clib_error_t *
1638  unformat_input_t * input, vlib_cli_command_t * cmd)
1639 {
1640  int i;
1641  int verbose = 0;
1642  clib_timebase_t _tb, *tb = &_tb;
1643 
1644  (void) unformat (input, "verbose %=", &verbose, 1);
1645 
1647  &vm->clib_time);
1648 
1649  vlib_cli_output (vm, "%U, %U GMT", format_clib_time, &vm->clib_time,
1650  verbose, format_clib_timebase_time,
1651  clib_timebase_now (tb));
1652 
1653  if (vlib_get_n_threads () == 1)
1654  return 0;
1655 
1656  vlib_cli_output (vm, "Time last barrier release %.9f",
1658 
1659  for (i = 1; i < vlib_get_n_threads (); i++)
1660  {
1662  if (ovm == 0)
1663  continue;
1664 
1665  vlib_cli_output (vm, "%d: %U", i, format_clib_time, &ovm->clib_time,
1666  verbose);
1667 
1668  vlib_cli_output (
1669  vm, "Thread %d offset %.9f error %.9f", i, ovm->time_offset,
1671  }
1672  return 0;
1673 }
1674 
1675 /* *INDENT-OFF* */
1677 {
1678  .path = "show clock",
1679  .short_help = "show clock",
1680  .function = show_clock_command_fn,
1681 };
1682 /* *INDENT-ON* */
1683 
1686 {
1687  return vlib_get_thread_main ();
1688 }
1689 
1690 /*
1691  * fd.io coding-style-patch-verification: ON
1692  *
1693  * Local Variables:
1694  * eval: (c-set-style "gnu")
1695  * End:
1696  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
vlib.h
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
vlib_node_sync_stats
void vlib_node_sync_stats(vlib_main_t *vm, vlib_node_t *n)
Definition: main.c:610
clib_calljmp
uword clib_calljmp(uword(*func)(uword func_arg), uword func_arg, void *stack)
vlib_worker_thread_t::barrier_caller
const char * barrier_caller
Definition: threads.h:101
vlib_thread_main_t::next
vlib_thread_registration_t * next
Definition: threads.h:246
vlib_process_signal_event_mt_helper
void vlib_process_signal_event_mt_helper(vlib_process_signal_event_mt_args_t *args)
Definition: threads.c:1605
vlib_stats_push_heap
void * vlib_stats_push_heap(void *old)
Definition: stat_segment.c:50
vlib_node_runtime_t::flags
u16 flags
Copy of main node flags.
Definition: node.h:491
vlib_worker_thread_barrier_release
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1375
vlib_main_t::random_buffer
clib_random_buffer_t random_buffer
Definition: main.h:212
vlib_main_t::barrier_no_close_before
f64 barrier_no_close_before
Definition: main.h:250
vlib_global_main_t
Definition: main.h:276
clib_mem_set_default_numa_affinity
__clib_export int clib_mem_set_default_numa_affinity()
Definition: mem.c:644
vlib_worker_thread_fn
void vlib_worker_thread_fn(void *arg)
Definition: threads.c:1521
vlib_main_t::main_loop_count
volatile u32 main_loop_count
Definition: main.h:118
os_panic
void os_panic(void)
Definition: pnat_test_stubs.h:19
VLIB_FRAME_NO_FREE_AFTER_DISPATCH
#define VLIB_FRAME_NO_FREE_AFTER_DISPATCH
Definition: node.h:405
vlib_thread_main_t::cpu_core_bitmap
uword * cpu_core_bitmap
Definition: threads.h:283
vlib_main_t::time_offset
f64 time_offset
Definition: main.h:108
clib_mem_get_heap
static clib_mem_heap_t * clib_mem_get_heap(void)
Definition: mem.h:362
vlib_main_t::clib_time
clib_time_t clib_time
Definition: main.h:106
stat_weak_inlines.h
vec_new
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:365
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
CLIB_TIMEBASE_DAYLIGHT_NONE
@ CLIB_TIMEBASE_DAYLIGHT_NONE
Definition: time_range.h:24
elog_track_t::name
char * name
Track name vector.
Definition: elog.h:116
vlib_node_main_t::processes
vlib_process_t ** processes
Definition: node.h:709
VLIB_NODE_TYPE_PRE_INPUT
@ VLIB_NODE_TYPE_PRE_INPUT
Definition: node.h:81
clib_max
#define clib_max(x, y)
Definition: clib.h:335
vlib_process_finish_switch_stack
static_always_inline void vlib_process_finish_switch_stack(vlib_main_t *vm)
Definition: node_funcs.h:67
vlib_frame_queue_t::vector_threshold
u64 vector_threshold
Definition: threads.h:119
VLIB_INVALID_NODE_INDEX
#define VLIB_INVALID_NODE_INDEX
Definition: node.h:365
name
string name[64]
Definition: fib.api:25
sort_registrations_by_no_clone
static int sort_registrations_by_no_clone(void *a0, void *a1)
Definition: threads.c:160
vlib_worker_thread_barrier_check
static void vlib_worker_thread_barrier_check(void)
Definition: threads.h:357
vlib_frame_size_t
Definition: node.h:518
clib_bitmap_t
uword clib_bitmap_t
Definition: bitmap.h:50
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
vlib_main_t::pending_rpc_lock
clib_spinlock_t pending_rpc_lock
Definition: main.h:264
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:314
vlib_worker_thread_t::node_reforks_required
volatile u32 * node_reforks_required
Definition: threads.h:103
vlib_thread_callbacks_t
Definition: threads.h:236
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
vlib_thread_main_t::n_pthreads
u32 n_pthreads
Definition: threads.h:268
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
clib_bitmap_first_set
static uword clib_bitmap_first_set(uword *ai)
Return the lowest numbered set bit in a bitmap.
Definition: bitmap.h:372
threads.h
vlib_main_t::heap_aligned_base
void * heap_aligned_base
Definition: main.h:161
vlib_thread_main_t::cb
vlib_thread_callbacks_t cb
Definition: threads.h:301
hash_create_string
#define hash_create_string(elts, value_bytes)
Definition: hash.h:689
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
thread
pthread_t thread[MAX_CONNS]
Definition: main.c:142
VLIB_NODE_TYPE_INPUT
@ VLIB_NODE_TYPE_INPUT
Definition: node.h:76
vlib_node_t::flags
u16 flags
Definition: node.h:278
vlib_worker_thread_barrier_sync_int
void vlib_worker_thread_barrier_sync_int(vlib_main_t *vm, const char *func_name)
Definition: threads.c:1279
vlib_stats_pop_heap2
void vlib_stats_pop_heap2(u64 *error_vector, u32 thread_index, void *oldheap, int lock)
Definition: stat_segment.c:363
vlib_main_t::error_main
vlib_error_main_t error_main
Definition: main.h:179
vlib_main_t::node_main
vlib_node_main_t node_main
Definition: main.h:173
hash_set_mem
#define hash_set_mem(h, key, value)
Definition: hash.h:275
vlib_worker_wait_one_loop
void vlib_worker_wait_one_loop(void)
Wait until each of the workers has been once around the track.
Definition: threads.c:1488
vlib_main_t::barrier_perf_callbacks
void(**volatile barrier_perf_callbacks)(struct vlib_main_t *, u64 t, int leave)
Definition: main.h:254
vlib_node_main_t::node_by_error
u32 * node_by_error
Definition: node.h:733
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
VLIB_REGISTER_THREAD
VLIB_REGISTER_THREAD(worker_thread_reg, static)
vlib_node_t::state
u8 state
Definition: node.h:299
node_index
node node_index
Definition: interface_output.c:440
vlib_frame_queue_main_t::frame_queue_nelts
u32 frame_queue_nelts
Definition: threads.h:136
vl_msg_api_handler_no_free
void vl_msg_api_handler_no_free(void *)
Definition: threads.c:363
elog_string
__clib_export u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table
Definition: elog.c:582
vlib_thread_registration_::next
struct vlib_thread_registration_ * next
Definition: threads.h:30
vlib_thread_main_t::main_lcore
u32 main_lcore
Definition: threads.h:280
vlib_thread_main_t::cpu_socket_bitmap
uword * cpu_socket_bitmap
Definition: threads.h:286
vlib_worker_thread_t::thread_function
void(* thread_function)(void *)
Definition: threads.h:92
vlib_worker_loop
void vlib_worker_loop(vlib_main_t *vm)
Definition: main.c:1781
VLIB_NODE_RUNTIME_DATA_SIZE
#define VLIB_NODE_RUNTIME_DATA_SIZE
Definition: node.h:516
clib_error_report
#define clib_error_report(e)
Definition: error.h:113
unformat_input_t
struct _unformat_input_t unformat_input_t
r
vnet_hw_if_output_node_runtime_t * r
Definition: interface_output.c:1089
vlib_worker_threads
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.c:35
vlib_thread_registration_::count
u32 count
Definition: threads.h:38
vlib_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
vlib_thread_stack_init
u8 * vlib_thread_stack_init(uword thread_index)
Definition: main.c:678
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
threads_init
clib_error_t * threads_init(vlib_main_t *vm)
Definition: threads.c:1628
vlib_get_global_main
static vlib_global_main_t * vlib_get_global_main(void)
Definition: global_funcs.h:50
sysfs.h
vlib_thread_main_t::worker_thread_release
volatile u32 worker_thread_release
Definition: threads.h:292
vlib_stat_segment_unlock
void vlib_stat_segment_unlock(void)
Definition: stat_segment.c:38
VLIB_EARLY_CONFIG_FUNCTION
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:220
clib_time_init
__clib_export void clib_time_init(clib_time_t *c)
Definition: time.c:207
i32
signed int i32
Definition: types.h:77
clib_callback_data_init
#define clib_callback_data_init(set_, lock_)
Initialize a callback set.
Definition: callback_data.h:41
vlib_worker_thread_t::core_id
int core_id
Definition: threads.h:107
vlib_frame_queue_main_init
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
Definition: threads.c:1561
clib_mem_main_t
Definition: mem.h:128
vlib_thread_registration_::short_name
char * short_name
Definition: threads.h:34
clib_mem_alloc_no_fail
#define clib_mem_alloc_no_fail(size)
Definition: mem.h:300
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
format_clib_timebase_time
format_function_t format_clib_timebase_time
Definition: time_range.h:70
vlib_node_main_t::next_frames
vlib_next_frame_t * next_frames
Definition: node.h:691
vlib_call_init_exit_functions_no_sort
clib_error_t * vlib_call_init_exit_functions_no_sort(vlib_main_t *vm, _vlib_init_function_list_elt_t **headp, int call_once, int is_global)
Definition: init.c:382
vlib_worker_thread_node_refork
void vlib_worker_thread_node_refork(void)
Definition: threads.c:884
clib_sysfs_read
__clib_export clib_error_t * clib_sysfs_read(char *file_name, char *fmt,...)
Definition: sysfs.c:51
vlib_global_main_t::need_vlib_worker_thread_node_runtime_update
int need_vlib_worker_thread_node_runtime_update
Definition: main.h:293
vlib_worker_thread_t::wait_at_barrier
volatile u32 * wait_at_barrier
Definition: threads.h:85
clib_mem_set_numa_affinity
__clib_export int clib_mem_set_numa_affinity(u8 numa_node, int force)
Definition: mem.c:608
BARRIER_SYNC_TIMEOUT
#define BARRIER_SYNC_TIMEOUT
Definition: threads.h:168
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
f_command
static vlib_cli_command_t f_command
(constructor) VLIB_CLI_COMMAND (f_command)
Definition: threads.c:1676
vlib_set_thread_name
void vlib_set_thread_name(char *name)
Definition: threads.c:145
vlib_worker_thread_t::thread_id
pthread_t thread_id
Definition: threads.h:109
unformat_sched_policy
u32 unformat_sched_policy(unformat_input_t *input, va_list *args)
Definition: threads.c:1087
clib_mem_get_per_cpu_heap
static clib_mem_heap_t * clib_mem_get_per_cpu_heap(void)
Definition: mem.h:164
count
u8 count
Definition: dhcp.api:208
unformat_memory_size
unformat_function_t unformat_memory_size
Definition: format.h:288
clib_mem_create_heap
clib_mem_heap_t * clib_mem_create_heap(void *base, uword size, int is_locked, char *fmt,...)
Definition: mem_dlmalloc.c:536
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_worker_thread_node_runtime_update
void vlib_worker_thread_node_runtime_update(void)
Definition: threads.c:1077
ELOG_TYPE_DECLARE
#define ELOG_TYPE_DECLARE(f)
Definition: elog.h:442
math.h
CLIB_MEMORY_STORE_BARRIER
#define CLIB_MEMORY_STORE_BARRIER()
Definition: clib.h:140
vlib_thread_main_t::sched_policy
u32 sched_policy
Definition: threads.h:295
clib_bitmap_get
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
Definition: bitmap.h:197
vlib_error_main_t::counters
u64 * counters
Definition: error.h:64
vlib_node_t::index
u32 index
Definition: node.h:269
vlib_thread_registration_::fixed_count
int fixed_count
Definition: threads.h:37
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
vlib_thread_main_t::numa_heap_size
uword numa_heap_size
Definition: threads.h:305
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
vlib_last_vectors_per_main_loop
static u32 vlib_last_vectors_per_main_loop(vlib_main_t *vm)
Definition: main.h:431
clib_timebase_t
Definition: time_range.h:28
interrupt.h
clib_interrupt_resize
__clib_export void clib_interrupt_resize(void **data, uword n_int)
Definition: interrupt.c:38
clib_bitmap_count_set_bits
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
Definition: bitmap.h:449
vlib_next_frame_t::flags
u32 flags
Definition: node.h:402
vlib_worker_thread_barrier_sync
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:173
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vlib_get_thread_index
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:187
clib_mem_main_t::per_numa_mheaps
void * per_numa_mheaps[CLIB_MAX_NUMAS]
Definition: mem.h:146
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vlib_config_function_runtime_t
Definition: init.h:68
vlib_global_main
vlib_global_main_t vlib_global_main
Definition: main.c:1786
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
vlib_launch_thread_int
static clib_error_t * vlib_launch_thread_int(void *fp, vlib_worker_thread_t *w, unsigned cpu_id)
Definition: threads.c:462
unformat_bitmap_mask
__clib_export uword unformat_bitmap_mask(unformat_input_t *input, va_list *va)
unformat an any sized hexadecimal bitmask into a bitmap
Definition: bitmap.c:20
vlib_node_runtime_t::state
u16 state
Input node state.
Definition: node.h:493
rpc_call_main_thread_cb_fn
void * rpc_call_main_thread_cb_fn
Definition: threads.c:1613
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
clib_bitmap_free
#define clib_bitmap_free(v)
Free a bitmap.
Definition: bitmap.h:92
uword
u64 uword
Definition: types.h:112
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
vlib_thread_main
vlib_thread_main_t vlib_thread_main
Definition: threads.c:36
vlib_worker_thread_t::cpu_id
int cpu_id
Definition: threads.h:106
vlib_worker_thread_t::thread_mheap
void * thread_mheap
Definition: threads.h:90
vlib_thread_main_t::thread_registrations_by_name
uword * thread_registrations_by_name
Definition: threads.h:251
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
vlib_thread_registration_::first_index
u32 first_index
Definition: threads.h:44
vlib_main_t::worker_init_functions_called
uword * worker_init_functions_called
Definition: main.h:191
vlib_get_node
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:86
vlib_get_elog_main
static elog_main_t * vlib_get_elog_main()
Definition: global_funcs.h:62
vlib_thread_registration_::coremask
uword * coremask
Definition: threads.h:45
vlib_frame_queue_main_t::vlib_frame_queues
vlib_frame_queue_t ** vlib_frame_queues
Definition: threads.h:138
vlib_worker_thread_t::barrier_context
const char * barrier_context
Definition: threads.h:102
BARRIER_MINIMUM_OPEN_FACTOR
#define BARRIER_MINIMUM_OPEN_FACTOR
Definition: threads.c:1238
vlib_thread_callbacks_t::vlib_launch_thread_cb
clib_error_t *(* vlib_launch_thread_cb)(void *fp, vlib_worker_thread_t *w, unsigned cpu_id)
Definition: threads.h:238
vlib_thread_cb_register
int vlib_thread_cb_register(struct vlib_main_t *vm, vlib_thread_callbacks_t *cb)
Definition: threads.c:1592
f64
double f64
Definition: types.h:142
clib_timebase_init
__clib_export void clib_timebase_init(clib_timebase_t *tb, i32 timezone_offset_in_hours, clib_timebase_daylight_time_t daylight_type, clib_time_t *clib_time)
Definition: time_range.c:19
vlib_node_main_t::frame_size_hash
uword * frame_size_hash
Definition: node.h:724
vlib_process_start_switch_stack
static_always_inline void vlib_process_start_switch_stack(vlib_main_t *vm, vlib_process_t *p)
Definition: node_funcs.h:57
vlib_worker_thread_t::thread_function_arg
void * thread_function_arg
Definition: threads.h:93
vlib_thread_main_t::n_thread_stacks
u32 n_thread_stacks
Definition: threads.h:265
vlib_worker_thread_t::lwp
long lwp
Definition: threads.h:105
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
vlib_worker_thread_t::numa_id
int numa_id
Definition: threads.h:108
format.h
vlib_worker_thread_barrier_held
u8 vlib_worker_thread_barrier_held(void)
Return true if the wroker thread barrier is held.
Definition: threads.c:1270
vlib_process_signal_event_mt_args_t::data
uword data
Definition: threads.h:149
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
vlib_main_t::pending_rpc_requests
uword * pending_rpc_requests
Definition: main.h:262
format_clib_time
format_function_t format_clib_time
Definition: time.h:76
vlib_stat_segment_lock
void vlib_stat_segment_lock(void)
Definition: stat_segment.c:30
vlib_process_signal_event_mt_args_t::node_index
uword node_index
Definition: threads.h:147
vlib_thread_main_t::sched_priority
u32 sched_priority
Definition: threads.h:298
clib_bitmap_set
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap.
Definition: bitmap.h:167
vlib_main_t::barrier_epoch
f64 barrier_epoch
Definition: main.h:247
vec_dup_aligned
#define vec_dup_aligned(V, A)
Return copy of vector (no header, alignment specified).
Definition: vec.h:453
vlib_node_t::runtime_data
void * runtime_data
Definition: node.h:275
clib_min
#define clib_min(x, y)
Definition: clib.h:342
vlib_node_main_t::frame_sizes
vlib_frame_size_t * frame_sizes
Definition: node.h:727
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
vlib_global_main_t::elog_main
elog_main_t elog_main
Definition: main.h:302
FRAME_QUEUE_MAX_NELTS
#define FRAME_QUEUE_MAX_NELTS
Definition: node.h:762
cpu_id
u32 cpu_id
Definition: vpe.api:222
vlib_main_t::vlib_node_runtime_perf_callbacks
vlib_node_runtime_perf_callback_set_t vlib_node_runtime_perf_callbacks
Definition: main.h:134
clib_atomic_fetch_add
#define clib_atomic_fetch_add(a, b)
Definition: atomics.h:23
barrier_trace_release
static void barrier_trace_release(f64 t_entry, f64 t_closed_total, f64 t_update_main)
Definition: threads.c:113
vec_add2_aligned
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:656
vlib_thread_registration_::function
vlib_thread_function_t * function
Definition: threads.h:35
clib_mem_main
__clib_export clib_mem_main_t clib_mem_main
Definition: mem.c:22
hash_get_mem
#define hash_get_mem(h, key)
Definition: hash.h:269
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vlib_worker_thread_t::registration
vlib_thread_registration_t * registration
Definition: threads.h:97
VLIB_FRAME_ALIGN
#define VLIB_FRAME_ALIGN
Definition: node.h:369
vlib_thread_main_t::registrations
vlib_thread_registration_t ** registrations
Definition: threads.h:249
time_range.h
vlib_thread_registration_::mheap_size
uword mheap_size
Definition: threads.h:36
cpu_config
static clib_error_t * cpu_config(vlib_main_t *vm, unformat_input_t *input)
Definition: threads.c:1101
vlib_error_main_t::counters_last_clear
u64 * counters_last_clear
Definition: error.h:67
clib_call_callbacks
#define clib_call_callbacks(h,...)
call the specified callback set
Definition: callback.h:67
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vec_add1_aligned
#define vec_add1_aligned(V, E, A)
Add 1 element to end of vector (alignment specified).
Definition: vec.h:615
VLIB_THREAD_STACK_SIZE
#define VLIB_THREAD_STACK_SIZE
Definition: threads.h:65
vlib_frame_queue_alloc
vlib_frame_queue_t * vlib_frame_queue_alloc(int nelts)
Definition: threads.c:342
vlib_thread_main_t::n_threads
u32 n_threads
Definition: threads.h:271
BARRIER_MINIMUM_OPEN_LIMIT
#define BARRIER_MINIMUM_OPEN_LIMIT
Definition: threads.c:1234
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vlib_next_frame_t::node_runtime_index
u32 node_runtime_index
Definition: node.h:399
clib_timebase_now
static f64 clib_timebase_now(clib_timebase_t *tb)
Definition: time_range.h:88
show_clock_command_fn
static clib_error_t * show_clock_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: threads.c:1637
vlib_thread_main_t
Definition: threads.h:243
vlib_node_t::stats_total
vlib_node_stats_t stats_total
Definition: node.h:259
vlib_node_t::runtime_data_bytes
u8 runtime_data_bytes
Definition: node.h:302
vlib_get_first_main
static vlib_main_t * vlib_get_first_main(void)
Definition: global_funcs.h:44
vlib_node_main_t::nodes_by_type
vlib_node_runtime_t * nodes_by_type[VLIB_N_NODE_TYPE]
Definition: node.h:678
CLIB_PAUSE
#define CLIB_PAUSE()
Definition: lock.h:23
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
clib_time_t::last_cpu_time
u64 last_cpu_time
Definition: time.h:51
vlib_worker_thread_t
Definition: threads.h:81
vlib_worker_thread_t::thread_stack
u8 * thread_stack
Definition: threads.h:91
vlib_get_main_by_index
static vlib_main_t * vlib_get_main_by_index(u32 thread_index)
Definition: global_funcs.h:29
clib_error_return_unix
#define clib_error_return_unix(e, args...)
Definition: error.h:102
vlib_worker_thread_t::barrier_elog_enabled
u8 barrier_elog_enabled
Definition: threads.h:100
vlib_worker_thread_bootstrap_fn
void * vlib_worker_thread_bootstrap_fn(void *arg)
Definition: threads.c:406
vlib_rpc_call_main_thread
void vlib_rpc_call_main_thread(void *callback, u8 *args, u32 arg_size)
Definition: threads.c:1616
vlib_worker_thread_t::elog_track
elog_track_t elog_track
Definition: threads.h:95
vlib_node_runtime_sync_stats
void vlib_node_runtime_sync_stats(vlib_main_t *vm, vlib_node_runtime_t *r, uword n_calls, uword n_vectors, uword n_clocks)
Definition: main.c:590
nm
nat44_ei_main_t * nm
Definition: nat44_ei_hairpinning.c:413
vlib_thread_registration_::no_data_structure_clone
int no_data_structure_clone
Definition: threads.h:39
vlib_node_get_runtime
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
Definition: node_funcs.h:116
vlib_worker_thread_initial_barrier_sync_and_release
void vlib_worker_thread_initial_barrier_sync_and_release(vlib_main_t *vm)
Definition: threads.c:1242
fformat
__clib_export word fformat(FILE *f, char *fmt,...)
Definition: format.c:466
vlib_main_t::heap_base
void * heap_base
Definition: main.h:158
vlib_thread_registration_::name
char * name
Definition: threads.h:33
foreach_sched_policy
#define foreach_sched_policy
Definition: threads.h:221
vlib_main_t::worker_thread_main_loop_callback_lock
clib_spinlock_t worker_thread_main_loop_callback_lock
Definition: main.h:230
now
f64 now
Definition: nat44_ei_out2in.c:710
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
vlib_thread_stacks
u8 ** vlib_thread_stacks
Definition: main.c:659
vlib_thread_main_t::extern_thread_mgmt
int extern_thread_mgmt
Definition: threads.h:302
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vlib_node_t::stats_last_clear
vlib_node_stats_t stats_last_clear
Definition: node.h:263
vlib_frame_queue_t::nelts
u32 nelts
Definition: threads.h:121
vlib_get_n_threads
static u32 vlib_get_n_threads()
Definition: global_funcs.h:23
vlib_node_t
Definition: node.h:247
vlib_get_thread_core_numa
void vlib_get_thread_core_numa(vlib_worker_thread_t *w, unsigned cpu_id)
Definition: threads.c:428
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
vlib_frame_queue_t::elts
vlib_frame_queue_elt_t * elts
Definition: threads.h:118
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vlib_worker_thread_init
void vlib_worker_thread_init(vlib_worker_thread_t *w)
Definition: threads.c:369
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:419
vlib_worker_thread_t::workers_at_barrier
volatile u32 * workers_at_barrier
Definition: threads.h:86
elog_track_register
__clib_export word elog_track_register(elog_main_t *em, elog_track_t *t)
register an event track
Definition: elog.c:198
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
os_get_nthreads
uword os_get_nthreads(void)
Definition: threads.c:139
vlib_thread_callbacks_t::vlib_thread_set_lcore_cb
clib_error_t *(* vlib_thread_set_lcore_cb)(u32 thread, u16 cpu)
Definition: threads.h:240
vlib_global_main_t::worker_init_function_registrations
_vlib_init_function_list_elt_t * worker_init_function_registrations
Definition: main.h:312
vlib_worker_thread_t::barrier_sync_count
u64 barrier_sync_count
Definition: threads.h:99
barrier_trace_sync_rec
static void barrier_trace_sync_rec(f64 t_entry)
Definition: threads.c:71
i
int i
Definition: flowhash_template.h:376
vlib_worker_thread_t::name
u8 * name
Definition: threads.h:98
start_workers
static clib_error_t * start_workers(vlib_main_t *vm)
Definition: threads.c:512
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
clib_mem_alloc_aligned
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:264
barrier_trace_sync
static void barrier_trace_sync(f64 t_entry, f64 t_open, f64 t_closed)
Definition: threads.c:46
rv
int __clib_unused rv
Definition: application.c:491
ELOG_DATA
#define ELOG_DATA(em, f)
Definition: elog.h:484
vlib_node_main_t::pending_frames
vlib_pending_frame_t * pending_frames
Definition: node.h:694
barrier_trace_release_rec
static void barrier_trace_release_rec(f64 t_entry)
Definition: threads.c:93
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
vlib_worker_thread_t::instance_id
u32 instance_id
Definition: threads.h:96
vlib_node_main_t
Definition: node.h:665
vlib_frame_queue_t
Definition: threads.h:114
clib_bitmap_foreach
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
vlib_node_runtime_t
Definition: node.h:454
vlib_next_frame_t
Definition: node.h:393
vlib_node_main_t::nodes
vlib_node_t ** nodes
Definition: node.h:668
vlib_thread_registration_
Definition: threads.h:27
vlib_cli_command_t
Definition: cli.h:92
worker_thread_node_runtime_update_internal
static void worker_thread_node_runtime_update_internal(void)
Definition: threads.c:837
vlib_thread_main_t::skip_cores
u32 skip_cores
Definition: threads.h:274
vlib_thread_main_t::use_pthreads
int use_pthreads
Definition: threads.h:259
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
vlib_global_main_t::vlib_mains
vlib_main_t ** vlib_mains
Definition: main.h:281
vlib_stats_register_mem_heap
void vlib_stats_register_mem_heap(clib_mem_heap_t *heap)
Definition: stat_segment_provider.c:84
elog_main_t::lock
uword * lock
SMP lock, non-zero means locking required.
Definition: elog.h:175
vlib_node_t::owner_node_index
u32 owner_node_index
Definition: node.h:345
hash_create
#define hash_create(elts, value_bytes)
Definition: hash.h:695
vlib_next_frame_init
static void vlib_next_frame_init(vlib_next_frame_t *nf)
Definition: node.h:432
vlib_node_runtime_t::runtime_data
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:505
vlib_process_signal_event_mt_args_t
Definition: threads.h:145
clib_mem_set_heap
static clib_mem_heap_t * clib_mem_set_heap(clib_mem_heap_t *heap)
Definition: mem.h:368
vlib_thread_main_t::frame_queue_mains
vlib_frame_queue_main_t * frame_queue_mains
Definition: threads.h:289
clib_mem_heap_t
Definition: mem.h:107
VLIB_MAIN_LOOP_ENTER_FUNCTION
#define VLIB_MAIN_LOOP_ENTER_FUNCTION(x)
Definition: init.h:175
vlib_thread_init
clib_error_t * vlib_thread_init(vlib_main_t *vm)
Definition: threads.c:173
vlib_frame_queue_main_t
Definition: threads.h:133
vlib_process_signal_event_mt_args_t::type_opaque
uword type_opaque
Definition: threads.h:148
vlib_thread_registration_::use_pthreads
int use_pthreads
Definition: threads.h:43
unformat_bitmap_list
__clib_export uword unformat_bitmap_list(unformat_input_t *input, va_list *va)
unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )
Definition: bitmap.c:55
vlib_node_main_t::interrupts
void * interrupts
Definition: node.h:681
vlib_get_thread_main_not_inline
vlib_thread_main_t * vlib_get_thread_main_not_inline(void)
Definition: threads.c:1685
vl
u32 vl(void *p)
Definition: threads.c:30
vlib_thread_main_t::thread_prefix
u8 * thread_prefix
Definition: threads.h:277
vlib_main_t::time_last_barrier_release
f64 time_last_barrier_release
Definition: main.h:109
vlib_frame_queue_main_t::node_index
u32 node_index
Definition: threads.h:135
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
clib_interrupt_init
__clib_export void clib_interrupt_init(void **data, uword n_int)
Definition: interrupt.c:24
clib_bitmap_dup
#define clib_bitmap_dup(v)
Duplicate a bitmap.
Definition: bitmap.h:87
clib_sysfs_list_to_bitmap
__clib_export uword * clib_sysfs_list_to_bitmap(char *filename)
Definition: sysfs.c:267