From 3f2b998f6100945521d2c89fd286b75e13e24977 Mon Sep 17 00:00:00 2001 From: Duncan Eastoe Date: Fri, 18 Dec 2020 14:29:36 +0000 Subject: [PATCH] zebra: local var in fpm_process_queue() sched cond Don't use an atomic operation to determine whether fpm_process_queue() needs to be re-scheduled. Instead we can simply use a local variable to determine if we stopped processing because we ran out of buffers. In the case where we would have re-scheduled due to new context objects in the queue (enqueued after we stopped processing), fpm_nl_process() will schedule us (or will have done already). Signed-off-by: Duncan Eastoe --- zebra/dplane_fpm_nl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c index 5133258eb3..13d81f8621 100644 --- a/zebra/dplane_fpm_nl.c +++ b/zebra/dplane_fpm_nl.c @@ -1222,11 +1222,14 @@ static int fpm_process_queue(struct thread *t) { struct fpm_nl_ctx *fnc = THREAD_ARG(t); struct zebra_dplane_ctx *ctx; + bool no_bufs = false; while (true) { /* No space available yet. */ - if (STREAM_WRITEABLE(fnc->obuf) < NL_PKT_BUF_SIZE) + if (STREAM_WRITEABLE(fnc->obuf) < NL_PKT_BUF_SIZE) { + no_bufs = true; break; + } /* Dequeue next item or quit processing. */ frr_with_mutex (&fnc->ctxqueue_mutex) { @@ -1247,10 +1250,8 @@ static int fpm_process_queue(struct thread *t) dplane_provider_enqueue_out_ctx(fnc->prov, ctx); } - /* Check for more items in the queue. */ - if (atomic_load_explicit(&fnc->counters.ctxqueue_len, - memory_order_relaxed) - > 0) + /* Re-schedule if we ran out of buffer space */ + if (no_bufs) thread_add_timer(fnc->fthread->master, fpm_process_queue, fnc, 0, &fnc->t_dequeue); -- 2.39.5