[dpdk-dev] [PATCH 10/15] examples/l2fwd: optimize check for master core
Anoob Joseph
anoob.joseph at caviumnetworks.com
Fri Jun 8 19:09:21 CEST 2018
Replacing the check for lcore_id & mastercore_id with the check for a
flag.
Signed-off-by: Anoob Joseph <anoob.joseph at caviumnetworks.com>
---
examples/l2fwd/l2fwd_worker.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/examples/l2fwd/l2fwd_worker.c b/examples/l2fwd/l2fwd_worker.c
index ee2de58..f73de82 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 lcore_id;
- unsigned master_core_id;
uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc;
unsigned 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;
--
2.7.4
More information about the dev
mailing list