aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/threads.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib/threads.h')
-rw-r--r--src/vlib/threads.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/vlib/threads.h b/src/vlib/threads.h
index 39f64e1dca0..eca4fc268d5 100644
--- a/src/vlib/threads.h
+++ b/src/vlib/threads.h
@@ -201,18 +201,6 @@ typedef enum
void vlib_worker_thread_fork_fixup (vlib_fork_fixup_t which);
-static inline void
-vlib_worker_thread_barrier_check (void)
-{
- if (PREDICT_FALSE (*vlib_worker_threads->wait_at_barrier))
- {
- clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, 1);
- while (*vlib_worker_threads->wait_at_barrier)
- ;
- clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, -1);
- }
-}
-
#define foreach_vlib_main(body) \
do { \
vlib_main_t ** __vlib_mains = 0, *this_vlib_main; \
@@ -221,6 +209,8 @@ do { \
for (ii = 0; ii < vec_len (vlib_mains); ii++) \
{ \
this_vlib_main = vlib_mains[ii]; \
+ ASSERT (ii == 0 || \
+ this_vlib_main->parked_at_barrier == 1); \
if (this_vlib_main) \
vec_add1 (__vlib_mains, this_vlib_main); \
} \
@@ -320,6 +310,8 @@ typedef struct
extern vlib_thread_main_t vlib_thread_main;
+#include <vlib/global_funcs.h>
+
#define VLIB_REGISTER_THREAD(x,...) \
__VA_ARGS__ vlib_thread_registration_t x; \
static void __vlib_add_thread_registration_##x (void) \
@@ -356,6 +348,26 @@ vlib_get_current_worker_index ()
return os_get_cpu_number () - 1;
}
+static inline void
+vlib_worker_thread_barrier_check (void)
+{
+ if (PREDICT_FALSE (*vlib_worker_threads->wait_at_barrier))
+ {
+ vlib_main_t *vm;
+ 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);
+ }
+}
+
always_inline vlib_main_t *
vlib_get_worker_vlib_main (u32 worker_index)
{