vlib: split vlib_main_t into global and per-thread
Type: refactor
Change-Id: I8b273bc3bf16aa360f031f1b2692f766e5fc4613
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vlib/threads.h b/src/vlib/threads.h
index b514ba4..d715ebf 100644
--- a/src/vlib/threads.h
+++ b/src/vlib/threads.h
@@ -19,8 +19,6 @@
#include <vppinfra/callback.h>
#include <linux/sched.h>
-extern vlib_main_t **vlib_mains;
-
void vlib_set_thread_name (char *name);
/* arg is actually a vlib__thread_t * */
@@ -239,28 +237,29 @@
void vlib_worker_thread_fork_fixup (vlib_fork_fixup_t which);
-#define foreach_vlib_main(body) \
-do { \
- vlib_main_t ** __vlib_mains = 0, *this_vlib_main; \
- int ii; \
- \
- 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); \
- } \
- \
- for (ii = 0; ii < vec_len (__vlib_mains); ii++) \
- { \
- this_vlib_main = __vlib_mains[ii]; \
- /* body uses this_vlib_main... */ \
- (body); \
- } \
- vec_free (__vlib_mains); \
-} while (0);
+#define foreach_vlib_main(body) \
+ do \
+ { \
+ vlib_main_t **__vlib_mains = 0, *this_vlib_main; \
+ int ii; \
+ \
+ for (ii = 0; ii < vec_len (vlib_global_main.vlib_mains); ii++) \
+ { \
+ this_vlib_main = vlib_global_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); \
+ } \
+ \
+ for (ii = 0; ii < vec_len (__vlib_mains); ii++) \
+ { \
+ this_vlib_main = __vlib_mains[ii]; \
+ /* body uses this_vlib_main... */ \
+ (body); \
+ } \
+ vec_free (__vlib_mains); \
+ } \
+ while (0);
#define foreach_sched_policy \
_(SCHED_OTHER, OTHER, "other") \
@@ -402,6 +401,7 @@
{
if (PREDICT_FALSE (*vlib_worker_threads->wait_at_barrier))
{
+ vlib_global_main_t *vgm = vlib_get_global_main ();
vlib_main_t *vm = vlib_get_main ();
u32 thread_index = vm->thread_index;
f64 t = vlib_time_now (vm);
@@ -448,7 +448,7 @@
f64 now;
vm->time_offset = 0.0;
now = vlib_time_now (vm);
- vm->time_offset = vlib_global_main.time_last_barrier_release - now;
+ vm->time_offset = vgm->vlib_mains[0]->time_last_barrier_release - now;
vm->time_last_barrier_release = vlib_time_now (vm);
}