summaryrefslogtreecommitdiffstats
path: root/src/vlib/threads.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-04-23 10:07:24 -0400
committerDave Barach <openvpp@barachs.net>2019-05-01 23:51:20 +0000
commit79ad20fc043d74b8812824d0862292bc83e9b09a (patch)
treee97ed7a7a8c4b8bcb26f394bd78af63e04f87abe /src/vlib/threads.c
parent7cbf2d154acc53609afdc76a8bef1c4023fe274a (diff)
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. Change-Id: I82008d09968c65e2a4af0ebb7887389992e60603 Signed-off-by: Dave Barach <dave@barachs.net> (cherry picked from commit 9ae190e9d228bfc1358482d4f07da1f4cfd41c90)
Diffstat (limited to 'src/vlib/threads.c')
-rw-r--r--src/vlib/threads.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 7d17c7b37cc..52886df37e0 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -1389,7 +1389,9 @@ vlib_worker_thread_barrier_sync_int (vlib_main_t * vm, const char *func_name)
f64 t_entry;
f64 t_open;
f64 t_closed;
+ f64 max_vector_rate;
u32 count;
+ int i;
if (vec_len (vlib_mains) < 2)
return;
@@ -1410,23 +1412,41 @@ vlib_worker_thread_barrier_sync_int (vlib_main_t * vm, const char *func_name)
return;
}
+ /*
+ * Need data to decide if we're working hard enough to honor
+ * the barrier hold-down timer.
+ */
+ max_vector_rate = 0.0;
+ for (i = 1; i < vec_len (vlib_mains); i++)
+ max_vector_rate =
+ clib_max (max_vector_rate,
+ vlib_last_vectors_per_main_loop_as_f64 (vlib_mains[i]));
+
vlib_worker_threads[0].barrier_sync_count++;
/* Enforce minimum barrier open time to minimize packet loss */
ASSERT (vm->barrier_no_close_before <= (now + BARRIER_MINIMUM_OPEN_LIMIT));
- while (1)
+ /*
+ * If any worker thread seems busy, which we define
+ * as a vector rate above 10, we enforce the barrier hold-down timer
+ */
+ if (max_vector_rate > 10.0)
{
- now = vlib_time_now (vm);
- /* Barrier hold-down timer expired? */
- if (now >= vm->barrier_no_close_before)
- break;
- if ((vm->barrier_no_close_before - now)
- > (2.0 * BARRIER_MINIMUM_OPEN_LIMIT))
+ while (1)
{
- clib_warning ("clock change: would have waited for %.4f seconds",
- (vm->barrier_no_close_before - now));
- break;
+ now = vlib_time_now (vm);
+ /* Barrier hold-down timer expired? */
+ if (now >= vm->barrier_no_close_before)
+ break;
+ if ((vm->barrier_no_close_before - now)
+ > (2.0 * BARRIER_MINIMUM_OPEN_LIMIT))
+ {
+ clib_warning
+ ("clock change: would have waited for %.4f seconds",
+ (vm->barrier_no_close_before - now));
+ break;
+ }
}
}
/* Record time of closure */