aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-01-19 13:09:20 -0500
committerFlorin Coras <florin.coras@gmail.com>2018-01-19 22:15:52 +0000
commitd47c509af13ddcb80f82aebd25dc4f40cc778a0e (patch)
treec5983c129c95682b4f9206019cec6a5024852c1d
parentba7992aa62523d014b55802463fb3357c7099b70 (diff)
Fix MP hazard in interrupt node scheduling
Change-Id: Iff14ed6ffd822eb2286aac6af467d9c8660e3d81 Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r--src/vlib/main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c
index d32ca7b8ea2..f915aa41b3b 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1514,13 +1514,19 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
/* Next handle interrupts. */
{
+ /* unlocked read, for performance */
uword l = _vec_len (nm->pending_interrupt_node_runtime_indices);
uword i;
- if (l > 0)
+ if (PREDICT_FALSE (l > 0))
{
u32 *tmp;
if (!is_main)
- clib_spinlock_lock (&nm->pending_interrupt_lock);
+ {
+ clib_spinlock_lock (&nm->pending_interrupt_lock);
+ /* Re-read w/ lock held, in case another thread added an item */
+ l = _vec_len (nm->pending_interrupt_node_runtime_indices);
+ }
+
tmp = nm->pending_interrupt_node_runtime_indices;
nm->pending_interrupt_node_runtime_indices =
last_node_runtime_indices;