mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 07:23:41 +00:00
zebra: reduce atomic ops in fpm_process_queue()
Maintain the count of contexts which have been processed in a local variable, and perform a single atomic update after we have consumed all queued contexts. Generally this results in at least one less atomic operation per context. Signed-off-by: Duncan Eastoe <duncan.eastoe@att.com>
This commit is contained in:
parent
3f2b998f61
commit
438dd3e7df
@ -1223,6 +1223,7 @@ static int fpm_process_queue(struct thread *t)
|
|||||||
struct fpm_nl_ctx *fnc = THREAD_ARG(t);
|
struct fpm_nl_ctx *fnc = THREAD_ARG(t);
|
||||||
struct zebra_dplane_ctx *ctx;
|
struct zebra_dplane_ctx *ctx;
|
||||||
bool no_bufs = false;
|
bool no_bufs = false;
|
||||||
|
uint64_t processed_contexts = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
/* No space available yet. */
|
/* No space available yet. */
|
||||||
@ -1241,8 +1242,7 @@ static int fpm_process_queue(struct thread *t)
|
|||||||
fpm_nl_enqueue(fnc, ctx);
|
fpm_nl_enqueue(fnc, ctx);
|
||||||
|
|
||||||
/* Account the processed entries. */
|
/* Account the processed entries. */
|
||||||
atomic_fetch_add_explicit(&fnc->counters.dplane_contexts, 1,
|
processed_contexts++;
|
||||||
memory_order_relaxed);
|
|
||||||
atomic_fetch_sub_explicit(&fnc->counters.ctxqueue_len, 1,
|
atomic_fetch_sub_explicit(&fnc->counters.ctxqueue_len, 1,
|
||||||
memory_order_relaxed);
|
memory_order_relaxed);
|
||||||
|
|
||||||
@ -1250,6 +1250,10 @@ static int fpm_process_queue(struct thread *t)
|
|||||||
dplane_provider_enqueue_out_ctx(fnc->prov, ctx);
|
dplane_provider_enqueue_out_ctx(fnc->prov, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update count of processed contexts */
|
||||||
|
atomic_fetch_add_explicit(&fnc->counters.dplane_contexts,
|
||||||
|
processed_contexts, memory_order_relaxed);
|
||||||
|
|
||||||
/* Re-schedule if we ran out of buffer space */
|
/* Re-schedule if we ran out of buffer space */
|
||||||
if (no_bufs)
|
if (no_bufs)
|
||||||
thread_add_timer(fnc->fthread->master, fpm_process_queue,
|
thread_add_timer(fnc->fthread->master, fpm_process_queue,
|
||||||
|
Loading…
Reference in New Issue
Block a user