Article View: linux.kernel.netdev
Article #19214Re: [PATCH net v3 1/2] net: do not run out of frags in alloc_skb_with_frags()
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 14:56
Date: Thu, 19 Nov 2026 14:56
143 lines
13551 bytes
13551 bytes
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
Technical Details
Message-ID:
<179510021729.3136.221796617179339449@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367097-linux-kernel-netdev=dewy.ruReferences:
<20261116115620.18151-2-yanhaishuang@cmss.chinamobile.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367097-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179510021729.3136.221796617179339449@kernel.org> References: <20261116115620.18151-2-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="2905605"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:rzVH64lrp3S3JrufM2iMu6/w9XE= sha256:XOyOV/DML2S2jzGA4067XBUY3+E5LXPQSImlbFTWMYk= sha1:RSZZzh2FA2HB23WMdug2GaD6U7Y= sha256:9Ru7xhwW0bDP9jkV6139MGmPB3fjUDbeJDzrN49jUdU= 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 E46E51156AD; Thu, 19 Nov 2026 17:57:34 +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 YPf8Sc2jgU3k; Thu, 19 Nov 2026 17:57:30 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-367097-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 8C5D71156AB; Thu, 19 Nov 2026 17:57:21 +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 8ADC32CA171; Thu, 19 Nov 2026 14:57:02 +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=1795100219; b=K2ZiShaatgWOL3/QGZO5mm2ic8oKvdxC4+MrPh4ZxuSWRFfUjPjLK1S2Xrd7M4KJV8ox n0QC+ssiAmWo1Ty0gcLJTRLMDIsTk6tbMzsaPpjCUBBnh6/Lj7De0+LWE81DM43ulfsvu /njgbN77uFF3rwg6gQlPJlRNkknOFwduTEQC30suhXYaV93YgWrGtC62C2EhH95T735Wn YWER6k4cxqEvUqR9BIk0ioUDuhYEf2vZHu/S9IP5t/Fu1lqoUppfTG/FkFAvhIZKa7sLj 1ECqxdojdp+3a03grbTwmeu+i6qKAzcBwfVqNbE9tBxAcS2L4HbEf9eEF1HOjyytFGw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795100219; 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=h4wVfzJaa/ibP8lnm0+cpyqaMS8S9SYMC5L5IAg9SnA=; b=g65rsX/h5gZz1zfuIWQc7lEQoe/6KM0jeTir26ZcqM3goUEeN8+BlCGaeZSJfws8FrHy yt0qtQTiyYNYeoB2E5TjEtXyQAvujreWKQoBfL5e4jQDqVWuPLVZSe/9qW/nunhnpUGaR ZwMKHPPzuMZz7RHUqOek7svAUBUgoWmb7vTr0FhqoB+SXkdixCIFkMOnthICPFH7yQevH LdMUS97aOjPJtsWmDGbXRbpi4DxjMEXaYlaJYyMw4XJoE96O6FfL7ALQgz6xd2eCQm/sr /AScHeVMWeVIYV/iodVA2TktfuF4tfnumqlgA+PtlXjSiNaxwXHriu5/0Id7hxjswpA== 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="E/NNxc3/"; 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 B7466606A335; Thu, 19 Nov 2026 14:56:59 +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=E/NNxc3/ 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=1795100218; b=H/b+211kddAkNycTbFuHxSb+Rt1sKNA0pzpBeIZmx2dJH0Sn2MBl+wMxKAqmG2NuJZl2 BtgHtzZvyfpIpdxGfCaAfTUby7rDgnPU+lBB64RUwoGpII8Xy1eqDbfZsm1BQX+87jyOq RCZX6jjiey62fgEjPAvXDCyn2FHnJf3IdnxkdiiLyRVhhonm8kIeOBjB06UMBvmJ1kSDo LjBsk6foZcUJ4pbCU92EDGka8ppDkB6fy76QkWoB3gn337g49Oj6VCoNHaOdpvcv3bbfd z/C3tGhK30ARhp6As9etpo0tm15rHM+lgT1+Pf3JDiiA+enSniwk00Tc1wPZ1jEanGg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795100218; 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=h4wVfzJaa/ibP8lnm0+cpyqaMS8S9SYMC5L5IAg9SnA=; b=u+GcP1aYZHzHTmrQdX5Hht/ZwnvKd9iZvGYZcDlCp8Rmulg0KOvsog6QGlHIfGM/AZh/ GoLl3eW1L3Pzs3t0dGx8pByRI1TjC3JicQrVbQ6wHiApcHWonU/+dun5YBcWJIDqHnIDX yPcNsUUVlVEKW1TQc3ow/zj/l6cdnho0IMLVXyvEHyU3ZISz8sjwWfeKpTITcqeWAJylE 8+viCGnsmD+gWOhB+ZbpWcHCHRSvxScUTY8lp5GMGYzC/G2xtDn5zNIN7KG55qRQvCxcD Z9JgjS0DOFCFXbX0TXaxIC0KONU4r9SC9ATba2/xhStxuZSMbaK+L0y5CGCcJqxSw9w== 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="E/NNxc3/"; 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 D4C15606A320; Thu, 19 Nov 2026 14:56:58 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3ADE1F000C4; Thu, 19 Nov 2026 14:56:57 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795100218; bh=h4wVfzJaa/ibP8lnm0+cpyqaMS8S9SYMC5L5IAg9SnA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=E/NNxc3/gdqSVZhn2j7w8PkOa6j1MvtbezXHVadiMFdAJfTCQ75jmOEtiVkXngxky UJjYXKwmqo2g3kba68S76vENKejPf5T04nKqLy+HjInKDqIHs5PFa8n8SqizR0n7dQ 9oIWQOqCroWU9Jpe/LpDoch1gyCPt18NSsr2VwWtW1jJZ31IMJ5iEUVE3Lhtb+AxY/ Oo7KI8m0vV+Iuhw41XmQNTBIM6tzHVTKvyv++/doYe5eezf/wtOhGbhWE7hfJmiwz0 xgi/MRY0EqfrKwcquRUDQf7zl5brrMxZZjjm18bdFtRNRoH+WexCRUNnda8RmaDlZZ 2SgGUGXu+SWcQ== 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: <20261116115620.18151-2-yanhaishuang@cmss.chinamobile.com> X-sashiko-severity: Low 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