Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tun: avoid high-order page allocation for packet header

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>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20230809164753.2247594-1-trdgn@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Tahsin Erdogan and committed by
Jakub Kicinski
6231e47b 5604ac35

+4 -1
+4 -1
drivers/net/tun.c
··· 1523 1523 int err; 1524 1524 1525 1525 /* Under a page? Don't bother with paged skb. */ 1526 - if (prepad + len < PAGE_SIZE || !linear) 1526 + if (prepad + len < PAGE_SIZE) 1527 1527 linear = len; 1528 1528 1529 1529 if (len - linear > MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER)) ··· 1840 1840 */ 1841 1841 zerocopy = false; 1842 1842 } else { 1843 + if (!linear) 1844 + linear = min_t(size_t, good_linear, copylen); 1845 + 1843 1846 skb = tun_alloc_skb(tfile, align, copylen, linear, 1844 1847 noblock); 1845 1848 }