aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/main.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-06-03 19:48:22 -0400
committerDamjan Marion <dmarion@me.com>2019-06-04 13:04:42 +0000
commitc602b384ac022f70690a3a7c711149f7cb63ad12 (patch)
treecad51d5702502d35c714b3a003d000ffe7aae4db /src/vlib/main.c
parentc424de75e561b2197d29812b3900db58a06096d7 (diff)
sort worker-thread init functions in advance
Otherwise, all N worker threads try to sort the list at the same time: a good way to have a bad day. This approach performs *far* better than maintaing order by adding a spin-lock. By direct measurement w/ elog + g2: 11 threads execute the per-thread init function list in 22us, vs. 50ms with a CLIB_PAUSE() enabled spin-lock. Change-Id: I1745f2a213c0561260139a60114dcb981e0c64e5 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib/main.c')
-rw-r--r--src/vlib/main.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c
index b6006e8bab0..43400f8594c 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1721,6 +1721,14 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
if (is_main)
{
uword i;
+
+ /*
+ * Perform an initial barrier sync. Pays no attention to
+ * the barrier sync hold-down timer scheme, which won't work
+ * at this point in time.
+ */
+ vlib_worker_thread_initial_barrier_sync_and_release (vm);
+
nm->current_process_index = ~0;
for (i = 0; i < vec_len (nm->processes); i++)
cpu_time_now = dispatch_process (vm, nm->processes[i], /* frame */ 0,
@@ -2090,6 +2098,9 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
if ((error = vlib_call_all_config_functions (vm, input, 0 /* is_early */ )))
goto done;
+ /* Sort per-thread init functions before we start threads */
+ vlib_sort_init_exit_functions (&vm->worker_init_function_registrations);
+
/* Call all main loop enter functions. */
{
clib_error_t *sub_error;