]> git.baikalelectronics.ru Git - kernel.git/commit
skbuff: back tiny skbs with kmalloc() in __netdev_alloc_skb() too
authorAlexander Lobakin <alobakin@pm.me>
Fri, 15 Jan 2021 15:04:40 +0000 (15:04 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sun, 17 Jan 2021 03:02:04 +0000 (19:02 -0800)
commitaf58501ddd892d7081e0f8abed3d16f9704d77fd
tree7b1594ff69b679f7e09a990113dbfb55cb0ea3b5
parent1e1e6920257f361e95d433b0eb026da8a7cf0d99
skbuff: back tiny skbs with kmalloc() in __netdev_alloc_skb() too

Commit 2d3478de5a24 ("net: avoid 32 x truesize under-estimation for
tiny skbs") ensured that skbs with data size lower than 1025 bytes
will be kmalloc'ed to avoid excessive page cache fragmentation and
memory consumption.
However, the fix adressed only __napi_alloc_skb() (primarily for
virtio_net and napi_get_frags()), but the issue can still be achieved
through __netdev_alloc_skb(), which is still used by several drivers.
Drivers often allocate a tiny skb for headers and place the rest of
the frame to frags (so-called copybreak).
Mirror the condition to __netdev_alloc_skb() to handle this case too.

Since v1 [0]:
 - fix "Fixes:" tag;
 - refine commit message (mention copybreak usecase).

[0] https://lore.kernel.org/netdev/20210114235423.232737-1-alobakin@pm.me

Fixes: a93c5a80a427 ("net: netdev_alloc_skb() use build_skb()")
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Link: https://lore.kernel.org/r/20210115150354.85967-1-alobakin@pm.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/skbuff.c