+ return vlib_get_thread_index () - 1;
+}
+
+static inline void
+vlib_worker_thread_barrier_check (void)
+{
+ if (PREDICT_FALSE (*vlib_worker_threads->wait_at_barrier))
+ {
+ vlib_main_t *vm = vlib_get_main ();
+ u32 thread_index = vm->thread_index;
+ f64 t = vlib_time_now (vm);
+
+ if (PREDICT_FALSE (vlib_worker_threads->barrier_elog_enabled))
+ {
+ vlib_worker_thread_t *w = vlib_worker_threads + thread_index;
+ /* *INDENT-OFF* */
+ ELOG_TYPE_DECLARE (e) = {
+ .format = "barrier-wait-thread-%d",
+ .format_args = "i4",
+ };
+ /* *INDENT-ON* */
+
+ struct
+ {
+ u32 thread_index;
+ } __clib_packed *ed;
+
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e,
+ w->elog_track);
+ ed->thread_index = thread_index;
+ }
+
+ clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, 1);
+ if (CLIB_DEBUG > 0)
+ {
+ vm = vlib_get_main ();
+ vm->parked_at_barrier = 1;
+ }
+ while (*vlib_worker_threads->wait_at_barrier)
+ ;
+ if (CLIB_DEBUG > 0)
+ vm->parked_at_barrier = 0;
+ clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, -1);
+
+ if (PREDICT_FALSE (*vlib_worker_threads->node_reforks_required))
+ {
+ if (PREDICT_FALSE (vlib_worker_threads->barrier_elog_enabled))
+ {
+ t = vlib_time_now (vm) - t;
+ vlib_worker_thread_t *w = vlib_worker_threads + thread_index;
+ /* *INDENT-OFF* */
+ ELOG_TYPE_DECLARE (e) = {
+ .format = "barrier-refork-thread-%d",
+ .format_args = "i4",
+ };
+ /* *INDENT-ON* */
+
+ struct
+ {
+ u32 thread_index;
+ } __clib_packed *ed;
+
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e,
+ w->elog_track);
+ ed->thread_index = thread_index;
+ }
+
+ vlib_worker_thread_node_refork ();
+ clib_smp_atomic_add (vlib_worker_threads->node_reforks_required,
+ -1);
+ while (*vlib_worker_threads->node_reforks_required)
+ ;
+ }
+ if (PREDICT_FALSE (vlib_worker_threads->barrier_elog_enabled))
+ {
+ t = vlib_time_now (vm) - t;
+ vlib_worker_thread_t *w = vlib_worker_threads + thread_index;
+ /* *INDENT-OFF* */
+ ELOG_TYPE_DECLARE (e) = {
+ .format = "barrier-released-thread-%d: %dus",
+ .format_args = "i4i4",
+ };
+ /* *INDENT-ON* */
+
+ struct
+ {
+ u32 thread_index;
+ u32 duration;
+ } __clib_packed *ed;
+
+ ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e,
+ w->elog_track);
+ ed->thread_index = thread_index;
+ ed->duration = (int) (1000000.0 * t);
+ }
+ }