[v2,09/12] examples/l2fwd: skip timer updates for non master cores

Message ID 1531289248-20025-10-git-send-email-anoob.joseph@caviumnetworks.com
State New
Delegated to: Thomas Monjalon
Headers show
Series
  • preparing l2fwd for eventmode additions
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Anoob Joseph July 11, 2018, 6:07 a.m.
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@caviumnetworks.com>
---
v2:
* No change

v1:
* No change

 examples/l2fwd/l2fwd_worker.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

Patch

diff --git a/examples/l2fwd/l2fwd_worker.c b/examples/l2fwd/l2fwd_worker.c
index 868d0c6..d6a5e90 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;
 	}
 }