[v2,07/12] examples/l2fwd: optimize check for master core

Message ID 1531289248-20025-8-git-send-email-anoob.joseph@caviumnetworks.com
State Rejected
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.
Replacing the check for lcore_id & mastercore_id with the check for a
flag.

Signed-off-by: Anoob Joseph <anoob.joseph@caviumnetworks.com>
---
v2:
* No change

v1:
* Replaced 'unsigned' with 'unsigned int'

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

Patch

diff --git a/examples/l2fwd/l2fwd_worker.c b/examples/l2fwd/l2fwd_worker.c
index dfa78ed..f847832 100644
--- a/examples/l2fwd/l2fwd_worker.c
+++ b/examples/l2fwd/l2fwd_worker.c
@@ -135,12 +135,12 @@  l2fwd_main_loop(void)
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	struct rte_mbuf *m;
 	unsigned int lcore_id;
-	unsigned int master_core_id;
 	uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc;
 	unsigned int i, j, portid, nb_rx;
 	struct lcore_queue_conf *qconf;
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1)
 			/ US_PER_S * BURST_TX_DRAIN_US;
+	int is_master_core;
 
 	prev_tsc = 0;
 	timer_tsc = 0;
@@ -162,8 +162,8 @@  l2fwd_main_loop(void)
 			portid);
 
 	}
-
-	master_core_id = rte_get_master_lcore();
+	/* Set the flag if master core */
+	is_master_core = (lcore_id == rte_get_master_lcore()) ? 1 : 0;
 
 	while (!force_quit) {
 
@@ -188,7 +188,7 @@  l2fwd_main_loop(void)
 				if (unlikely(timer_tsc >= timer_period)) {
 
 					/* do this only on master core */
-					if (lcore_id == master_core_id) {
+					if (is_master_core) {
 						print_stats();
 						/* reset the timer */
 						timer_tsc = 0;