From: Ruifeng Wang Date: Thu, 10 Jun 2021 06:57:40 +0000 (+0000) Subject: examples/l3fwd: remove useless reloads in LPM main loop X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=74fb854a3de6899f1846c2e929462d830cf04d83;p=dpdk.git examples/l3fwd: remove useless reloads in LPM main loop Number of rx queue and number of rx port in lcore config are constants during the period of l3 forward application running. But compiler has no this information. Copied values from lcore config to local variables and used the local variables for iteration. Compiler can see that the local variables are not changed, so qconf reloads at each iteration can be eliminated. The change showed 1.8% performance uplift in single core, single port, single queue test on N1SDP platform with MLX5 NIC. Signed-off-by: Ruifeng Wang Acked-by: Jerin Jacob --- diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index 427c72b1d2..ff1c18a442 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -154,14 +154,16 @@ lpm_main_loop(__rte_unused void *dummy) lcore_id = rte_lcore_id(); qconf = &lcore_conf[lcore_id]; - if (qconf->n_rx_queue == 0) { + const uint16_t n_rx_q = qconf->n_rx_queue; + const uint16_t n_tx_p = qconf->n_tx_port; + if (n_rx_q == 0) { RTE_LOG(INFO, L3FWD, "lcore %u has nothing to do\n", lcore_id); return 0; } RTE_LOG(INFO, L3FWD, "entering main loop on lcore %u\n", lcore_id); - for (i = 0; i < qconf->n_rx_queue; i++) { + for (i = 0; i < n_rx_q; i++) { portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; @@ -181,7 +183,7 @@ lpm_main_loop(__rte_unused void *dummy) diff_tsc = cur_tsc - prev_tsc; if (unlikely(diff_tsc > drain_tsc)) { - for (i = 0; i < qconf->n_tx_port; ++i) { + for (i = 0; i < n_tx_p; ++i) { portid = qconf->tx_port_id[i]; if (qconf->tx_mbufs[portid].len == 0) continue; @@ -197,7 +199,7 @@ lpm_main_loop(__rte_unused void *dummy) /* * Read packet from RX queues */ - for (i = 0; i < qconf->n_rx_queue; ++i) { + for (i = 0; i < n_rx_q; ++i) { portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,