lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  9 Mar 2023 01:26:18 +0900
From:   Leesoo Ahn <lsahn@...eel.net>
To:     lsahn@...eel.net
Cc:     Giuseppe Cavallaro <peppe.cavallaro@...com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Jose Abreu <joabreu@...opsys.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Jesper Dangaard Brouer <hawk@...nel.org>,
        John Fastabend <john.fastabend@...il.com>,
        netdev@...r.kernel.org, linux-stm32@...md-mailman.stormreply.com,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        bpf@...r.kernel.org
Subject: [PATCH net-next] net: stmmac: call stmmac_finalize_xdp_rx() on a condition

The current codebase calls the function no matter net device has XDP
programs or not. So the finalize function is being called everytime when RX
bottom-half in progress. It needs a few machine instructions for nothing
in the case that XDP programs are not attached at all.

Lets it call the function on a condition that if xdp_status variable has
not zero value. That means XDP programs are attached to the net device
and it should be finalized based on the variable.

The following instructions show that it's better than calling the function
unconditionally.

  0.31 │6b8:   ldr     w0, [sp, #196]
       │    ┌──cbz     w0, 6cc
       │    │  mov     x1, x0
       │    │  mov     x0, x27
       │    │→ bl     stmmac_finalize_xdp_rx
       │6cc:└─→ldr    x1, [sp, #176]

with 'if (xdp_status)' statement, jump to '6cc' label if xdp_status has
zero value.

Signed-off-by: Leesoo Ahn <lsahn@...eel.net>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index e4902a7bb61e..53c6e9b3a0c2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5145,7 +5145,8 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
 		rx_q->state.len = len;
 	}
 
-	stmmac_finalize_xdp_rx(priv, xdp_status);
+	if (xdp_status)
+		stmmac_finalize_xdp_rx(priv, xdp_status);
 
 	priv->xstats.rx_pkt_n += count;
 	priv->xstats.rxq_stats[queue].rx_pkt_n += count;
@@ -5425,7 +5426,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 		rx_q->state.len = len;
 	}
 
-	stmmac_finalize_xdp_rx(priv, xdp_status);
+	if (xdp_status)
+		stmmac_finalize_xdp_rx(priv, xdp_status);
 
 	stmmac_rx_refill(priv, queue);
 
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ