[dpdk-dev] [PATCH 12/15] examples/l2fwd: skip timer updates for non master cores

Anoob Joseph anoob.joseph at caviumnetworks.com
Fri Jun 8 19:09:23 CEST 2018


The timer updates and checks are required only for stats printing by the
master core. This can be entirely skipped for other cores.

Signed-off-by: Anoob Joseph <anoob.joseph at caviumnetworks.com>
---
 examples/l2fwd/l2fwd_worker.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/examples/l2fwd/l2fwd_worker.c b/examples/l2fwd/l2fwd_worker.c
index 231b849..9ba78f6 100644
--- a/examples/l2fwd/l2fwd_worker.c
+++ b/examples/l2fwd/l2fwd_worker.c
@@ -111,6 +111,14 @@ l2fwd_periodic_drain_stats_monitor(struct lcore_queue_conf *qconf,
 		/* Drain buffers */
 		l2fwd_drain_buffers(qconf);
 
+		t->prev_tsc = cur_tsc;
+
+		/* Skip the timer based stats prints if not master core */
+		if (!is_master_core)
+			return;
+
+		/* On master core */
+
 		/* if timer is enabled */
 		if (timer_period > 0) {
 
@@ -120,16 +128,13 @@ l2fwd_periodic_drain_stats_monitor(struct lcore_queue_conf *qconf,
 			/* if timer has reached its timeout */
 			if (unlikely(t->timer_tsc >= timer_period)) {
 
-				/* do this only on master core */
-				if (is_master_core) {
-					print_stats();
-					/* reset the timer */
-					t->timer_tsc = 0;
-				}
+				/* Print stats */
+				print_stats();
+
+				/* reset the timer */
+				t->timer_tsc = 0;
 			}
 		}
-
-		t->prev_tsc = cur_tsc;
 	}
 }
 
-- 
2.7.4



More information about the dev mailing list