@@ -136,8 +136,6 @@ struct fpm_nl_ctx {
136
136
137
137
/* Amount of data plane context processed. */
138
138
_Atomic uint32_t dplane_contexts ;
139
- /* Amount of data plane contexts enqueued. */
140
- _Atomic uint32_t ctxqueue_len ;
141
139
/* Peak amount of data plane contexts enqueued. */
142
140
_Atomic uint32_t ctxqueue_len_peak ;
143
141
@@ -399,6 +397,12 @@ DEFUN(fpm_show_counters, fpm_show_counters_cmd,
399
397
FPM_STR
400
398
"FPM statistic counters\n" )
401
399
{
400
+ uint32_t curr_queue_len ;
401
+
402
+ frr_with_mutex (& gfnc -> ctxqueue_mutex ) {
403
+ curr_queue_len = dplane_ctx_queue_count (& gfnc -> ctxqueue );
404
+ }
405
+
402
406
vty_out (vty , "%30s\n%30s\n" , "FPM counters" , "============" );
403
407
404
408
#define SHOW_COUNTER (label , counter ) \
@@ -412,8 +416,7 @@ DEFUN(fpm_show_counters, fpm_show_counters_cmd,
412
416
SHOW_COUNTER ("Connection errors" , gfnc -> counters .connection_errors );
413
417
SHOW_COUNTER ("Data plane items processed" ,
414
418
gfnc -> counters .dplane_contexts );
415
- SHOW_COUNTER ("Data plane items enqueued" ,
416
- gfnc -> counters .ctxqueue_len );
419
+ SHOW_COUNTER ("Data plane items enqueued" , curr_queue_len );
417
420
SHOW_COUNTER ("Data plane items queue peak" ,
418
421
gfnc -> counters .ctxqueue_len_peak );
419
422
SHOW_COUNTER ("Buffer full hits" , gfnc -> counters .buffer_full );
@@ -432,6 +435,12 @@ DEFUN(fpm_show_counters_json, fpm_show_counters_json_cmd,
432
435
"FPM statistic counters\n"
433
436
JSON_STR )
434
437
{
438
+ uint32_t curr_queue_len ;
439
+
440
+ frr_with_mutex (& gfnc -> ctxqueue_mutex ) {
441
+ curr_queue_len = dplane_ctx_queue_count (& gfnc -> ctxqueue );
442
+ }
443
+
435
444
struct json_object * jo ;
436
445
437
446
jo = json_object_new_object ();
@@ -445,8 +454,7 @@ DEFUN(fpm_show_counters_json, fpm_show_counters_json_cmd,
445
454
gfnc -> counters .connection_errors );
446
455
json_object_int_add (jo , "data-plane-contexts" ,
447
456
gfnc -> counters .dplane_contexts );
448
- json_object_int_add (jo , "data-plane-contexts-queue" ,
449
- gfnc -> counters .ctxqueue_len );
457
+ json_object_int_add (jo , "data-plane-contexts-queue" , curr_queue_len );
450
458
json_object_int_add (jo , "data-plane-contexts-queue-peak" ,
451
459
gfnc -> counters .ctxqueue_len_peak );
452
460
json_object_int_add (jo , "buffer-full-hits" , gfnc -> counters .buffer_full );
@@ -1495,8 +1503,6 @@ static void fpm_process_queue(struct event *t)
1495
1503
1496
1504
/* Account the processed entries. */
1497
1505
processed_contexts ++ ;
1498
- atomic_fetch_sub_explicit (& fnc -> counters .ctxqueue_len , 1 ,
1499
- memory_order_relaxed );
1500
1506
1501
1507
dplane_ctx_set_status (ctx , ZEBRA_DPLANE_REQUEST_SUCCESS );
1502
1508
dplane_provider_enqueue_out_ctx (fnc -> prov , ctx );
@@ -1670,7 +1676,7 @@ static int fpm_nl_process(struct zebra_dplane_provider *prov)
1670
1676
struct zebra_dplane_ctx * ctx ;
1671
1677
struct fpm_nl_ctx * fnc ;
1672
1678
int counter , limit ;
1673
- uint64_t cur_queue , peak_queue = 0 , stored_peak_queue ;
1679
+ uint64_t cur_queue = 0 , peak_queue = 0 , stored_peak_queue ;
1674
1680
1675
1681
fnc = dplane_provider_get_data (prov );
1676
1682
limit = dplane_provider_get_work_limit (prov );
@@ -1684,20 +1690,12 @@ static int fpm_nl_process(struct zebra_dplane_provider *prov)
1684
1690
* anyway.
1685
1691
*/
1686
1692
if (fnc -> socket != -1 && fnc -> connecting == false) {
1687
- /*
1688
- * Update the number of queued contexts *before*
1689
- * enqueueing, to ensure counter consistency.
1690
- */
1691
- atomic_fetch_add_explicit (& fnc -> counters .ctxqueue_len ,
1692
- 1 , memory_order_relaxed );
1693
-
1694
1693
frr_with_mutex (& fnc -> ctxqueue_mutex ) {
1695
1694
dplane_ctx_enqueue_tail (& fnc -> ctxqueue , ctx );
1695
+ cur_queue =
1696
+ dplane_ctx_queue_count (& fnc -> ctxqueue );
1696
1697
}
1697
1698
1698
- cur_queue = atomic_load_explicit (
1699
- & fnc -> counters .ctxqueue_len ,
1700
- memory_order_relaxed );
1701
1699
if (peak_queue < cur_queue )
1702
1700
peak_queue = cur_queue ;
1703
1701
continue ;
@@ -1714,9 +1712,7 @@ static int fpm_nl_process(struct zebra_dplane_provider *prov)
1714
1712
atomic_store_explicit (& fnc -> counters .ctxqueue_len_peak ,
1715
1713
peak_queue , memory_order_relaxed );
1716
1714
1717
- if (atomic_load_explicit (& fnc -> counters .ctxqueue_len ,
1718
- memory_order_relaxed )
1719
- > 0 )
1715
+ if (cur_queue > 0 )
1720
1716
event_add_event (fnc -> fthread -> master , fpm_process_queue , fnc , 0 ,
1721
1717
& fnc -> t_dequeue );
1722
1718
0 commit comments