Skip to content

Commit 34670c4

Browse files
committed
zebra: Use the ctx queue counters
The ctx queue data structures already have a counter associated with them. Let's just use them instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
1 parent ade1d8a commit 34670c4

1 file changed

Lines changed: 8 additions & 25 deletions

File tree

zebra/zebra_dplane.c

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,8 @@ struct zebra_dplane_provider {
483483
int (*dp_fini)(struct zebra_dplane_provider *prov, bool early_p);
484484

485485
_Atomic uint32_t dp_in_counter;
486-
_Atomic uint32_t dp_in_queued;
487486
_Atomic uint32_t dp_in_max;
488487
_Atomic uint32_t dp_out_counter;
489-
_Atomic uint32_t dp_out_queued;
490488
_Atomic uint32_t dp_out_max;
491489
_Atomic uint32_t dp_error_counter;
492490

@@ -6137,17 +6135,19 @@ int dplane_show_provs_helper(struct vty *vty, bool detailed)
61376135

61386136
/* Show counters, useful info from each registered provider */
61396137
while (prov) {
6138+
dplane_provider_lock(prov);
6139+
in_q = dplane_ctx_queue_count(&prov->dp_ctx_in_list);
6140+
out_q = dplane_ctx_queue_count(&prov->dp_ctx_out_list);
6141+
dplane_provider_unlock(prov);
61406142

61416143
in = atomic_load_explicit(&prov->dp_in_counter,
61426144
memory_order_relaxed);
6143-
in_q = atomic_load_explicit(&prov->dp_in_queued,
6144-
memory_order_relaxed);
6145+
61456146
in_max = atomic_load_explicit(&prov->dp_in_max,
61466147
memory_order_relaxed);
61476148
out = atomic_load_explicit(&prov->dp_out_counter,
61486149
memory_order_relaxed);
6149-
out_q = atomic_load_explicit(&prov->dp_out_queued,
6150-
memory_order_relaxed);
6150+
61516151
out_max = atomic_load_explicit(&prov->dp_out_max,
61526152
memory_order_relaxed);
61536153

@@ -6299,10 +6299,6 @@ struct zebra_dplane_ctx *dplane_provider_dequeue_in_ctx(
62996299
dplane_provider_lock(prov);
63006300

63016301
ctx = dplane_ctx_list_pop(&(prov->dp_ctx_in_list));
6302-
if (ctx) {
6303-
atomic_fetch_sub_explicit(&prov->dp_in_queued, 1,
6304-
memory_order_relaxed);
6305-
}
63066302

63076303
dplane_provider_unlock(prov);
63086304

@@ -6330,10 +6326,6 @@ int dplane_provider_dequeue_in_list(struct zebra_dplane_provider *prov,
63306326
break;
63316327
}
63326328

6333-
if (ret > 0)
6334-
atomic_fetch_sub_explicit(&prov->dp_in_queued, ret,
6335-
memory_order_relaxed);
6336-
63376329
dplane_provider_unlock(prov);
63386330

63396331
return ret;
@@ -6358,10 +6350,7 @@ void dplane_provider_enqueue_out_ctx(struct zebra_dplane_provider *prov,
63586350
dplane_ctx_list_add_tail(&(prov->dp_ctx_out_list), ctx);
63596351

63606352
/* Maintain out-queue counters */
6361-
atomic_fetch_add_explicit(&(prov->dp_out_queued), 1,
6362-
memory_order_relaxed);
6363-
curr = atomic_load_explicit(&prov->dp_out_queued,
6364-
memory_order_relaxed);
6353+
curr = dplane_ctx_queue_count(&prov->dp_ctx_out_list);
63656354
high = atomic_load_explicit(&prov->dp_out_max,
63666355
memory_order_relaxed);
63676356
if (curr > high)
@@ -6383,9 +6372,6 @@ dplane_provider_dequeue_out_ctx(struct zebra_dplane_provider *prov)
63836372
if (!ctx)
63846373
return NULL;
63856374

6386-
atomic_fetch_sub_explicit(&(prov->dp_out_queued), 1,
6387-
memory_order_relaxed);
6388-
63896375
return ctx;
63906376
}
63916377

@@ -7422,10 +7408,7 @@ static void dplane_thread_loop(struct event *event)
74227408

74237409
atomic_fetch_add_explicit(&prov->dp_in_counter, counter,
74247410
memory_order_relaxed);
7425-
atomic_fetch_add_explicit(&prov->dp_in_queued, counter,
7426-
memory_order_relaxed);
7427-
curr = atomic_load_explicit(&prov->dp_in_queued,
7428-
memory_order_relaxed);
7411+
curr = dplane_ctx_queue_count(&prov->dp_ctx_in_list);
74297412
high = atomic_load_explicit(&prov->dp_in_max,
74307413
memory_order_relaxed);
74317414
if (curr > high)

0 commit comments

Comments
 (0)