From: Donald Sharp Date: Fri, 5 May 2023 14:37:11 +0000 (-0400) Subject: zebra: Fix dp_out_queued counter to actually reflect real life X-Git-Tag: docker/8.5.2~12^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=97fff7b767b00ded2c429b80bc9878fdacf38b9e;p=mirror%2Ffrr.git zebra: Fix dp_out_queued counter to actually reflect real life The prov->dp_out_queued counter was never being decremented when a ctx was pulled off of the list. Let's change it to accurately reflect real life. Broken: janelle.pinkbelly.org# show zebra dplane providers detailed Zebra dataplane providers: Kernel (1): in: 330872, q: 0, q_max: 100, out: 330872, q: 330872, q_max: 330872 janelle.pinkbelly.org# Fixed: sharpd@janelle:/tmp/topotests$ vtysh -c "show zebra dplane providers detailed" Zebra dataplane providers: Kernel (1): in: 221495, q: 0, q_max: 100, out: 221495, q: 0, q_max: 100 sharpd@janelle:/tmp/topotests$ Signed-off-by: Donald Sharp (cherry picked from commit 995d810d08109d8c7eca0d23710a2043711411d9) --- diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index f6f436f39f..eb408232ab 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -5774,6 +5774,21 @@ void dplane_provider_enqueue_out_ctx(struct zebra_dplane_provider *prov, memory_order_relaxed); } +static struct zebra_dplane_ctx * +dplane_provider_dequeue_out_ctx(struct zebra_dplane_provider *prov) +{ + struct zebra_dplane_ctx *ctx; + + ctx = dplane_ctx_list_pop(&(prov->dp_ctx_out_list)); + if (!ctx) + return NULL; + + atomic_fetch_sub_explicit(&(prov->dp_out_queued), 1, + memory_order_relaxed); + + return ctx; +} + /* * Accessor for provider object */ @@ -6805,7 +6820,7 @@ static void dplane_thread_loop(struct thread *event) dplane_provider_lock(prov); while (counter < limit) { - ctx = dplane_ctx_list_pop(&(prov->dp_ctx_out_list)); + ctx = dplane_provider_dequeue_out_ctx(prov); if (ctx) { dplane_ctx_list_add_tail(&work_list, ctx); counter++;