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 2/2] net: add a KUnit test for the alloc_skb_with_frags() tail split
Date: Thu, 19 Nov 2026 14:56:58 +0000 [thread overview]
Message-ID: <179510021881.3136.3672843529450562064@kernel.org> (raw)
In-Reply-To: <20261116115620.18151-3-yanhaishuang@cmss.chinamobile.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The skip-or-fail decision in alloc_skb_with_frags_test_tail()
(net/core/net_test.c) depends on a probe that only runs after…
--
net: add a KUnit test for the alloc_skb_with_frags() tail split
This adds a KUnit test that asks alloc_skb_with_frags() for
MAX_SKB_FRAGS - 2 full order-3 chunks plus a 7 page tail. It then checks
that the frags cover the full length. If the allocation fails, the test
checks whether MAX_SKB_FRAGS - 1 order-3 pages can be held at once, and
skips if they cannot.
> diff --git a/net/core/net_test.c b/net/core/net_test.c
> index 2b5080c226636..118866f3e28c3 100644
> --- a/net/core/net_test.c
> +++ b/net/core/net_test.c
> @@ -1721,7 +1721,58 @@ static void netmem_ref_test_tcp_devmem_recv(struct kunit *test)
> #endif
> #endif
>
> +/* Can @nr pages of @order be allocated and held at the same time? */
> +static bool alloc_skb_with_frags_test_have_pages(unsigned int nr,
> + unsigned int order)
> +{
> + struct page *pages[MAX_SKB_FRAGS];
> + unsigned int i, n;
> +
> + for (n = 0; n < nr; n++) {
> + pages[n] = alloc_pages(GFP_KERNEL | __GFP_NOWARN |
> + __GFP_NORETRY, order);
> + if (!pages[n])
> + break;
> + }
[ ... ]
> +static void alloc_skb_with_frags_test_tail(struct kunit *test)
> +{
[ ... ]
> + skb = alloc_skb_with_frags(0, len, PAGE_ALLOC_COSTLY_ORDER, &err,
> + GFP_KERNEL);
> + /* The full chunks can't fall back to smaller pages here, so the
> + * call needs up to MAX_SKB_FRAGS - 1 order-3 pages at once. Don't
> + * report a lack of them as a failure.
> + */
> + if (!skb && !alloc_skb_with_frags_test_have_pages(MAX_SKB_FRAGS - 1,
> + PAGE_ALLOC_COSTLY_ORDER))
> + kunit_skip(test, "not enough order-%d pages",
> + PAGE_ALLOC_COSTLY_ORDER);
> + KUNIT_ASSERT_NOT_NULL_MSG(test, skb, "err %d", err);
[Severity: Medium]
Can this report a FAIL when alloc_skb_with_frags() only ran into a
temporary shortage of high-order pages?
The probe in alloc_skb_with_frags_test_have_pages() runs only after the
real allocation has failed, and by then memory is in a different state.
For this len, the full order-3 chunks can't drop to a lower order. So a
single failed __GFP_NORETRY retry ends the call:
net/core/skbuff.c:alloc_skb_with_frags() {
...
page = alloc_pages(gfp_mask | __GFP_COMP |
__GFP_NOWARN | __GFP_NORETRY,
order);
if (!page)
goto failure;
...
failure:
kfree_skb(skb);
return NULL;
}
By the time the probe runs, three things have changed:
- kfree_skb() has given the order-3 pages already taken back to the
allocator.
- The failed call has already done one round of direct reclaim and
compaction.
- kswapd and kcompactd have been woken for order 3.
The probe's GFP_KERNEL | __GFP_NORETRY order-3 allocations can then
succeed. In that case the test does not skip, and
KUNIT_ASSERT_NOT_NULL_MSG() fails.
The commit message says:
so that fragmented memory is not reported as a failure.
Does this ordering guarantee that?
Also, the failure message prints err. That value is -ENOBUFS both for a
real frag exhaustion regression and for a page allocation failure, so the
log can't tell the two apart.
Would it be more robust to call alloc_skb_with_frags() again when the
probe succeeds, and fail only if the second call also returns NULL?
> +
> + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
> + frags_len += skb_frag_size(&skb_shinfo(skb)->frags[i]);
> + KUNIT_EXPECT_EQ(test, frags_len, len);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116115620.18151-1-yanhaishuang%40cmss.chinamobile.com
prev parent reply other threads:[~2026-11-19 14:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 11:56 [PATCH net v3 0/2] net: do not run out of frags in alloc_skb_with_frags() Haishuang Yan
2026-11-16 11:56 ` [PATCH net v3 1/2] " Haishuang Yan
2026-11-19 14:56 ` netdev-bot+sashiko
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 [this message]
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=179510021881.3136.3672843529450562064@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