]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: local var in fpm_process_queue() sched cond
authorDuncan Eastoe <duncan.eastoe@att.com>
Fri, 18 Dec 2020 14:29:36 +0000 (14:29 +0000)
committerDuncan Eastoe <duncan.eastoe@att.com>
Fri, 18 Dec 2020 15:36:39 +0000 (15:36 +0000)
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 <duncan.eastoe@att.com>
zebra/dplane_fpm_nl.c

index 5133258eb3a7d05e6a1e053f994fbb625e361324..13d81f8621c320fa7f3aeef261866f21168eee4a 100644 (file)
@@ -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);