🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12625

[PATCH net 2/2] net: add a KUnit test for the alloc_skb_with_frags() tail split

#12625
From: Haishuang Yan
Date: Sun, 08 Nov 2026 10:06
49 lines
10346 bytes
Allocate MAX_SKB_FRAGS - 2 full chunks of PAGE_ALLOC_COSTLY_ORDER plus
a 7 page tail. Rounding the tail down to 4 + 2 + 1 pages would need
one frag more than MAX_SKB_FRAGS, which made the allocation fail with
-ENOBUFS before the previous patch.

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
 net/core/net_test.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/net/core/net_test.c b/net/core/net_test.c
index 2b5080c22663..5a451aaf37c9 100644
--- a/net/core/net_test.c
+++ b/net/core/net_test.c
@@ -1721,7 +1721,31 @@ static void netmem_ref_test_tcp_devmem_recv(struct kunit *test)
 #endif
 #endif
 
+static void alloc_skb_with_frags_test_tail(struct kunit *test)
+{
+	/* MAX_SKB_FRAGS - 2 full chunks plus a 7 page tail: rounding the
+	 * tail down to 4 + 2 + 1 pages would need one frag too many.
+	 */
+	unsigned long len = (MAX_SKB_FRAGS - 2) *
+			    (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER) +
+			    7 * PAGE_SIZE;
+	unsigned long frags_len = 0;
+	struct sk_buff *skb;
+	int err, i;
+
+	skb = alloc_skb_with_frags(0, len, PAGE_ALLOC_COSTLY_ORDER, &err,
+				   GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL_MSG(test, skb, "err %d", err);
+
+	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);
+}
+
 static struct kunit_case net_test_cases[] = {
+	KUNIT_CASE(alloc_skb_with_frags_test_tail),
 	KUNIT_CASE_PARAM(gso_test_func, gso_test_gen_params),
 	KUNIT_CASE_PARAM(ip_tunnel_flags_test_run,
 			 ip_tunnel_flags_test_gen_params),
-- 
2.43.0
Technical Details
Message-ID: <20261108100617.23840-3-yanhaishuang@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358575-linux-kernel-netdev=dewy.ru
References: <20261108100617.23840-1-yanhaishuang@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358575-linux-kernel-netdev=dewy.ru
From: yanhaishuang@cmss.chinamobile.com (Haishuang Yan)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 2/2] net: add a KUnit test for the alloc_skb_with_frags() tail split
Date: Sun,  8 Nov 2026 19:06:17 +0900
Organization: Usenet Network
Message-ID: <20261108100617.23840-3-yanhaishuang@cmss.chinamobile.com>
References: <20261108100617.23840-1-yanhaishuang@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="44136"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mwXcPVFy7eod2SCY2ceL9eadEPQ= sha256:6eW+QmRRDJuuWIvYJCcfCw/iMB37gcAvi4RvLML+Mis=
	sha1:EQFb3zxz8ft7DoiP0v9bucezUaM= sha256:7BGzWenGxuwrUuejF05COJ2Apucgu7xsqDJUc1jh45U=
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 8E5C3113500; Sun,  8 Nov 2026 05:07:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.85
X-Spam-Status: No, score=-2.85 tagged_above=-9999 required=6.31
	tests=[DATE_IN_FUTURE_06_12=0.001, DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
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 pZ5eiTsSvU9k;
	Sun,  8 Nov 2026 05:07:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-358575-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 716B61134FF; Sun,  8 Nov 2026 05:07:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id B4734618D81; Sun,  8 Nov 2026 02:07:17 +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=1794103634;
	b=rTR7dphlPr0ozYYYaGmZUnk9CmfTzUh0sYMmwTvaRxxqe74z2LcKo0+UIRr7mlFcPhKN
	 xoah9eEmHKhseE3wvS3VNoRj7LOiQJqGQ5oz8/9O2hUf3NZPrUQ1XRypuGeGg+uNbYh0H
	 7WLb1683C/Iva8fE3N9G9uczuRFTl4LghVqE3Ptkj5Cx5RtZcssfpNzA93LfpUwJITu1z
	 EAul0vowtwRDEQF1egl1ODmCmUp23XS5XSHGl89zA6MUL4EcMoDwEcVbf6608oYgaj50S
	 bNO2cAo8NXAGxhTaQaHCHRubCq0dZJ6dRBSZ61fK/8PzrJ3Aj2t6C8Em1BAL9JF9ZRA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794103634;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=2/D69VEzPM7Q/+SVKhU5ORcgYn8HSMO73uMCYp751oY=;
	b=UmmyKtncyrGb68BXbMJvTSuJtxy2fnDnfU3DCS2gt+ZjdUKqTcmIzkP9d+2eLPUhMAdf
	 dGTRPNMp7uJ97zNb5rRZsxaV6+uD7ayWOTzEHl7G7JBWaf3t9h4UcFeOwyONVrdBHxAhB
	 Qy5zMMTjhuaZ5pBrAa9PLlyjbHF3mCFjEUlfc2LZBfrc89p2Sif/OsgyaCh5xFIRhDUxb
	 SOaQANX2uwaWlDmtOpnjSrfkHDpUjFwtYJzWxBqGBLg3qK0ePEIEmGnEF0sBwHbPnv8rm
	 3NTtaMDkPezNVq6AWzynA0LJi6DQuUgqMSjjM06PsoMM5XivwxbgzoXrbf7mGCvhxxg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=MALCRar1;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	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 DBB54606D802;
	Sun,  8 Nov 2026 02:07:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=MALCRar1
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.139
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794103619;
	b=i5UXHYIgCpZJzHhMBlNYn1+zuQwplBE1qTYSDnPZWq99XIKG7fxU+zR2iPA+2DClozS3
	 r4Eo1qyZuoO8eOlt0FMGdUVOOMKg3kqrBjPOb8/z9Ys+HN0qAq6qiLyGB29Bx7cVZl80i
	 F+lAu/DZTAeEzw9ddv0noXMkNP0SEXZuGjN2SHNYPYB3n+fuK3dQMfHbxVBNzCqJrWcZO
	 dKrEbvcoEXtWndKn6GYNIzno0hSVQnJkd6RXXk4YCUPhCsEmQxBpsfiggBz4bPY8XxIDe
	 tenW57qDFWRQw4aFJJ0mTgJ3II72gDZD1zN7Mn8zFp8wIYZBF6mjVPxPGwcN/RwD7iA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794103619;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=2/D69VEzPM7Q/+SVKhU5ORcgYn8HSMO73uMCYp751oY=;
	b=Caj8u4OW7839QniJGi1+pcTwiatCuvwjqEo/L6ROt4FB8M3iuFp/eCRpQyTVEEivtXX6
	 1E702VWk70L1u6r/ijuGyXuEbjJgz+Q+d1O3lyQsn67nGmmJ0MIcV8m9BIe4X/IpuR/QP
	 awxXmz4gTu4X/Vd57697Qk8umS9z5UhjTdWKSjuwvwSZWdvwUuFR6S9RQ8giqzloWKG/E
	 R7BHMVtUnJB3q+cZ5yg3O0IQ4fNz/N90/UvocT66aCDtm/V3Ia+0u8h1uwefqCXfh1Cm/
	 SyDBqSqgNoaOG37X6iqSC9UktDe/ctwQbv0Uwu9strG9DUXodhkM/LBENGX0hti1mYQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=MALCRar1;
	arc=none smtp.remote-ip=111.22.67.139
X-Received: from cmccmta6.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B3BC606A331;
	Sun,  8 Nov 2026 02:06:55 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1B3BC606A331
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=MALCRar1X88OK8ITtk1PjF/ZBkUMbOoqCFBGWMXDO+c/84HKmVy1AcOycZ8IdVhXM3sqUbTLMy7iS
	 5mCxKm2lSm6w+5XefiT4sop7JHRUBsle6QVjI77e21YpYQVUYRiXy/PX8X1raoGdFmGLIGBQ52xtTT
	 Eyz+P00yKI04LkXM=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app01-12001 (RichMail) with SMTP id 2ee16aefd93dfdc-952a1;
	Sun, 08 Nov 2026 10:06:55 +0800 (CST)
X-RM-TRANSID: 2ee16aefd93dfdc-952a1
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from  (unknown[74.82.203.40])
	by rmsmtp-syy-appsvr05-12005 (RichMail) with SMTP id 2ee56aefd91c07a-59b0f;
	Sun, 08 Nov 2026 10:06:54 +0800 (CST)
X-RM-TRANSID: 2ee56aefd91c07a-59b0f
X-Cc: davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	horms@kernel.org,
	willemb@google.com,
	mst@redhat.com,
	jasowangio@gmail.com,
	eperezma@redhat.com,
	willemdebruijn.kernel@gmail.com,
	linux-kernel@vger.kernel.org,
	Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <20261108100617.23840-1-yanhaishuang@cmss.chinamobile.com>
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