* [PATCH] netlink: avoid extra pskb_expand_head() in netlink_trim()
@ 2025-05-28 15:36 Dmitry Antipov
2025-05-29 0:43 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Antipov @ 2025-05-28 15:36 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, Dmitry Antipov
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@yandex.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] netlink: avoid extra pskb_expand_head() in netlink_trim()
2025-05-28 15:36 [PATCH] netlink: avoid extra pskb_expand_head() in netlink_trim() Dmitry Antipov
@ 2025-05-29 0:43 ` Jakub Kicinski
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2025-05-29 0:43 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Eric Dumazet, Paolo Abeni, Simon Horman, netdev
On Wed, 28 May 2025 18:36:28 +0300 Dmitry Antipov wrote:
> 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.
Looks fine, but it would be useful to add more info about the practical
scenario where this patch makes a difference.
Other than that - net-next is closed, please repost after the merge
window.
--
pw-bot: defer
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] netlink: avoid extra pskb_expand_head() in netlink_trim()
2025-06-06 7:41 [PATCH] net: core: avoid extra pskb_expand_head() when adjusting headroom Dmitry Antipov
@ 2025-06-06 7:41 ` Dmitry Antipov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Antipov @ 2025-06-06 7:41 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: netdev, Dmitry Antipov
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@yandex.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-06 7:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-28 15:36 [PATCH] netlink: avoid extra pskb_expand_head() in netlink_trim() Dmitry Antipov
2025-05-29 0:43 ` Jakub Kicinski
-- strict thread matches above, loose matches on Subject: below --
2025-06-06 7:41 [PATCH] net: core: avoid extra pskb_expand_head() when adjusting headroom Dmitry Antipov
2025-06-06 7:41 ` [PATCH] netlink: avoid extra pskb_expand_head() in netlink_trim() Dmitry Antipov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).