[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250528153628.249631-1-dmantipov@yandex.ru>
Date: Wed, 28 May 2025 18:36:28 +0300
From: Dmitry Antipov <dmantipov@...dex.ru>
To: Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>
Cc: netdev@...r.kernel.org,
Dmitry Antipov <dmantipov@...dex.ru>
Subject: [PATCH] netlink: avoid extra pskb_expand_head() in netlink_trim()
When 'netlink_trim()' processes shared skb, using 'skb_clone()' with
following 'pskb_expand_head()' looks suboptimal, and it's expected to
be a bit faster to do 'skb_copy_expand()' with desired tailroom instead.
Signed-off-by: Dmitry Antipov <dmantipov@...dex.ru>
---
net/netlink/af_netlink.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index e8972a857e51..efb360433339 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1285,11 +1285,15 @@ static struct sk_buff *netlink_trim(struct sk_buff *skb, gfp_t allocation)
return skb;
if (skb_shared(skb)) {
- struct sk_buff *nskb = skb_clone(skb, allocation);
+ struct sk_buff *nskb;
+
+ nskb = skb_copy_expand(skb, skb_headroom(skb),
+ skb_tailroom(skb) - delta,
+ allocation);
if (!nskb)
return skb;
consume_skb(skb);
- skb = nskb;
+ return nskb;
}
pskb_expand_head(skb, 0, -delta,
--
2.49.0
Powered by blists - more mailing lists