Skip to contentSkip to conversation

Couple of minor improvements to build_skb variants

PATCH Applied Gal Pressman 3 participants 6 messages Mar 8, 2023 – Mar 11, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Couple of minor improvements to build_skb variants

First patch replaces open-coded occurrences of skb_propagate_pfmemalloc() in build_skb() and build_skb_around(). The secnod patch adds a likely() to the skb allocation in build_skb().

Changelog -
v1->v2: https://lore.kernel.org/netdev/[email protected]/
* Add 'frag_size' into the likely call

Thanks

Gal Pressman (2):
skbuff: Replace open-coded skb_propagate_pfmemalloc()s
skbuff: Add likely to skb pointer in build_skb()

 net/core/skbuff.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
Signature · 1 line
2.39.1
#1 lore raw

PATCH v2 1/2 skbuff: Replace open-coded skb_propagate_pfmemalloc()s

Use skb_propagate_pfmemalloc() in build_skb()/build_skb_around() instead of open-coding it.

---
 net/core/skbuff.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/core/skbuff.c +2 -4
index eb7d33b41e71..5c1a65cc2f39 100644
@@ -422,8 +422,7 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
 
 	if (skb && frag_size) {
 		skb->head_frag = 1;
-		if (page_is_pfmemalloc(virt_to_head_page(data)))
-			skb->pfmemalloc = 1;
+		skb_propagate_pfmemalloc(virt_to_head_page(data), skb);
 	}
 	return skb;
 }
@@ -445,8 +444,7 @@ struct sk_buff *build_skb_around(struct sk_buff *skb,
 
 	if (frag_size) {
 		skb->head_frag = 1;
-		if (page_is_pfmemalloc(virt_to_head_page(data)))
-			skb->pfmemalloc = 1;
+		skb_propagate_pfmemalloc(virt_to_head_page(data), skb);
 	}
 	return skb;
 }
Signature · 1 line
2.39.1
#3 lore raw

PATCH v2 2/2 skbuff: Add likely to skb pointer in build_skb()

In reply to Gal Pressman

Similarly to napi_build_skb(), it is likely the skb allocation in build_skb() succeeded. frag_size != 0 is also likely, as stated in __build_skb_around().

---
 net/core/skbuff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/skbuff.c +1 -1
index 5c1a65cc2f39..34df1aa0584b 100644
@@ -420,7 +420,7 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
 {
 	struct sk_buff *skb = __build_skb(data, frag_size);
 
-	if (skb && frag_size) {
+	if (likely(skb && frag_size)) {
 		skb->head_frag = 1;
 		skb_propagate_pfmemalloc(virt_to_head_page(data), skb);
 	}
Signature · 1 line
2.39.1
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH net-next v2 2/2] skbuff: Add likely to skb pointer in build_skb()

Quoted 7 lines · Gal Pressman

Similarly to napi_build_skb(), it is likely the skb allocation in build_skb() succeeded. frag_size != 0 is also likely, as stated in __build_skb_around().

#5 lore raw
In reply to Gal Pressman
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 8 Mar 2023 15:17:18 +0200 you wrote:

First patch replaces open-coded occurrences of skb_propagate_pfmemalloc() in build_skb() and build_skb_around(). The secnod patch adds a likely() to the skb allocation in build_skb().

Changelog -
v1->v2: https://lore.kernel.org/netdev/[email protected]/
* Add 'frag_size' into the likely call

[...]

Here is the summary with links:
- [net-next,v2,1/2] skbuff: Replace open-coded skb_propagate_pfmemalloc()s

    https://git.kernel.org/netdev/net-next/c/566b6701d5df
  - [net-next,v2,2/2] skbuff: Add likely to skb pointer in build_skb()
    https://git.kernel.org/netdev/net-next/c/3c6401266f91

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html