* [PATCH v4] tun: avoid high-order page allocation for packet header
@ 2023-08-09 16:47 Tahsin Erdogan
2023-08-10 3:37 ` Jason Wang
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Tahsin Erdogan @ 2023-08-09 16:47 UTC (permalink / raw)
To: Willem de Bruijn, Jason Wang, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Herbert Xu
Cc: Tahsin Erdogan, netdev, linux-kernel
When gso.hdr_len is zero and a packet is transmitted via write() or
writev(), all payload is treated as header which requires a contiguous
memory allocation. This allocation request is harder to satisfy, and may
even fail if there is enough fragmentation.
Note that sendmsg() code path limits the linear copy length, so this change
makes write()/writev() and sendmsg() paths more consistent.
Signed-off-by: Tahsin Erdogan <trdgn@amazon.com>
---
v4: updated commit message address comments from Willem
v3: rebase to latest net-next
v2: replace linear == 0 with !linear
v1: https://lore.kernel.org/all/20230726030936.1587269-1-trdgn@amazon.com/
drivers/net/tun.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 973b2fc74de3..62106464f1b9 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1523,7 +1523,7 @@ static struct sk_buff *tun_alloc_skb(struct tun_file *tfile,
int err;
/* Under a page? Don't bother with paged skb. */
- if (prepad + len < PAGE_SIZE || !linear)
+ if (prepad + len < PAGE_SIZE)
linear = len;
if (len - linear > MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
@@ -1840,6 +1840,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
*/
zerocopy = false;
} else {
+ if (!linear)
+ linear = min_t(size_t, good_linear, copylen);
+
skb = tun_alloc_skb(tfile, align, copylen, linear,
noblock);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4] tun: avoid high-order page allocation for packet header
2023-08-09 16:47 [PATCH v4] tun: avoid high-order page allocation for packet header Tahsin Erdogan
@ 2023-08-10 3:37 ` Jason Wang
2023-08-10 6:53 ` Eric Dumazet
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2023-08-10 3:37 UTC (permalink / raw)
To: Tahsin Erdogan
Cc: Willem de Bruijn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Herbert Xu, netdev, linux-kernel
On Thu, Aug 10, 2023 at 12:48 AM Tahsin Erdogan <trdgn@amazon.com> wrote:
>
> When gso.hdr_len is zero and a packet is transmitted via write() or
> writev(), all payload is treated as header which requires a contiguous
> memory allocation. This allocation request is harder to satisfy, and may
> even fail if there is enough fragmentation.
>
> Note that sendmsg() code path limits the linear copy length, so this change
> makes write()/writev() and sendmsg() paths more consistent.
>
> Signed-off-by: Tahsin Erdogan <trdgn@amazon.com>
> ---
> v4: updated commit message address comments from Willem
> v3: rebase to latest net-next
> v2: replace linear == 0 with !linear
> v1: https://lore.kernel.org/all/20230726030936.1587269-1-trdgn@amazon.com/
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] tun: avoid high-order page allocation for packet header
2023-08-09 16:47 [PATCH v4] tun: avoid high-order page allocation for packet header Tahsin Erdogan
2023-08-10 3:37 ` Jason Wang
@ 2023-08-10 6:53 ` Eric Dumazet
2023-08-10 14:04 ` Willem de Bruijn
2023-08-11 2:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2023-08-10 6:53 UTC (permalink / raw)
To: Tahsin Erdogan
Cc: Willem de Bruijn, Jason Wang, David S. Miller, Jakub Kicinski,
Paolo Abeni, Herbert Xu, netdev, linux-kernel
On Wed, Aug 9, 2023 at 6:48 PM Tahsin Erdogan <trdgn@amazon.com> wrote:
>
> When gso.hdr_len is zero and a packet is transmitted via write() or
> writev(), all payload is treated as header which requires a contiguous
> memory allocation. This allocation request is harder to satisfy, and may
> even fail if there is enough fragmentation.
>
> Note that sendmsg() code path limits the linear copy length, so this change
> makes write()/writev() and sendmsg() paths more consistent.
>
> Signed-off-by: Tahsin Erdogan <trdgn@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] tun: avoid high-order page allocation for packet header
2023-08-09 16:47 [PATCH v4] tun: avoid high-order page allocation for packet header Tahsin Erdogan
2023-08-10 3:37 ` Jason Wang
2023-08-10 6:53 ` Eric Dumazet
@ 2023-08-10 14:04 ` Willem de Bruijn
2023-08-11 2:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Willem de Bruijn @ 2023-08-10 14:04 UTC (permalink / raw)
To: Tahsin Erdogan, Willem de Bruijn, Jason Wang, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Herbert Xu
Cc: Tahsin Erdogan, netdev, linux-kernel
Tahsin Erdogan wrote:
> When gso.hdr_len is zero and a packet is transmitted via write() or
> writev(), all payload is treated as header which requires a contiguous
> memory allocation. This allocation request is harder to satisfy, and may
> even fail if there is enough fragmentation.
>
> Note that sendmsg() code path limits the linear copy length, so this change
> makes write()/writev() and sendmsg() paths more consistent.
>
> Signed-off-by: Tahsin Erdogan <trdgn@amazon.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4] tun: avoid high-order page allocation for packet header
2023-08-09 16:47 [PATCH v4] tun: avoid high-order page allocation for packet header Tahsin Erdogan
` (2 preceding siblings ...)
2023-08-10 14:04 ` Willem de Bruijn
@ 2023-08-11 2:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-11 2:40 UTC (permalink / raw)
To: Tahsin Erdogan
Cc: willemdebruijn.kernel, jasowang, davem, edumazet, kuba, pabeni,
herbert, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 9 Aug 2023 09:47:52 -0700 you wrote:
> When gso.hdr_len is zero and a packet is transmitted via write() or
> writev(), all payload is treated as header which requires a contiguous
> memory allocation. This allocation request is harder to satisfy, and may
> even fail if there is enough fragmentation.
>
> Note that sendmsg() code path limits the linear copy length, so this change
> makes write()/writev() and sendmsg() paths more consistent.
>
> [...]
Here is the summary with links:
- [v4] tun: avoid high-order page allocation for packet header
https://git.kernel.org/netdev/net-next/c/6231e47b6fad
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] 5+ messages in thread
end of thread, other threads:[~2023-08-11 2:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 16:47 [PATCH v4] tun: avoid high-order page allocation for packet header Tahsin Erdogan
2023-08-10 3:37 ` Jason Wang
2023-08-10 6:53 ` Eric Dumazet
2023-08-10 14:04 ` Willem de Bruijn
2023-08-11 2:40 ` patchwork-bot+netdevbpf
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).