Article View: linux.kernel.netdev
Article #20381Re: [PATCH net-next v4 0/7] net: devmem: support leased RX and TX queues on netdev unregister
From: Nikolay Aleksandrov
Date: Sun, 22 Nov 2026 09:16
Date: Sun, 22 Nov 2026 09:16
105 lines
17268 bytes
17268 bytes
On 20/11/2026 06:59, Mina Almasry wrote: > Support leased RX and TX devmem bindings when either the virtual device > (e.g. netkit) or the physical backing net_device is unregistered: > > 1. Pass struct net_device **dev_ptr to net_devmem_lock_dev() so callers > can lock either binding->map_dev or binding->bind_dev. > 2. Rename binding->dev and binding->vdev to binding->map_dev (physical > DMA device) and binding->bind_dev (device passed to bind-rx/bind-tx). > 3. Introduce netif_lease_valid() and guard netif_mp_open_rxq(), > netif_mp_close_rxq(), and netif_rxq_cleanup_unlease() against an > unregistering physical device reached through a queue lease. > 4. Fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() so the > xarray lookup, validation, device check, and reference acquisition > run under a single rcu_read_lock() section. > 5. Always populate bind_dev on RX and TX bindings and handle teardown > and netdev unregistration of both bind_dev and map_dev, waiting for > synchronize_net() after clearing NET_DEVMEM_BINDING_LIVE before > unmapping bindings whose map_dev is unregistering. > 6. Resolve the physical backing map_dev in netdev_nl_get_dma_dev() for > leased RX bindings, lock map_dev around net_devmem_bind_dmabuf() on > bind-rx when map_dev differs from netdev, assert both devices are > locked, and check netif_lease_valid(map_dev). > 7. Add kselftests in nl_netdev.py covering leased RX and TX devmem > bindings across both virtual-first and physical-first netdev > unregistration orders. > > These issues were discovered during AI code review (Sashiko) of the > earlier non-leased devmem unregister series (and subsequent mailing list > review) and confirmed by code inspection (not observed in production or > reproduced on real hardware). Tested with the nl_netdev.py selftest on > netdevsim added in this series. > > v4: > - Rebase onto latest net-next/main. > - Fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() under a > single rcu_read_lock() (deferring net_devmem_dmabuf_binding_get() > until after all checks pass) and update net_devmem_dev_unregister() to > use a two-pass loop with a single synchronize_net() after clearing > NET_DEVMEM_BINDING_LIVE and before unmapping bindings with > map_dev == dev (Paolo). > - Document issue discovery, validation, and testing in commit messages > and the cover letter (netdev-bot+sinfo). > - v3: https://lore.kernel.org/netdev/20261115022607.348112-1-almasrymina@google.com/ > > v3: > - Rebase onto latest net-next/main. > - Add netif_lease_valid() helper and keep lease validity checks in the > lease-aware callers (netif_mp_open_rxq(), netif_mp_close_rxq(), > netif_rxq_cleanup_unlease(), and net_devmem_bind_dmabuf()) rather than > inside __netif_mp_open_rxq() / __netif_mp_close_rxq(), and document why > mp_params is cleared directly when !netif_lease_valid(dev) (Stanislav, > Sashiko). > - Guard the bound_rxqs loop in net_devmem_unbind_dmabuf() with > if (binding->bind_dev), keep the !netif_is_queue_leasee(dev) guard in > net_devmem_dev_unregister() in patch 4/6 until patch 5/6 resolves > binding->map_dev to the physical device so the series is bisectable at > every commit, and document the use-after-free in dma_unmap_sg_attrs() on > physical netdev teardown in patch 5/6 (Sashiko). > - In nl_netdev.py, verify dmabuf and lease on the physical queue after > binding, skip when queue_create returns EOPNOTSUPP, probe the physical > device on EOPNOTSUPP so a broken lease lookup is not masked as SKIP, and > clean up nk_ifname between loop iterations (Sashiko). > - v2: https://lore.kernel.org/netdev/20261108055809.2122934-1-almasrymina@google.com/ > > v2: > - Split patch 3/4 from v1 into 3 smaller commits (patches 3/6..5/6). > - Clear rxq->mp_params and return 0 in __netif_mp_close_rxq() whenever > dev is already unregistering, avoiding queue reconfiguration on an > already-shut-down map_dev during cascaded lease teardown (Sashiko). > - Drop unnecessary xa_erase() in net_devmem_unbind_dmabuf() and use a > local map_dev variable in net_devmem_get_binding() (Stanislav). > - Restore ASSERT_EXCLUSIVE_WRITER(binding->bind_dev) in > mp_dmabuf_devmem_uninstall(), drop redundant bind_dev->reg_state check > in net_devmem_bind_dmabuf(), and expand commit message rationale > (Dragos, Stanislav). > - v1: https://lore.kernel.org/netdev/20261103232659.1340283-1-almasrymina@google.com/ > > Mina Almasry (7): > net: devmem: pass net_device pointer to net_devmem_lock_dev() > net: devmem: rename binding dev and vdev to map_dev and bind_dev > net: guard memory provider RX queue open and close on unregister > net: devmem: fold net_devmem_lookup_dmabuf() into > net_devmem_get_binding() > net: devmem: always populate bind_dev and detach both devices on > unregister > net: devmem: resolve physical map_dev for leased RX bindings > selftests: net: add leased devmem RX and TX netdev unregister tests > > net/core/dev.c | 2 +- > net/core/dev.h | 7 + > net/core/devmem.c | 178 ++++++++++++----------- > net/core/devmem.h | 31 ++-- > net/core/netdev-genl.c | 59 +++++--- > net/core/netdev_rx_queue.c | 31 +++- > tools/testing/selftests/net/nl_netdev.py | 159 +++++++++++++++++++- > 7 files changed, 333 insertions(+), 134 deletions(-) > > > base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e The set looks good to me, I also ran a few basic lease queue tests w/ netkit. For the set: Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Technical Details
Message-ID:
<9c6546b4-d88d-48ce-a4f7-721eed72d4b2@blackwall.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368626-linux-kernel-netdev=dewy.ruReferences:
<20261120045918.1239746-1-almasrymina@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368626-linux-kernel-netdev=dewy.ru
From: razor@blackwall.org (Nikolay Aleksandrov)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 0/7] net: devmem: support leased RX and TX
queues on netdev unregister
Date: Sun, 22 Nov 2026 11:16:03 +0200
Organization: Usenet Network
Message-ID: <9c6546b4-d88d-48ce-a4f7-721eed72d4b2@blackwall.org>
References: <20261120045918.1239746-1-almasrymina@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="3604606"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:OZ7sK6RMIX3ruzrOruw7T/3r4Xs= sha256:TJyvjHOzFenRNxMRH+yIxlDpR091P1mWg5YoMNVUu2U=
sha1:USKp6mNE7QtI3C178/75XY4kkUQ= sha256:Z8uX87g3+8K4eVsbxklk/yZKZy/l01iELy8clKZn05E=
Content-Language: en-US, bg
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 3830C125D72; Sun, 22 Nov 2026 12:16:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-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, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=blackwall.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 qpkdVjitUhSP;
Sun, 22 Nov 2026 12:16:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368626-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=blackwall.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id AE17E125D71; Sun, 22 Nov 2026 12:16:10 +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 6D33832978; Sun, 22 Nov 2026 09:16:09 +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=1795338969;
b=OPO6KjylUIPKnGSdGhzb6uunCZuLAww+xyEDc6wK6sMVQ4ul8clxVa+kB4zIoCLSsjiF
H1zZD1oqn4Or47X2x754xikIsQaKNyGzFfdbdfuQZWC/hlDikh0K5oEEc4ZXHQaKa3wov
DwIBo5ivksznwuiIbp/zQa+lp+2yYQULbXPFG2wF1SXl5nsDsT7AleJrYQPi61mZHWadg
O5HBtgDEMmphzPOSIG2KeAwTtGt+7bP8o7FLdnsTyqg+hVfT3siyt22QqvuNsgfqf1ze0
vlcebQTxnH3lDySgm/qPzb1orVOp65mqRMqQHPhQ8UjrAdIwzMgCXwZhAVywN+s3g9Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795338969;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Message-ID:Date:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:User-Agent:Subject:Content-Language:To:Cc:
References:From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
bh=0KmhmqWZGey7mXaEaM39Yzuu4YAG3T1qaBpPiWLL0gM=;
b=jQRTVdWTluTP2VmSzN8eg6beaTzWdH9dFYiRXmj2b3JxiYRM+nuYFgGWeYuXamMaXPWZ
gaiXVIMk5x3gR2VaI8d07wQuf+FI2B7lRlm52A7QYYBrq85rtyHw4iyPJvAr4tRPtx/+P
CoixfrlturxhXG3asYj22x17d39q5n4qdtrCo9mEe+i41u/0y/sa3fCnLVWn+kRSOJzFL
ytKNdHQTMsHp8mtQ+16C9E4JU8yuMrQwn4QjflTXjR5j5+XA8mwGH9LYMr4QJI1QXMgq2
JLfEWVam+yq6RVZyLiDwIxjE0fI5ykUdJ9cS3VexDkci4OTNYKGyKuMccdkVrNqlppQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=N48KdldY;
dmarc=none header.from=blackwall.org;
spf=none smtp.mailfrom=blackwall.org;
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 25278606A334;
Sun, 22 Nov 2026 09:16:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=N48KdldY
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.52
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795338968;
b=4KntuaoWdg/N2ZLIaiQxd3H/6RWGJpj7zQMMj1IRU9bIW10eA2nR3ukQhV5XrpijWw7b
+M1ONw+U03a0HbPEpl1DQbomUTUQ937SmLBdUCie9z+wuNrMPZhFrhjPvXoPIsifybtZ9
ce1DckKTb5wNMGwvza4HIYVnGdx9MQtkTzFpvbwiUudlGtc65hAex67Q/VLrlB4hI3dUG
JVdtbB62akhci3txas2BweyHLEvwpsWdAnp4Exw4Fg6kHw2fqpPDQVNCXqBpGxzV2e920
YANxZSnm7sA4fm+bEgc3HJw1Pzwg3+7S/fBXfiJJlotQSDwiaR2cV+F6oh6LqLi3lBw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795338968;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Message-ID:Date:MIME-Version:User-Agent:Subject:Content-Language:To:
Cc:References:From:In-Reply-To:Content-Type:
Content-Transfer-Encoding;
bh=0KmhmqWZGey7mXaEaM39Yzuu4YAG3T1qaBpPiWLL0gM=;
b=zjQM5NhAtZcFnT/O7Z9IE25h3hLvdPuHEuULeIHD0BDNdCahzMXeBzraqPo+7/bWFRGk
Zkhyz8R2YFetKkIbGNiKcM+NHwdgrjqTnmAIKplu+3xBghOZcnQefMuKnmLj0LL0Gwuuq
wjEZ+VOmUYovHuu+riZ+PADEvdHw/20peta5Q03P9/1Ygat2R/6ssnUu6AiNep3N6DyVD
JFxKtZAMNmrgbYBYV+fg2/2+IVRebUe5416mayZk1AAZLCJgF4b7/W8MOCmhqQbd1DnlK
Ny4T8QF51axRqbt4GlWdFxXZTkzGk2+ASC4fLVYnB5CiqI8b2wdbhGE6CQmtzHATEvQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=none header.from=blackwall.org;
spf=none smtp.mailfrom=blackwall.org;
dkim=pass header.d=blackwall.org header.i=@blackwall.org header.a=rsa-sha256 header.s=google header.b=N48KdldY;
arc=none smtp.remote-ip=209.85.221.52
X-Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37CA5606A320
for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 09:16:07 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 37CA5606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=blackwall.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=blackwall.org
X-Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-4a2f4ca0dcfso1256573f8f.1
for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 01:16:06 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=blackwall.org; s=google; t=1795338965; x=1795943765; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:in-reply-to:from:references
:cc:to:content-language:subject:user-agent:mime-version:date
:message-id:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=0KmhmqWZGey7mXaEaM39Yzuu4YAG3T1qaBpPiWLL0gM=;
b=N48KdldYkQjaF/ngDujTZE6Al8clD0ZABH8Hwlk3by70BFtk/LFt1h1KBlEim1qTak
TscYtqyoJhYd+t2xBeovlUCH5YA13JRwUhwg/R6csWedfGyUpwtwfO1Iw5QThnf0ySiD
hCXVz61t55ZhKaYFXj+aLhrvlcBGM9S76VlycOzGpNJUl6ZxhRVQGiMCVYnu5UMaxaYC
X3pkeuuPFi2Xvif5OAaar1Qu3z8ZsZAh2qf8QT4ZAQbhA3hwaqvJQfDXYg36G2PFlf7v
SJyFZ55FrdfWRWjNovTf3iur4sD52UlCmkQyQC6IFvEPq6OguYPD4WXf2Jjun+dk3M+2
Rkmg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795338965; x=1795943765;
h=content-transfer-encoding:content-type:in-reply-to:from:references
:cc:to:content-language:subject:user-agent:mime-version:date
:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=0KmhmqWZGey7mXaEaM39Yzuu4YAG3T1qaBpPiWLL0gM=;
b=aw6ztr4dmjuwUCtbCL+tjF/LLuKr2m3zj+S37TCmSCcKuoqNxFzOkXeeVkBm5WWrUW
gXguWAqHV4u1FT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ycovsTr34Bqo1AoVtoX9IVQ11FqfHELTE5wk2aXfBfpap/VEymcFI
ZgR2f2hSUoIxTlmDvjg1/O3xMDzmJSnZf65U9CuS34OlMa7xYhI/E5V592giCFQKRIsZ3s1GwQ7
0UyYM
X-Received: by 2002:a5d:5d01:0:b0:4a7:851a:e617 with SMTP id ffacd0b85a97d-4abaac5777cmr17246463f8f.7.1795338965324;
Sun, 22 Nov 2026 01:16:05 -0800 (PST)
X-Received: from [192.168.0.161] (78-154-14-127.ip.btc-net.bg. [78.154.14.127])
by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab658e2e6dsm15828914f8f.6.2026.11.22.01.16.04
(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
Sun, 22 Nov 2026 01:16:04 -0800 (PST)
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
X-User-Agent: Mozilla Thunderbird
X-Cc: "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>,
Shuah Khan <shuah@kernel.org>, linux-kselftest@vger.kernel.org,
Weiming Shi <bestswngs@gmail.com>, Daniel Borkmann <daniel@iogearbox.net>,
David Wei <dw@davidwei.uk>, Stanislav Fomichev <sdf.kernel@gmail.com>,
Bobby Eshleman <bobbyeshleman@meta.com>
X-In-Reply-To: <20261120045918.1239746-1-almasrymina@google.com>