Article View: linux.kernel.netdev
Article #16342Re: [PATCH net v2 2/2] net: add a KUnit test for the alloc_skb_with_frags() tail split
From: netdev-bot+sashiko
Date: Sat, 14 Nov 2026 14:45
Date: Sat, 14 Nov 2026 14:45
104 lines
11671 bytes
11671 bytes
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 probe in alloc_skb_with_frags_test_tail()
(net/core/net_test.c) cannot do what its comment says ("Don't report a…
--
net: add a KUnit test for the alloc_skb_with_frags() tail split
This adds a KUnit case that asks alloc_skb_with_frags() for
MAX_SKB_FRAGS - 2 order-3 chunks plus a 7 page tail. Before the fix it
references, splitting that tail ran out of frags. If the allocation fails
and a single order-3 page can't be allocated either, the test is meant to
skip rather than fail.
> diff --git a/net/core/net_test.c b/net/core/net_test.c
> index 2b5080c226636..de4d246f2f7ab 100644
> --- a/net/core/net_test.c
> +++ b/net/core/net_test.c
> @@ -1721,7 +1721,42 @@ static void netmem_ref_test_tcp_devmem_recv(struct kunit *test)
[ ... ]
> + skb = alloc_skb_with_frags(0, len, PAGE_ALLOC_COSTLY_ORDER, &err,
> + GFP_KERNEL);
> + if (!skb) {
> + struct page *page;
> +
> + /* Don't report a lack of high-order pages as a failure. */
> + page = alloc_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY,
> + PAGE_ALLOC_COSTLY_ORDER);
> + if (!page)
> + kunit_skip(test, "no order-%d pages",
> + PAGE_ALLOC_COSTLY_ORDER);
> + __free_pages(page, PAGE_ALLOC_COSTLY_ORDER);
> + }
> + KUNIT_ASSERT_NOT_NULL_MSG(test, skb, "err %d", err);
[Severity: Medium]
Does probing for a single order-3 page catch the case the comment
describes?
For this len, alloc_skb_with_frags() never lets a leading chunk drop
below order 3. At nr_frags = k, the check is:
net/core/skbuff.c:alloc_skb_with_frags() {
...
can_shrink = DIV_ROUND_UP(data_len, smaller) <=
MAX_SKB_FRAGS - nr_frags;
...
}
This works out to 2*MAX_SKB_FRAGS - 2 - 2k <= MAX_SKB_FRAGS - k. That
holds only once k >= MAX_SKB_FRAGS - 2. So each of the first
MAX_SKB_FRAGS - 2 chunks has to get an order-3 page, or the function
does goto failure. In total the call needs roughly MAX_SKB_FRAGS - 1
order-3 pages, not one.
When the call fails partway through, the failure path does:
failure:
kfree_skb(skb);
return NULL;
This frees every order-3 page already placed in the frags. Since
pcp_allowed_order(3) is true, those pages land on this CPU's per-CPU
free lists right before the probe runs. The single
alloc_pages(..., PAGE_ALLOC_COSTLY_ORDER) probe will then almost always
succeed, the skip is not taken, and KUNIT_ASSERT_NOT_NULL_MSG() reports
a failure.
So the test seems to skip only when the very first order-3 allocation
fails. A host with some order-3 pages, but fewer than MAX_SKB_FRAGS - 1,
would still report a failure. That doesn't match "so that a host with
fragmented memory does not report this as a regression" in the commit
message.
Could the probe check the real requirement instead? For example, it
could try to hold MAX_SKB_FRAGS - 1 order-3 pages at once, or treat
-ENOBUFS as a skip unless a stronger check shows enough pages were
available.
> +
> + 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);
> +
> + kfree_skb(skb);
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110162418.28322-1-yanhaishuang%40cmss.chinamobile.com
Technical Details
Message-ID:
<179466755804.2199510.1095568480643973664@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363310-linux-kernel-netdev=dewy.ruReferences:
<20261110162418.28322-3-yanhaishuang@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363310-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 2/2] net: add a KUnit test for the alloc_skb_with_frags() tail split Date: Sat, 14 Nov 2026 14:45:58 +0000 Organization: Usenet Network Message-ID: <179466755804.2199510.1095568480643973664@kernel.org> References: <20261110162418.28322-3-yanhaishuang@cmss.chinamobile.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1590754"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:MqTshUjgJHUg959uEM3a2uUt6zQ= sha256:rWjPUAPgqu+oZAuNpM4ec/bCyJwg0hTC7bT0o6jViQk= sha1:9KPfVNvVjnDR7VjpKAJUnipg2Xg= sha256:9ADiymZJzH305XZkStiqs3/19uCunzmC2lB0WazfXf4= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id BBDCC11475E; Sat, 14 Nov 2026 17:46:20 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3exZwIDH5yGb; Sat, 14 Nov 2026 17:46:17 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363310-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id E1F1E114830; Sat, 14 Nov 2026 17:46:08 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 5DA133CEA0; Sat, 14 Nov 2026 14:46:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794667560; b=sEfaVdnN1l1C3vZykcOuQ4amRVf6VgDuem2kJ1EsnF6LtGL950cSexn15naZPlXb7OwD 5Bjkuzu9f5vvM156x1544St8ipnppZO309CGXsxC64f0wcKWir5uOawlb3uTv6m8vs6UB pEYq+ddiVwPbLdwG1+iBU8Rg74zgx2yD1UXxd/7GaJIX08DkWFk83yxMXpRhGT3sHR48W eCDc9+UkFp/Nvvb5/+pUH1Yr2/c4+/O+89Hl17KKtOQK0TylLrqm7eFwP3OvvN74p00uW mX9G7haJHACVMh9U+PoaLxbgutLH8KuCSoWXNEJYE9jwUWddvQILW1EQJyqryB99yYw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794667560; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=dQKkTV59PA9gDrnFZqTN77W5XNr80hjLVJl64KfD5Hc=; b=soB4VPG6SW2NIzIZxCvcWEUe+M4iSSih0vqei6coho1/k+5qA/Uv7VUVcTc2Xmhsr7Xy OhYKCaORq8VCiBIZqXhVlbLfnMU9q7M81KBN4MNt6Q/9J6uxI0KLV9I4qWp/AqE/2iPSr noVNQ0ap87mSx3Kcdv62h2p8JhfGDyfMdVU1Nx/CXxUd+e7F1NXyTwZQVA5nfhu0Mr7V7 RMDl41r1cLPkJ9xOBCWLvo99i58aYWgmurVeqdyBhqokmQlX3sduJC+LiMyZ1TcW6/xO0 PXoxXScWDOVHCFTQ+5bXmeOmVbSDt+8roZCz3IpRYSEUH+zrHFz0VUw8CYmCgBfrUEw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="kabNH/F3"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D8A9606A884; Sat, 14 Nov 2026 14:46:00 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kabNH/F3 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794667559; b=Mcv0oiQWnMyEjZY2CEDFEPdHiUvgDMlIxtWlcgzHLlrcaIVo0NUZTYLpTv819Rkr6QJS 9fBGET23+oaZfNcWroGXeHEDc+iIrUTFO4DHyjJGenk7hPdTyg+QuTdThfDjWyBsMk96Q qNB2WDWqq37NFLUXXGOMnStGsmLDpKAxCUAzNrvOR+B/lYOX2lq0Bul04Om8++Jc/VkLc E+cqnf/9had9BN3r4/kfCqTq9YuWLm1ojh0NcMyGE5Jd3bkm3gMdNcRAm7jz5Mu/DRJna GzdSOzBypxEXoQ12iismYTqlfTTCIPEU0yGl1WhmG1WMf8PrnCTibrNLs8lfNiMt8Zg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794667559; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=dQKkTV59PA9gDrnFZqTN77W5XNr80hjLVJl64KfD5Hc=; b=FSHXEGwCGH+KrXWRgJLqA1ugEUkByRF26moFO4MoCmGYikyCMITRiyEWxoXybal5hAA6 P+uQCgO38SvTqLy/Q003ahaPaeHwPEq3BSnrZLbZ0zMhswKq7TG1GmtUdapeBWv0nzk8s eO8QZFMkqs5hl3XSUomAiYWupP8TmiY9k+TRoYsuG0oKrGoIjpdmTXM4PbB5CNcQ4y/8p 7utdawJL+gvVXTyCWGSiXv4VOe+kLARRIOS5tacTVLGrhiv+QAnPyVV0W2vF86rdi2t3M c9FLr2mvsE0Lxcrv2Vc+BNHPraXKNI8IuiU2WF0w+xZnerV/MYPpPjqUYIYriiYTGfg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="kabNH/F3"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B50D606A33D; Sat, 14 Nov 2026 14:45:59 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A9491F000C4; Sat, 14 Nov 2026 14:45:58 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794667559; bh=dQKkTV59PA9gDrnFZqTN77W5XNr80hjLVJl64KfD5Hc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=kabNH/F3S+UrrEuuedgxRELY4hGwCq7FxgQvEhMoV4jRhY7vkx6F92lrJq4frCiFd tXrj8jUX5WG0tI6YZgKKjfOgjsBJWnv1PrpreIVwMmB7UeG+GMKwAvso2kAHnff7Ak EBWG3VYa776D8wSvmgWTHJ3lBgrLY+ckOqxffc9CawGLaCAwry6x6H+ZngBmHhydef SHOml4ylCYxBQJgIdzYAWFXOIBMpghoj+d48h5ACUZH/usWPPfKxTcqAcQNxO9SW4q KF8MiHpo+pul+NID+RkmqAISGpmt8p9yMlk7Y5BuyisPU8igSBWKsvHRoZ7wH8mtkO yUpdCgjtR/oBQ== X-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 X-In-Reply-To: <20261110162418.28322-3-yanhaishuang@cmss.chinamobile.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list