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>] [day] [month] [year] [list]
Message-Id: <20220630062453.2530477-1-david.wu@rock-chips.com>
Date:   Thu, 30 Jun 2022 14:24:53 +0800
From:   David Wu <david.wu@...k-chips.com>
To:     joabreu@...opsys.com, mcoquelin.stm32@...il.com,
        alexandre.torgue@...s.st.com, davem@...emloft.net
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        David Wu <david.wu@...k-chips.com>
Subject: [PATCH RFC net-next] net: stmmac: Reduce the memory copy for rx data

Use skb_add_rx_frag() to reduce the memory copy for rx data, only copy
ethernet header.

Signed-off-by: David Wu <david.wu@...k-chips.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index d1a7cf4567bc..ac8d92ec35c0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5226,7 +5226,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 			/* XDP program may expand or reduce tail */
 			buf1_len = xdp.data_end - xdp.data;
 
-			skb = napi_alloc_skb(&ch->rx_napi, buf1_len);
+			skb = napi_alloc_skb(&ch->rx_napi, ETH_HLEN);
 			if (!skb) {
 				priv->dev->stats.rx_dropped++;
 				count++;
@@ -5234,11 +5234,15 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
 			}
 
 			/* XDP program may adjust header */
-			skb_copy_to_linear_data(skb, xdp.data, buf1_len);
-			skb_put(skb, buf1_len);
+			memcpy(skb->data, xdp.data, ETH_HLEN);
+			skb_put(skb, ETH_HLEN);
+			skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
+					buf->page, buf->page_offset + ETH_HLEN,
+					buf1_len - ETH_HLEN,
+					priv->dma_buf_sz);
 
-			/* Data payload copied into SKB, page ready for recycle */
-			page_pool_recycle_direct(rx_q->page_pool, buf->page);
+			/* Data payload appended into SKB */
+			page_pool_release_page(rx_q->page_pool, buf->page);
 			buf->page = NULL;
 		} else if (buf1_len) {
 			dma_sync_single_for_cpu(priv->device, buf->addr,
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ