All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net] net: allow alloc_skb_with_frags() to use MAX_SKB_FRAGS
@ 2025-09-22 19:19 Jason Baron
  2025-09-22 19:57 ` Eric Dumazet
  2025-09-24  0:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jason Baron @ 2025-09-22 19:19 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni; +Cc: netdev

Currently, alloc_skb_with_frags() will only fill (MAX_SKB_FRAGS - 1)
slots. I think it should use all MAX_SKB_FRAGS slots, as callers of
alloc_skb_with_frags() will size their allocation of frags based
on MAX_SKB_FRAGS.

This issue was discovered via a test patch that sets 'order' to 0
in alloc_skb_with_frags(), which effectively tests/simulates high
fragmentation. In this case sendmsg() on unix sockets will fail every
time for large allocations. If the PAGE_SIZE is 4K, then data_len will
request 68K or 17 pages, but alloc_skb_with_frags() can only allocate
64K in this case or 16 pages.

Fixes: 09c2c90705bb ("net: allow alloc_skb_with_frags() to allocate bigger packets")
Signed-off-by: Jason Baron <jbaron@akamai.com>
---
Changes:
v2: Add Fixes: tag
---
 net/core/skbuff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 23b776cd9879..df942aca0617 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -6669,7 +6669,7 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
 		return NULL;
 
 	while (data_len) {
-		if (nr_frags == MAX_SKB_FRAGS - 1)
+		if (nr_frags == MAX_SKB_FRAGS)
 			goto failure;
 		while (order && PAGE_ALIGN(data_len) < (PAGE_SIZE << order))
 			order--;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 net] net: allow alloc_skb_with_frags() to use MAX_SKB_FRAGS
  2025-09-22 19:19 [PATCH v2 net] net: allow alloc_skb_with_frags() to use MAX_SKB_FRAGS Jason Baron
@ 2025-09-22 19:57 ` Eric Dumazet
  2025-09-24  0:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2025-09-22 19:57 UTC (permalink / raw)
  To: Jason Baron; +Cc: davem, kuba, pabeni, netdev

On Mon, Sep 22, 2025 at 12:20 PM Jason Baron <jbaron@akamai.com> wrote:
>
> Currently, alloc_skb_with_frags() will only fill (MAX_SKB_FRAGS - 1)
> slots. I think it should use all MAX_SKB_FRAGS slots, as callers of
> alloc_skb_with_frags() will size their allocation of frags based
> on MAX_SKB_FRAGS.
>
> This issue was discovered via a test patch that sets 'order' to 0
> in alloc_skb_with_frags(), which effectively tests/simulates high
> fragmentation. In this case sendmsg() on unix sockets will fail every
> time for large allocations. If the PAGE_SIZE is 4K, then data_len will
> request 68K or 17 pages, but alloc_skb_with_frags() can only allocate
> 64K in this case or 16 pages.
>
> Fixes: 09c2c90705bb ("net: allow alloc_skb_with_frags() to allocate bigger packets")
> Signed-off-by: Jason Baron <jbaron@akamai.com>
> ---
> Changes:
> v2: Add Fixes: tag

Reviewed-by: Eric Dumazet <edumazet@google.com>

Thanks Jason !

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 net] net: allow alloc_skb_with_frags() to use MAX_SKB_FRAGS
  2025-09-22 19:19 [PATCH v2 net] net: allow alloc_skb_with_frags() to use MAX_SKB_FRAGS Jason Baron
  2025-09-22 19:57 ` Eric Dumazet
@ 2025-09-24  0:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-24  0:00 UTC (permalink / raw)
  To: Jason Baron; +Cc: davem, edumazet, kuba, pabeni, netdev

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 22 Sep 2025 15:19:57 -0400 you wrote:
> Currently, alloc_skb_with_frags() will only fill (MAX_SKB_FRAGS - 1)
> slots. I think it should use all MAX_SKB_FRAGS slots, as callers of
> alloc_skb_with_frags() will size their allocation of frags based
> on MAX_SKB_FRAGS.
> 
> This issue was discovered via a test patch that sets 'order' to 0
> in alloc_skb_with_frags(), which effectively tests/simulates high
> fragmentation. In this case sendmsg() on unix sockets will fail every
> time for large allocations. If the PAGE_SIZE is 4K, then data_len will
> request 68K or 17 pages, but alloc_skb_with_frags() can only allocate
> 64K in this case or 16 pages.
> 
> [...]

Here is the summary with links:
  - [v2,net] net: allow alloc_skb_with_frags() to use MAX_SKB_FRAGS
    https://git.kernel.org/netdev/net/c/ca9f9cdc4de9

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-24  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 19:19 [PATCH v2 net] net: allow alloc_skb_with_frags() to use MAX_SKB_FRAGS Jason Baron
2025-09-22 19:57 ` Eric Dumazet
2025-09-24  0:00 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.