From: Rakesh Kudurumalla <[email protected]>
Race condition between jobstats and time metrics
for forwarding and flushing is maintained using spinlock.
Timer metrics are not displayed properly due to the
frequent unavailability of the lock.
This patch fixes the issue by introducing a delay before
acquiring the lock in the loop. This delay allows for better
availability of the lock, ensuring that show_lcore_stats() can
periodically update the statistics even when forwarding
jobs are running.
Fixes: 204896f8d66c ("examples/l2fwd-jobstats: add new example")
Cc: [email protected]
Signed-off-by: Rakesh Kudurumalla <[email protected]>
---
examples/l2fwd-jobstats/main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index a7cd5b4840..036bd4f951 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -541,7 +541,9 @@ l2fwd_main_loop(void)
} while (likely(stats_read_pending == 0));
rte_spinlock_unlock(&qconf->lock);
- rte_pause();
+ while (rte_atomic_load_explicit(&qconf->stats_read_pending,
+ rte_memory_order_relaxed) != 0)
+ rte_pause();
}
/* >8 End of minimize impact of stats reading. */
}
--
2.25.1