From 511ce2572a9710835c6722a09a93b4dd80ab7fae Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Thu, 2 May 2019 15:48:15 -0400 Subject: Clean up multi-thread barrier-sync hold-down timer Main thread: don't bother with the barrier sync hold-down timer if none of the worker threads are busy. Worker threads: avoid epoll_pwait (10ms timeout) when the control-plane has been active in the last half-second. Cherry-pick a recent dangling reference fix: pool_elt_at_index after e.g. rx callback is required, in case the unix file pool expands. Manual feature backport to 18.07 Change-Id: I745fbb8a12aeda34b0ec7b6dcda66c0e25c3eee1 Signed-off-by: Dave Barach --- src/vlib/threads.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/vlib/threads.h') diff --git a/src/vlib/threads.h b/src/vlib/threads.h index f78ec1b9fa5..dd0ed20ca0c 100644 --- a/src/vlib/threads.h +++ b/src/vlib/threads.h @@ -400,7 +400,7 @@ vlib_worker_thread_barrier_check (void) { if (PREDICT_FALSE (*vlib_worker_threads->wait_at_barrier)) { - vlib_main_t *vm; + vlib_main_t *vm = vlib_get_main (); clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, 1); if (CLIB_DEBUG > 0) { @@ -409,6 +409,21 @@ vlib_worker_thread_barrier_check (void) } while (*vlib_worker_threads->wait_at_barrier) ; + + /* + * Recompute the offset from thread-0 time. + * Note that vlib_time_now adds vm->time_offset, so + * clear it first. Save the resulting idea of "now", to + * see how well we're doing. See show_clock_command_fn(...) + */ + { + 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_last_barrier_release = vlib_time_now (vm); + } + if (CLIB_DEBUG > 0) vm->parked_at_barrier = 0; clib_smp_atomic_add (vlib_worker_threads->workers_at_barrier, -1); -- cgit 1.2.3-korg