Article View: linux.kernel.netdev
Article #27017[PATCH net-next v2 00/15] xsk: Return UMEM chunks explicitly
From: Björn Töpel
Date: Fri, 04 Dec 2026 16:27
Date: Fri, 04 Dec 2026 16:27
200 lines
18546 bytes
18546 bytes
Currently, AF_XDP zero copy fills one UMEM chunk per buffer at the
UMEM headroom, and each RX descriptor gives its chunk back. Drivers
carry a second RX path for that layout, and cannot use their own
buffer sizes or pack small packets into a page.
This series adds explicit chunk return. With XDP_UMEM_EXPLICIT_RETURN,
the device lays out buffers in chunks as in pages, so a chunk may hold
several buffers and a packet may span chunks. Each buffer reaches the
socket as an RX descriptor. A chunk comes back on a descriptor with
XDP_RX_CHUNK_RETURNED, or without one once the receiving socket is
gone. The application cannot influence where packets land, how many
share a chunk, or the headroom.
The design came out of off-list discussions with Magnus, Maciej,
Stanislav and Jakub, where Jakub proposed letting the device keep its
own buffer layout.
The chunks back the bound queue's RX page pools through an AF_XDP
memory provider, so drivers need no AF_XDP code. fbnic and mlx5 add 54
and 165 lines, to handle buffers as netmem, refuse settings that the
provider cannot take and, for mlx5, restart queues with a provider
bound. A native XDP program steers packets to the socket. The kernel
keeps nothing in the chunks, as userspace may write them at any time.
The provider takes no lock. The driver uses the queue's buffers from
one context at a time, its NAPI or an operation that runs only while
that NAPI cannot use the rings. It runs that NAPI once after the queue
starts, and passes the buffers only to the queue's socket. That
context writes every return at once, as the RX ring keeps room for
each chunk the kernel owes, so packets drop a little before the ring
is full.
This posting drops XDP_PASS and XDP_TX of these buffers. Both need a
copy, which a follow-up adds. Until then, management traffic should
use other queues. Sockets transmit in copy mode only.
Performance in Mpps with 4 KiB chunks and preferred busy polling, so
application and NAPI share one CPU. Native XDP drops each packet and
AF_XDP sockets only return it, untouched. Min-max of 3 runs, 5 for
mlx5 XDP_DROP below 300 B; * is within 2% of the offered load, ** a
PCIe limit (Gen4 x4).
MTU 1500:
offered native explicit classic
frame NIC XDP_DROP return zero copy
66 B mlx5 61.0 31.38-32.71 18.19-18.25 23.40-23.87
fbnic 65.3 37.68-38.15 26.61-26.96 n/a
128 B mlx5 37.0 31.07-31.27** 18.09-18.28 23.22-23.64
fbnic 40.5 37.99-38.21 26.81-27.14 n/a
300 B mlx5 19.3 17.70-17.71** 17.72-17.73** 17.72-17.73**
fbnic 17.4 17.38-17.43* 17.41-17.52* n/a
1500 B mlx5 4.10 4.10* 4.10* 4.09*
fbnic 4.04 4.03-4.08* 4.03-4.05* n/a
MTU 5000, where classic zero copy cannot bind on mlx5; fbnic has none:
offered native explicit classic
frame NIC XDP_DROP return zero copy
300 B mlx5 19.3 17.78** 17.21-17.48** n/a
fbnic 17.4 17.41-17.48* 17.39-17.46* n/a
1500 B mlx5 4.10 4.10* 4.10* n/a
fbnic 4.04 4.04-4.06* 4.03-4.04* n/a
3000 B mlx5 2.07 2.07* 2.07* n/a
fbnic 2.02 2.02* 2.02* n/a
5000 B mlx5 1.24 1.24* 1.24* n/a
fbnic 1.21 1.20-1.21* 1.20-1.21* n/a
Native XDP (XDP_DROP, XDP_TX and XDP_REDIRECT), classic AF_XDP and the
kernel UDP and TCP paths run at the rate of the base on mlx5, fbnic
and bnxt, within the run-to-run spread.
This series transmits in copy mode; the full branch, with bnxt,
zero-copy TX and the follow-up optimizations, and its numbers are at
https://github.com/fb-bjorn/linux/tree/xsk-explicit-return-v2.
Dependencies:
- "xsk: Keep the shared info of zero-copy buffers in kernel memory",
https://lore.kernel.org/netdev/20261204142030.626820-1-bjorn@kernel.org/;
- "eth: fbnic: Support XDP redirect",
https://lore.kernel.org/netdev/20261203180924.3862144-1-bjorn@kernel.org/;
- "net/mlx5e: Report a down device as -ENETDOWN to queue restarts",
https://lore.kernel.org/netdev/20261201113925.1245805-1-bjorn@kernel.org/;
- "ethtool: Allow the channel count that a memory provider needs",
https://lore.kernel.org/netdev/20261201115458.1254880-1-bjorn@kernel.org/;
- "bpf: Use the checked TCP header length in the syncookie helpers",
https://lore.kernel.org/netdev/20261201091755.1130605-1-bjorn@kernel.org/.
v1: https://lore.kernel.org/netdev/20261124112707.118678-1-bjorn@kernel.org/
Changes since v1:
- v1 was "xsk: Receive in the device's buffer layout". The flags are
now XDP_UMEM_EXPLICIT_RETURN and XDP_RX_CHUNK_RETURNED, not
XDP_UMEM_DRV_LAYOUT and XDP_RX_CHUNK_FREE, after Magnus. xsk_sink
is now xsk_mp, and "sink" is "XDP-only" in kernel names;
- v1 patch 2 became a net series, see Dependencies, which also moves
the shared info of classic zero-copy buffers out of the UMEM,
after Maciej;
- v1 patch 9, fbnic XDP_REDIRECT, is a dependency. v1 patch 11
is part of patch 2, and v1 patch 12 is split into patches 10 and
11. bnxt, v1 patch 13, comes back in a follow-up, after fixes to
its queue restarts. Patches 8, 12 and 13 are new;
- binding also needs CAP_NET_ADMIN, and XDP_ZEROCOPY fails as
XDP_COPY did. Classic zero copy may bind next to an XDP-only
provider on another queue;
- an empty head with metadata reaches the socket as a zero-length
first descriptor with XDP_PKT_CONTD. v1 dropped such packets;
- a returned chunk counts against no page pool, so a restart while
bound does not starve the new queue;
- the provider takes no lock, as the driver uses a queue's buffers
from one context at a time. Returns go into RX ring room kept for
them, and need_wakeup reports only an empty FILL ring;
- the provider drops the references of a run of buffers at once, and
mlx5 lets go of a page after its last stride, so fewer chunks need
an extra empty descriptor;
- the provider goes with the last socket of the queue, not with the
receiving socket. Once the receiver is gone, the queue drops what
it redirects and the chunks the kernel owes return. The rest
return with the last socket, and a program detach right after that
may briefly fail with EBUSY;
- redirects show in the xdp_redirect_map tracepoints, and page-pool
dumps carry a new, empty xsk nest, NETDEV_A_PAGE_POOL_XSK;
- mlx5 takes the provider on striding RQs only. While a queue has
one, it refuses to leave them, PTP, HTB offload and growing the
RQs of a down device. A channel switch closes the old channels
first;
- xskxceiver's --drv-layout is now --explicit-return, -H checks the
headroom, and RX_RING_FULL_RETURNS is new. The test now fits the
reworked xsk selftests, and drivers/net/xsk.py runs its rx cases
with explicit return on a NIC. The af_xdp.rst section
"Device Buffer Layout" is now "Explicit Chunk Return", with a part
for drivers;
- many fixes from a machine review of v1, listed in each patch.
Björn Töpel (15):
xdp: Let memory providers expose net_iovs to XDP
net: Add memory providers that only feed XDP
page_pool: Let memory providers take back net_iovs
xdp: Run programs on XDP-only buffers
xsk: Back a queue's page pools with UMEM chunks
xsk: Deliver packets and return chunks explicitly
xsk: Receive with explicit chunk return
xsk: Drop references of a run of buffers at once
eth: fbnic: Receive into XDP-only memory providers
net/mlx5e: Handle restarts with XDP-only providers
net/mlx5e: Receive into XDP-only memory providers
net/mlx5e: Release XDP-only pages earlier
net/mlx5e: Test for XDP-only pages per RQ
selftests: net: xsk: Test explicit chunk return
Documentation: xsk: Describe explicit chunk return
Documentation/netlink/specs/netdev.yaml | 8 +
Documentation/networking/af_xdp.rst | 244 ++++-
drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 +
.../net/ethernet/mellanox/mlx5/core/en_main.c | 100 +-
.../net/ethernet/mellanox/mlx5/core/en_rx.c | 83 +-
.../net/ethernet/meta/fbnic/fbnic_ethtool.c | 22 +
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 41 +-
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 8 +
drivers/net/netkit.c | 2 +-
include/linux/netdevice.h | 2 +
include/net/netdev_queues.h | 1 +
include/net/netdev_rx_queue.h | 5 +
include/net/netmem.h | 31 +-
include/net/page_pool/helpers.h | 4 +-
include/net/page_pool/memory_provider.h | 22 +
include/net/page_pool/types.h | 24 +-
include/net/xdp.h | 117 ++-
include/net/xdp_sock.h | 8 +
include/net/xsk_buff_pool.h | 3 +
include/uapi/linux/if_xdp.h | 23 +-
include/uapi/linux/netdev.h | 1 +
net/core/dev.c | 56 +-
net/core/filter.c | 46 +-
net/core/netdev_rx_queue.c | 51 +-
net/core/page_pool.c | 71 +-
net/core/xdp.c | 55 ++
net/ethtool/rings.c | 5 +-
net/xdp/Kconfig | 1 +
net/xdp/Makefile | 2 +-
net/xdp/xdp_umem.c | 5 +
net/xdp/xsk.c | 110 ++-
net/xdp/xsk_buff_pool.c | 38 +-
net/xdp/xsk_mp.c | 900 ++++++++++++++++++
net/xdp/xsk_mp.h | 21 +
tools/include/uapi/linux/if_xdp.h | 23 +-
tools/include/uapi/linux/netdev.h | 1 +
tools/testing/selftests/drivers/net/xsk.py | 28 +-
.../testing/selftests/net/lib/xsk/test_xsk.c | 556 ++++++++++-
.../testing/selftests/net/lib/xsk/test_xsk.h | 9 +
.../selftests/net/lib/xsk/xskxceiver.c | 57 +-
40 files changed, 2659 insertions(+), 126 deletions(-)
create mode 100644 net/xdp/xsk_mp.c
create mode 100644 net/xdp/xsk_mp.h
base-commit: e5ba10df689a988da8480e4f3e2a6cd88a506f97
--
2.56.1
Technical Details
Message-ID:
<20261204162723.755897-1-bjorn@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377481-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377481-linux-kernel-netdev=dewy.ru From: bjorn@kernel.org (Björn Töpel) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next v2 00/15] xsk: Return UMEM chunks explicitly Date: Fri, 4 Dec 2026 17:27:05 +0100 Organization: Usenet Network Message-ID: <20261204162723.755897-1-bjorn@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2805865"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:XjutTIfeJKvXkdJVKpdaFMQALvQ= sha256:n5cuP3vg03RfqlcsmnGUipXSCRm6EVHVHQJ9kgNNGIg= sha1:kfrCkxnEBYY9V8gIgtu2LhQipwg= sha256:F7TfIvybtsFC0X5cH9L2uoQycC1l5zenCSsCx8Rie7o= 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 F15BE117C60; Fri, 4 Dec 2026 19:28:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.541 X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, 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 aS5PaiTRikFi; Fri, 4 Dec 2026 19:27:59 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377481-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 CAA3A117B87; Fri, 4 Dec 2026 19:27:48 +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 09F5543F7D; Fri, 4 Dec 2026 16:27:43 +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=1796401661; b=VbXwXmsUITdoyPy/SPSk0GfDJIF3h+X/a6zqF/7g4gM4V9uAlbNB8rGKLW1lgiz09e7d 8dRyyW7SlvRvt0QLE8no6CijhdxUA+M5n8dHsap7znga8ySXOezHUXBfQqG5c53b7z7qu XpToM2e7lm+w7unQecqkpuF6C9y8/YGVZY4SmdxS0VP5ULNeD0AawBaCT9aH7OJgRksM5 YmH+8fyuhBtrt48CTml5dxTugcf+WC40beGEqmqdsDdxP9KDlrUL2/DD9imHCFHCGP/68 kmN0jmm6H2285aOV84J7pPBCw+t+uvAB0f5PZUiuusvGcSTjvKGoemZCr/lyGxuQEsg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401661; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=2LMkYRTeqw34yFVH5rmu3fod1f0Y7ynxU6iL2gWVyCg=; b=5mCVIiiEQRqyOdyJ79OxmVQgdaW0mVXe0iYsBg4/QsoWjrcQ/Pxt3njfoCmy7wDmsAhi 6UqjovHtalxhFBaltMEyYNQuWkIj9Nzu3CQbEigI59ngbdSgxJ4nkVKO9mGT/ucm6iYay Q2GGsuau3DNagECk4oIiuyhQo/r/Z7lySBevt3tXf2Z8q05y4xBFu/kcEPpTACyxiR9BB dGyn1/y+ef82JUS8SjgdqyD8XmzHcvYF5KRkhRwZj7ZfmYYsghuTQWPTGfxaBchaedpgk 0l+mk8Z1pjIfV9xKhUGHpKMHOGF6c8fYChDVVuZHP3gwmDpjZogkhvPql+N+djmsAjQ== 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=iJD1gK1c; 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 A5B16606A68A; Fri, 4 Dec 2026 16:27:41 +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=iJD1gK1c 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=1796401660; b=u0UL2nzsn/Va+MWXPRD8CG76+UOEVwtFRl3s4JsoPrZ2SZg1VkQlWD6s5YRBr5NOc/j9 UAQTTPnyQGfgkMhgVIc8rvp1855GCTBB7xv1JRBiIC28JpId8HJo4sZTYt8o+bxlgRK6P BynflMzCDCG9FyFYNTniG7btSvahQDO5U86aE/Z/nSlkhzNZGFcFPnLpp5paLmoOzMhHG SPVRsGofsF82NuneLQU1U5TxJ6J3FVI6GsrORqlG86+TMB5NgHpPIkgjtIF+YiNECWVxP E+TSyymIvQiMHoxsWvA5XQHIRL7mUzsRlmHEM49laz9SjHjGeGBMILAJTz3VxcMQlAQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401660; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=2LMkYRTeqw34yFVH5rmu3fod1f0Y7ynxU6iL2gWVyCg=; b=x16p3MgdjjwzirBjaUtkaFEikgaQSLhdLtNs+Gvw6QvBtNqFFqM1m2oYITOxO8HcFk+o PHy22YGU1QEPb/gMD8m74rl6vUYNtSlYXLsDxBsPj7pRjcDnWo0Pm7/qGa3QYIASxnOH/ 2hukBrCefHHzOer9apm0jHTPZ6YsT0KqtmKSviGsCxmc306INxnrnH+bbh4lmcbr96mGN /W418CJ10H6NmbZqQaPZiMle0gJEatAJzes1+g8aYWz054siucM8aw2KxMEr784OIL4AS YM2AOUVoyGVAwBpX8c36Ps+19Nb/V4j2zOHMBTz/dXb6RX891LMNHIdNbzqocKaH8nA== 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=iJD1gK1c; 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 C2460606A32D; Fri, 4 Dec 2026 16:27:40 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E28DB1F000CE; Fri, 4 Dec 2026 16:27:31 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796401660; bh=2LMkYRTeqw34yFVH5rmu3fod1f0Y7ynxU6iL2gWVyCg=; h=From:To:Cc:Subject:Date; b=iJD1gK1cyjVTP99/t65IkSxk8dRhfSko2xbTSAk93edhJOfmQ0jPixsHcEFHXjsn/ IHKZ0O2rtF9LX4TDZ3dpYUaulyQqN4VkstWU0yXCebIOuJN7o9AKplSXJ0VSn1mqKu 1F3S5Y3ryzaxs5iKB0Nty4qvPoEz2leJrPyb5mRBb+uj/pePc6jYjzbQslJe5d7T8c wcJ5zsJarMWcwPZQpYFVCnZHXlbwmGCb0Ev7QHzWLJH0UbqqWMkbAuTdwSE2Mt2zaf 1stnjpDZUKKZxSetYmYanR9SA3RS44AqtcZSbOe3jiaV0ULICvWs1c5E4VraTDI7lg qUdQ3v84MCehA== X-Cc: Björn Töpel <bjorn@kernel.org>, Simon Horman <horms@kernel.org>, Stanislav Fomichev <sdf@fomichev.me>, 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>, David Wei <dw@davidwei.uk>, Tao Cui <cuitao@kylinos.cn>, linux-kernel@vger.kernel.org, kernel-team@meta.com, "Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>, linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan <skhan@linuxfoundation.org>, Randy Dunlap <rdunlap@infradead.org>, linux-doc@vger.kernel.org X-Mailer: git-send-email 2.56.1 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