[dpdk-dev] [PATCH 3/4] examples/l3fwd: eliminate unnecessary reloads in loop

Jerin Jacob jerinjacobk at gmail.com
Tue Apr 13 19:43:27 CEST 2021


On Thu, Mar 18, 2021 at 3:56 PM Ruifeng Wang <ruifeng.wang at arm.com> wrote:
>
> 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.

At least, in octeontx2, I dont see any performance improvement.
But change looks good. Please find below a comment.

>
> Signed-off-by: Ruifeng Wang <ruifeng.wang at arm.com>
> ---
>  examples/l3fwd/l3fwd_lpm.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c
> index 3dcf1fef1..d338590b9 100644
> --- a/examples/l3fwd/l3fwd_lpm.c
> +++ b/examples/l3fwd/l3fwd_lpm.c
> @@ -190,14 +190,16 @@ lpm_main_loop(__rte_unused void *dummy)
>         lcore_id = rte_lcore_id();
>         qconf = &lcore_conf[lcore_id];
>
> -       if (qconf->n_rx_queue == 0) {
> +       uint16_t n_rx_q = qconf->n_rx_queue;
> +       uint16_t n_tx_p = qconf->n_tx_port;

How about adding const?


More information about the dev mailing list