diff mbox series

examples/l3fwd: remove useless reloads in EM main loop

Message ID 20210706115755.1011721-1-conor.walsh@intel.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers show
Series examples/l3fwd: remove useless reloads in EM main loop | expand

Checks

Context Check Description
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

Conor Walsh July 6, 2021, 11:57 a.m. UTC
This patch aligns the l3fwd EM code with the changes made to LPM in
commit 74fb854a3de6 ("examples/l3fwd: remove useless reloads in LPM
main loop").
This change ensures the compiler knows that the lcore config variables
are constant values and the compiler will then optimize the code
accordingly.

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
---
 examples/l3fwd/l3fwd_em.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Ruifeng Wang July 7, 2021, 5:20 a.m. UTC | #1
> -----Original Message-----
> From: Conor Walsh <conor.walsh@intel.com>
> Sent: Tuesday, July 6, 2021 7:58 PM
> To: david.marchand@redhat.com; konstantin.ananyev@intel.com;
> vladimir.medvedkin@intel.com; Ruifeng Wang <Ruifeng.Wang@arm.com>;
> jerinj@marvell.com
> Cc: dev@dpdk.org; paulis.gributs@intel.com; Conor Walsh
> <conor.walsh@intel.com>
> Subject: [PATCH] examples/l3fwd: remove useless reloads in EM main loop
> 
> This patch aligns the l3fwd EM code with the changes made to LPM in commit
> 74fb854a3de6 ("examples/l3fwd: remove useless reloads in LPM main loop").
> This change ensures the compiler knows that the lcore config variables are
> constant values and the compiler will then optimize the code accordingly.
> 
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> ---
>  examples/l3fwd/l3fwd_em.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
David Marchand July 7, 2021, 6:20 a.m. UTC | #2
On Tue, Jul 6, 2021 at 1:58 PM Conor Walsh <conor.walsh@intel.com> wrote:
>
> This patch aligns the l3fwd EM code with the changes made to LPM in
> commit 74fb854a3de6 ("examples/l3fwd: remove useless reloads in LPM
> main loop").
> This change ensures the compiler knows that the lcore config variables
> are constant values and the compiler will then optimize the code
> accordingly.
>
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>
David Marchand July 7, 2021, 9:57 a.m. UTC | #3
On Tue, Jul 6, 2021 at 1:58 PM Conor Walsh <conor.walsh@intel.com> wrote:
>
> This patch aligns the l3fwd EM code with the changes made to LPM in
> commit 74fb854a3de6 ("examples/l3fwd: remove useless reloads in LPM
> main loop").
> This change ensures the compiler knows that the lcore config variables
> are constant values and the compiler will then optimize the code
> accordingly.
>
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>

Applied, thanks.
diff mbox series

Patch

diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c
index 01f8dff485..43fc7612e7 100644
--- a/examples/l3fwd/l3fwd_em.c
+++ b/examples/l3fwd/l3fwd_em.c
@@ -632,14 +632,16 @@  em_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;
@@ -659,7 +661,7 @@  em_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;
@@ -675,7 +677,7 @@  em_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,