examples/l3fwd: remove useless reloads in FIB main loop
PATCH 1/1 examples/l3fwd: remove useless reloads in FIB main loop
This patch aligns the l3fwd FIB 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.
--- examples/l3fwd/l3fwd_fib.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
examples/l3fwd/l3fwd_fib.c +6 -4
@@ -182,14 +182,16 @@ fib_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;
@@ -207,7 +209,7 @@ fib_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 ;
@@ -221,7 +223,7 @@ fib_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,
Signature · 1 line
2.25.1
Quoted 47 lines
This patch aligns the l3fwd FIB 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 <[email protected]>--- examples/l3fwd/l3fwd_fib.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)examples/l3fwd/l3fwd_fib.c +5
-3@@ -182,14 +182,16 @@ fib_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;@@ -207,7 +209,7 @@ fib_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 ;
examples/l3fwd/l3fwd_fib.c fib_main_loop(__rte_unused void *dummy)
Quoted 9 lines
examples/l3fwd/l3fwd_fib.c +1
-2@@ -221,7 +223,7 @@ fib_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, --
Quoted 1 line
2.25.1
Quoted 14 lines
-----Original Message-----
From: Conor Walsh <[email protected]>
Sent: Tuesday, July 6, 2021 1:06 AM
To: [email protected]; [email protected]; Ruifeng Wang <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Conor Walsh <[email protected]>
Subject: [PATCH] examples/l3fwd: remove useless reloads in FIB main loopThis patch aligns the l3fwd FIB 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.
Quoted 5 lines
Signed-off-by Conor Walsh <[email protected]>--- examples/l3fwd/l3fwd_fib.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Quoted 7 lines · Conor Walsh
This patch aligns the l3fwd FIB 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.
em can undergo the same change too.
Can you send a followup patch and I would take them both for rc1?
Thanks.
Quoted 2 lines
Signed-off-by Conor Walsh <[email protected]>
Signature · 1 line
David Marchand
Quoted 9 lines
Quoted 6 lines
This patch aligns the l3fwd FIB 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.em can undergo the same change too.
Can you send a followup patch and I would take them both for rc1?
Thanks! I will send a patch for em now
/Conor.
Quoted 8 lines
Thanks.
Quoted 2 lines
Signed-off-by Conor Walsh <[email protected]>--
David Marchand
Quoted 9 lines · Conor Walsh
This patch aligns the l3fwd FIB 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 <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand