🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16730

Re: [PATCH net-next v1 03/11] xdp: Copy buffers with restricted lifetime

#16730
From: Björn Töpel
Date: Sun, 15 Nov 2026 18:52
49 lines
11208 bytes
Mina Almasry <almasrymina@google.com> writes:

> On Tue, Nov 10, 2026 at 2:21 AM Björn Töpel <bjorn@kernel.org> wrote:
>>
>> UMEM stays mapped writable in userspace, and it has a fixed number of
>> chunks. The stack must not keep its chunks in an skb or an xdp_frame.
>> Mark the providers whose buffers the stack may keep with
>> MP_CAP_RETAIN, and copy packets of the others on XDP_PASS, on
>> conversion to a frame, and on redirects other than XSKMAP.
>>
>
> I'm not understanding why that needs special handling. Devmem stays
> mapped and writeable and did not need MP_CAP_RETAIN. Also, today the
> stack can keep any pp page in the socket's receive queue for arbitrary
> time without _RETAIN. I'm espcially confused you're not adding _RETAIN
> as a cap to existing providers, but their netmems can be retained.

This patch does give devmem and io_uring zcrx MP_CAP_RETAIN, and pages
need nothing... a pool without a provider is retainable. Only UMEM
isn't.

The stack never reads devmem or io_uring zcrx payloads, so it doesn't
matter that userspace can write them. UMEM is readable, and the stack
would parse headers and payload that the application can change under
it. An AF_XDP socket also has a fixed set of chunks, and chunks held in
skbs elsewhere starve it. Driver zero copy copies on XDP_PASS for the
same reasons, in xdp_build_skb_from_zc(); this does the same for
provider buffers.

>> The head chunk is writable by userspace, so it cannot hold
>> skb_shared_info, and virt_to_netmem() cannot find a net_iov head.
>> Drivers pass kernel memory for both to xdp_init_buff_netmem().
>>
>> A static key keeps the check off while no such page pool exists. A
>> frame copy is linear, so a multi-buffer packet of such a provider
>> cannot go to a device or CPU map.
>>
>
> Did this actually improve perf? I recall that when I benchmarked the
> performance improvement, it was questionable.

I have no numbers for it, and it goes in v2. With the frag walk gone, as
agreed with Stan, the only check left under the key is for page heads,
and no provider hands out pages.


Björn
Technical Details
Message-ID: <874idij5bi.fsf@all.your.base.are.belong.to.us>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363800-linux-kernel-netdev=dewy.ru
References: <20261110102039.1002605-1-bjorn@kernel.org> <20261110102039.1002605-4-bjorn@kernel.org> <CAHS8izMhFEMu+v4zAm6VqjU=Lz=vMn58Ft6HKya1L-uNY0hL-A@mail.gmail.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!3.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363800-linux-kernel-netdev=dewy.ru
From: bjorn@kernel.org (Björn Töpel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v1 03/11] xdp: Copy buffers with restricted lifetime
Date: Sun, 15 Nov 2026 19:52:01 +0100
Organization: Usenet Network
Message-ID: <874idij5bi.fsf@all.your.base.are.belong.to.us>
References: <20261110102039.1002605-1-bjorn@kernel.org> <20261110102039.1002605-4-bjorn@kernel.org> <CAHS8izMhFEMu+v4zAm6VqjU=Lz=vMn58Ft6HKya1L-uNY0hL-A@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network; logging-data="1876970"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:E1amFFVewXThScMjzlefcB48XgQ= sha256:d5R4IzkEPApz5EiUK4kMzga07omy2rigZYjeXuhOJx0= sha1:uvp1c1WzND3xJjt2SUmK8dxQDUw= sha256:KFqs57tgYpg1jxf6E8Yb7AZ3THb9GyeaiuUjPdEOSmo=
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 4A065114A34; Sun, 15 Nov 2026 21:52:26 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 ug6mlTFB3GeL; Sun, 15 Nov 2026 21:52:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-363800-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 11D5C114A32; Sun, 15 Nov 2026 21:52:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 51317265B2; Sun, 15 Nov 2026 18:52:08 +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=1794768727; b=bqGZu3K+/UhngmLzdPooPTpBeipzQZVE0q2YC+4J/dS51wDkZKrGP76OJCIt6PCF7fAl Z2CpKskKPn+1EAlRh+8IxafpRCw+mYXpWELO7S784bQ3wL3XKSBlTZ7StdvwF7qpezDhw MJ0uzC38N06dQ8u1kD1/nEs6sJ5IqgXQBwVvTnfR9AO+BevpX45bJwpgx2tMMt1Zi0Piz aQXQIVNxjW81mleZaYrspn8GDJ3Am77M6xo2YtEsk9KBW0Ej/KWEa8hVxTpSreK28s59t qZfmCuM/7420GnMZ3i8gDmy9VglO8Rqx9zfajAZMD4diVEovm2xXGOHH2XA07qp7HPw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794768727; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: In-Reply-To:References:Date:Message-ID:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=SdudER1+z7QJDiZ1Nnh2ZbZ2E80axq39/K+Tsu5UA/w=; b=i+NpJIOuQMz4CpciK+fe2JygantGZScazriHL5fBf2dt2O4R7OtEpVyn9bcKxesvjB3b sRTnI0zLYcMEhzWpdd1st1As4oaHH3d5nAhBRicB6O3oop0J/bjmimVM3PzvIOFr6oFdk GB5qGijMKoAO8/8De7SSeBqXVAmrsxXzYZt6Tu6Xk8AjovVgHH/QGHF7PGs97HpgNRxaq Le3sx8oR6DAQ0NTmdQT+H5jGq5JamsysqU72URJohuT6vfhcfcrxhOsudvbAnYoh8Fw0e wKKiclEvRf7qhIkfTCvohE/KUangk1zCyZJuetpcr50zQf7TtcxgImLch2SLaTfU4qg==
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=Yi4oaMcO; 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 265C1606A339; Sun, 15 Nov 2026 18:52:07 +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=Yi4oaMcO
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=1794768726; b=NXVsAl7r3sZX2EjYc/qH2G5tnpg2W3pJql8V05IZBnOm5ZeBCwPd4YvGWNIqBm4ClhRL e3InZbYUwZIgifGQ1CbNUO5h8t9JLrTFwQh9FwOyLvTxlA0X0U4g5QoTNFqNfFuGIcqZ1 0oAqwfHrWZe3B9WaYkYBVAf7XSMHoa0vKAPa2s0eU0hLd9VXvvtLcQDiLpqGZIxxLhuFm sittHRpyUsQEG7js9xbzpRfKKUSqQclo1udWOnkaj4IDh2/rJ2dLQYtYTIqhtVL+DjA3t PJ/GE9BXZuT71HOGMfN7dXm7vIipu7FvqxiqZsbQec6gSDTS9vxrtrPFofqQhnm7GzA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794768726; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=SdudER1+z7QJDiZ1Nnh2ZbZ2E80axq39/K+Tsu5UA/w=; b=wLfRl8I7bgWf/d4cB/GdGcHCJdGtgBhH0P3dQVbCAH9LUlfvLO/pZcIosQ7J8yvKRCB8 vWJ2o/gW0vpO5RRRjgUnWd5DTmPv0jJ4hlT4uUHnYB0QGmeCL2/wbqgVpo50zXHD5q3+S Rp31DKslsa0WgoLz8twGGSYtxY42i2aWUQnq33urjw+kvfBmrLYBBWGsQZKc4KQ8i19C/ CVkcZ3tSRxyceF0NxWlwZVnHwEzNhMbG8rlyAYyNEwvGiVu+0Wgt19v4a4v7Q4/EbRyoU Re+t/1qpxCo0z+csJC1qsB8M1IaOG191OCXb6UGyV2QrhAHqOs8inGhw85Tsjr5OyzA==
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=Yi4oaMcO; 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 45979606A31D; Sun, 15 Nov 2026 18:52:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 940D41F000C4; Sun, 15 Nov 2026 18:52:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794768725; bh=SdudER1+z7QJDiZ1Nnh2ZbZ2E80axq39/K+Tsu5UA/w=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=Yi4oaMcOGX2qt7K6xqQ1ukn3u3IMrRR9Vyw5Msfzk3hAI8l8HV/yfhWxljmFTkgXe QewrDoa47Q8taP+G8Cw5AWN7uDgarEMA0qA82uQHDKhScIKK1ZpA9Crlfy9f9AjtEx uRXn46e/XmiB/CTeO2qOXT6V+0x9UtPa4PY8kRz5EgO2XXdYO0fs55Tbo7W8EZm9MK 7216YnY0EOU37M4AYq7EdEuJSOX6jJHDJeDBZCDQoyFxLtvcnNdLTYNeohvpNzPjwq 7EgC17gY/t/VY3BRoZCfyJ2sTgIAmko21KncSHOQ3pB1WvZb2IhxIkg3rBUwW1lTMt D5JoYQJimN3QQ==
X-Cc: Magnus Karlsson <magnus.karlsson@intel.com>, Maciej Fijalkowski <maciej.fijalkowski@intel.com>, Stanislav Fomichev <sdf@fomichev.me>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>, Shuah Khan <skhan@linuxfoundation.org>, Randy Dunlap <rdunlap@infradead.org>, Alexander Duyck <alexanderduyck@fb.com>, kernel-team@meta.com, Andrew Lunn <andrew+netdev@lunn.ch>, Jesper Dangaard Brouer <hawk@kernel.org>, Ilias Apalodimas <ilias.apalodimas@linaro.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, John Fastabend <john.fastabend@gmail.com>, Pavel Begunkov <asml.silence@gmail.com>, Jens Axboe <axboe@kernel.dk>, Andrii Nakryiko <andrii@kernel.org>, Eduard Zingerman <eddyz87@gmail.com>, Kumar Kartikeya Dwivedi <memxor@gmail.com>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, Jiri Olsa <jolsa@kernel.org>, Emil Tsalapatis <emil@etsalapatis.com>, Ihor Solodrai <ihor.solodrai@linux.dev>, netdev@vger.kernel.org, bpf@vger.kernel.org, io-uring@vger.kernel.org, "Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>, Weiming Shi <bestswngs@gmail.com>, Nikolay Aleksandrov <razor@blackwall.org>, David Wei <dw@davidwei.uk>, Alexander Lobakin <aleksander.lobakin@intel.com>, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Stuart Clark <stuclar@meta.com>
X-In-Reply-To: <CAHS8izMhFEMu+v4zAm6VqjU=Lz=vMn58Ft6HKya1L-uNY0hL-A@mail.gmail.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