[dpdk-dev] [PATCH 08/39] examples/l2fwd-event: optimize check for master core

Anoob Joseph anoobj at marvell.com
Mon Jun 3 19:32:08 CEST 2019


Replacing the check for lcore_id & mastercore_id with the check for a
flag.

Signed-off-by: Anoob Joseph <anoobj at marvell.com>
Signed-off-by: Lukasz Bartosik <lbartosik at marvell.com>
---
 examples/l2fwd-event/l2fwd_worker.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/examples/l2fwd-event/l2fwd_worker.c b/examples/l2fwd-event/l2fwd_worker.c
index ebce5c1..86bdd40 100644
--- a/examples/l2fwd-event/l2fwd_worker.c
+++ b/examples/l2fwd-event/l2fwd_worker.c
@@ -140,6 +140,7 @@ l2fwd_main_loop(void)
 	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,6 +163,9 @@ l2fwd_main_loop(void)
 
 	}
 
+	/* Set the flag if master core */
+	is_master_core = (lcore_id == rte_get_master_lcore()) ? 1 : 0;
+
 	while (!force_quit) {
 
 		cur_tsc = rte_rdtsc();
@@ -185,8 +189,7 @@ l2fwd_main_loop(void)
 				if (unlikely(timer_tsc >= timer_period)) {
 
 					/* do this only on master core */
-					if (lcore_id ==
-					    rte_get_master_lcore()) {
+					if (is_master_core) {
 						print_stats();
 						/* reset the timer */
 						timer_tsc = 0;
-- 
2.7.4



More information about the dev mailing list