From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3DEF5A034F; Sun, 6 Jun 2021 20:39:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B42BE40147; Sun, 6 Jun 2021 20:39:34 +0200 (CEST) Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by mails.dpdk.org (Postfix) with ESMTP id 0AFF940040 for ; Sun, 6 Jun 2021 20:39:32 +0200 (CEST) Received: by mail-il1-f177.google.com with SMTP id i17so14015834ilj.11 for ; Sun, 06 Jun 2021 11:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WIBGVAX2/H17l+c7Ilb5hSjO5NyhkwVM+KCWAolbORA=; b=sYkwAgrVecUEqeINuBtGLxjXSmTzjpD887bmqPy26LfDIbhJspgjTLUO/e3FARnixh T8GqBKgc5SlIizYmtqb2syqT4RY7/i5+6PtzbcJeBI54FZXazjGBsPXgWXGKo+ltHxnH C7xJ3BS42i5HT3kUC8zsQUH13Ho+1mR5PaW8A56H7QF/s4UbBzs/1KEyXLMrehiZ/i41 QuDaD350xjwvTKRbuYmKeJlncv415oNwDzcE8fzLIa3GdDpj8lVF55tgcwNIlRGifMhT JaS2i+V9QRC0llfqqMjRS/gbQqH5VAWqT4ZzCULoWAtSFdjRLmdFTDvEVhS+mwmp1dii ITuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WIBGVAX2/H17l+c7Ilb5hSjO5NyhkwVM+KCWAolbORA=; b=K9BcLxctftsECYawQi3NlLWu14XNnucgrrt8lXDQZMhJWm5HolmHg7tVhOGdSSeKzc FRagvg7q8LI253hUkTt3ZemcWvIBRLet1LvUIqBDLxd+F//aWC8zKOa36EWA/luNfhlN y4kR4tAY6deIM5I5KJb16LBNctgaobfEcq8H+mNCh8/pB1Y9PgXApi6fOcNmiMWBy5Iu w/fxT7i81rodvPU1Lft5vbtQ8KAKRNW4a45bNRT76S5YyV4a4BRohEX6xCPr3+gtyFev yCE06tJQj0IOvkWgG0HsY3/CP4PJGB0qMfdMVdgjFUZtDc1NvEs12juQlF6bNimciAzF 42Cg== X-Gm-Message-State: AOAM533yAGkM9EkyDPpUM3qB2hIwl3B6m69GVHA66XqBng7uNQoON+y9 t5YqXYfyETbSH3Mu3olGT4xLp66NJYEDK0/gU2A= X-Google-Smtp-Source: ABdhPJwQQnFKUfzTm7eOQx6p4kvoZYEL5hWfgMeIGthIpZLS/NwHGSpHGgCbG+5GXPERK+HIBX8bc3YFNjUiMqVApBU= X-Received: by 2002:a92:1310:: with SMTP id 16mr13082875ilt.60.1623004772315; Sun, 06 Jun 2021 11:39:32 -0700 (PDT) MIME-Version: 1.0 References: <20210318102550.59265-1-ruifeng.wang@arm.com> <20210601075653.84927-1-ruifeng.wang@arm.com> <20210601075653.84927-4-ruifeng.wang@arm.com> In-Reply-To: <20210601075653.84927-4-ruifeng.wang@arm.com> From: Jerin Jacob Date: Mon, 7 Jun 2021 00:09:16 +0530 Message-ID: To: Ruifeng Wang Cc: Jerin Jacob , Hemant Agrawal , Ferruh Yigit , Thomas Monjalon , David Marchand , dpdk-dev , nd , Honnappa Nagarahalli , Ola Liljedahl Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v2 3/3] examples/l3fwd: eliminate unnecessary reloads in loop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Jun 1, 2021 at 1:27 PM Ruifeng Wang 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. > > Signed-off-by: Ruifeng Wang > Reviewed-by: Ola Liljedahl > Reviewed-by: Honnappa Nagarahalli No performance regression with octeontx2. Acked-by: Jerin Jacob > --- > 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 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, > -- > 2.25.1 >