From: netdev-bot+sashiko@kernel.org
To: yanhaishuang@cmss.chinamobile.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
almasrymina@google.com, daniel@iogearbox.net, willemb@google.com,
willemdebruijn.kernel@gmail.com, mst@redhat.com,
jasowangio@gmail.com, eperezma@redhat.com,
narcisav.kernel@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 1/2] net: do not run out of frags in alloc_skb_with_frags()
Date: Thu, 19 Nov 2026 14:56:57 +0000 [thread overview]
Message-ID: <179510021729.3136.221796617179339449@kernel.org> (raw)
In-Reply-To: <20261116115620.18151-2-yanhaishuang@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message says only tun is affected ("tun hits this with
large GSO packets from a vhost-net guest").
- [Low] In alloc_skb_with_frags() (net/core/skbuff.c), when a non-
blocking high-order allocation fails and order-1 pages cannot hold the…
- [Low] The commit body (above the '---' line, so it stays in git
history) says "Tested with that guest, page allocation fault injection…
--
net: do not run out of frags in alloc_skb_with_frags()
This patch changes how alloc_skb_with_frags() sizes its frags. When
splitting the tail into smaller pages would need more than MAX_SKB_FRAGS
frags, it uses one larger page instead. When a non-blocking high-order
allocation fails, the order is lowered only if the rest still fits.
Otherwise the same order is retried with direct reclaim.
> tun hits this with large GSO packets from a vhost-net guest.
[Severity: Low]
Is tun the only affected caller? tap_alloc_skb() in drivers/net/tap.c and
packet_alloc_skb() in net/packet/af_packet.c use the same clamp as
tun_alloc_skb():
drivers/net/tap.c:tap_alloc_skb() {
...
if (len - linear > MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER))
linear = len - MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER);
skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
err, PAGE_ALLOC_COSTLY_ORDER);
...
}
vhost-net also drives macvtap/ipvtap through tap_get_socket(), and
AF_PACKET vnet_hdr GSO senders reach the same path. All of them could hit
the same -ENOBUFS failure before this patch. The fix in the shared helper
covers all of these callers, so only the message is incomplete.
The visible symptom is only described below the '---' line, and that part
is dropped when the patch is applied. In that symptom, handle_tx_copy()
treats -ENOBUFS as retryable:
drivers/vhost/net.c:handle_tx_copy() {
...
if (err == -EAGAIN || err == -ENOMEM || err == -ENOBUFS) {
vhost_discard_vq_desc(vq, 1, ndesc);
vhost_net_enable_vq(net, vq);
break;
}
...
}
It then retries the same descriptor forever.
The message also doesn't say that the trigger needs data_len above roughly
68K. At 64K the order can drop to 0 and the data still fits in the
available frags, so stock 64K virtio-net guests are not affected.
Could the commit message list tap and AF_PACKET as affected, describe the
vhost retry symptom, and give the size threshold? That would help anyone
deciding on a stable backport.
> Found while prototyping >64K TSO in a virtio-net guest. Tested with that
> guest, page allocation fault injection and the KUnit test in patch 2.
[Severity: Low]
This isn't a bug, but "patch 2" is a position in the posted series and
will mean nothing once the commit is in git history. This fix also has a
Fixes: tag and may be backported on its own.
Could this sentence name the test commit instead ("net: add a KUnit test
for the alloc_skb_with_frags() tail split"), or move below the '---'
line?
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index a7d555b3d2f28..43581ca020243 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -6906,17 +6906,40 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
[ ... ]
> if (order) {
> page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) |
> __GFP_COMP |
> __GFP_NOWARN,
> order);
> - if (!page) {
> - order--;
> - continue;
> + if (unlikely(!page)) {
> + unsigned int shift = PAGE_SHIFT + order - 1;
> +
> + /* Can smaller pages hold the rest? */
> + if (((data_len - 1) >> shift) + 1 <=
> + MAX_SKB_FRAGS - nr_frags) {
> + order--;
> + continue;
> + }
> + /* No, retry this order with direct reclaim. */
> + if (!gfpflags_allow_blocking(gfp_mask))
> + goto failure;
> + page = alloc_pages(gfp_mask | __GFP_COMP |
> + __GFP_NOWARN | __GFP_NORETRY,
> + order);
> + if (!page)
> + goto failure;
[Severity: Low]
Does this fallback bring back the order-3 direct reclaim and compaction
that commit fb05e7a89f50 ("net: don't wait for order-3 page allocation")
removed from this function on purpose? That commit noted that
"alloc_skb_with_frags is the same".
tun_alloc_skb(), tap_alloc_skb() and packet_alloc_skb() set data_len to
exactly MAX_SKB_FRAGS * (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER). With 4K
pages and the default MAX_SKB_FRAGS of 17, the check at nr_frags == 0 is:
((557056 - 1) >> 14) + 1 = 34 > 17
The left side stays larger than the remaining frag count for every later
frag too. Under fragmentation, could a single packet then cause up to
MAX_SKB_FRAGS direct reclaim/compaction attempts? Those would run either
in the vhost worker while holding vq->mutex, or in the AF_PACKET sendmsg
path.
This retry only runs where the old code would already have failed with
-ENOBUFS, so the behaviour itself is not a regression. If the order-3
retry also fails, though, handle_tx_copy() retries the same descriptor
again, and each pass now includes a reclaim attempt.
Could the commit message mention fb05e7a89f50 and explain why the
reclaim cost is acceptable here?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116115620.18151-1-yanhaishuang%40cmss.chinamobile.com
next prev parent reply other threads:[~2026-11-19 14:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 11:56 [PATCH net v3 0/2] " Haishuang Yan
2026-11-16 11:56 ` [PATCH net v3 1/2] " Haishuang Yan
2026-11-19 14:56 ` netdev-bot+sashiko [this message]
2026-11-16 11:56 ` [PATCH net v3 2/2] net: add a KUnit test for the alloc_skb_with_frags() tail split Haishuang Yan
2026-11-19 14:56 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179510021729.3136.221796617179339449@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=almasrymina@google.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=horms@kernel.org \
--cc=jasowangio@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=narcisav.kernel@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=yanhaishuang@cmss.chinamobile.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®