🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19885

Re: [PATCH net-next v4 0/7] net: devmem: support leased RX and TX queues on netdev unregister

#19885
From: Stanislav Fomichev
Date: Fri, 20 Nov 2026 17:04
90 lines
16061 bytes
On 11/20, 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

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Technical Details
Message-ID: <awB9nOahr_lP5teq@devvm16445.scu0.facebook.com>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368031-linux-kernel-netdev=dewy.ru
References: <20261120045918.1239746-1-almasrymina@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368031-linux-kernel-netdev=dewy.ru
From: sdf.kernel@gmail.com (Stanislav Fomichev)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 0/7] net: devmem: support leased RX and TX
 queues on netdev unregister
Date: Fri, 20 Nov 2026 09:04:38 -0800
Organization: Usenet Network
Message-ID: <awB9nOahr_lP5teq@devvm16445.scu0.facebook.com>
References: <20261120045918.1239746-1-almasrymina@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="3213206"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ud+dIMKAoFHpjny+0MdzHjha41o= sha256:Yop92ehK0jCgu+cnooT5da6jVuCRyYpHoalUXMtDMxc=
	sha1:GrBUdScz1Tuj/qRNoyS8rYct1OI= sha256:xla1d7px5royeT4aqyVfYdyRLiA4lWqYMOhLc44XTJg=
Content-Disposition: inline
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 A44F5115998; Fri, 20 Nov 2026 20:07:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, 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=pass (2048-bit key)
	header.d=gmail.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 NVoW9tmLvUqo;
	Fri, 20 Nov 2026 20:06:58 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-368031-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id B98E9115A0F; Fri, 20 Nov 2026 20:06:49 +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 75A14160C2C; Fri, 20 Nov 2026 17:06:37 +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=1795194397;
	b=KxNndPMJPFjgm1bFvbkxvi3qruLnsGibFAxOOu7UqZAF2MyLkbCqgcsAM0zHcXu/Zugp
	 A0DusvhMUL76TvKl6YJB8Sv5OC933IL9MSjK3brxJeItAnb3y3GA1m4e83W+oe2UQAEcS
	 gVBS+ibplEpkr0sZT1ZUUSgI3JL3tPSWnzwmQEvhDiVPvfsVAJWR0bnLTuCl73pp+yUgs
	 6c46uZvJOQai2i2BrdCiz8MqzgkTZHMCnlWxXIVxQJdhpnRz5AuJ84hnejizIATIyep2/
	 LsSil22vBh8zWYJ5fbikTCCxPbjLC18SehriyvzBZd6MGbYIDYqgax3EQKeUiZ9arbw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795194397;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Date:From:To:Cc:Subject:Message-ID:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To;
	bh=HawP4HaqSSCCRWTOg50sFxNueZcWIp4gg9tOLMEyCnI=;
	b=ar6DRFReJ7K3cyv01GGMzzIqLjVc5A0NE+fPNBRM0COYjk3tosdO9bBCFhQccWyUCT8x
	 LseunJHXddebt1CNfY4tFxyPLfruua8c/tlwONjtaKhkrMAbG90kQFK99DkB1S9nkYAH2
	 Bd3GDiwDw9Iq4tzzH9JcT/40fq17P9xGLRXYHkcRNlknZyXxcKb2fG8aCO/uX2S2YB+gp
	 2QsvuvXg9fqDV6lW4AVfqVyNSnN8oQsJlHBloDm7LySbuFhh/TnTJUp+4nO7Cm99t3PZ8
	 XwjJv7JjLngIoD3owPxzeYFp+8jBCv/3Y89QsIz9asDmw7jEtzVyCBKFUzPgE/XGZWw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=OmzPOz94;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.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 DF6FC60A2606;
	Fri, 20 Nov 2026 17:06:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=OmzPOz94
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.227.1
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795194396;
	b=Mw3eETwgCaajyBQQh772CW54Wes5Z9ZTWUv7PkGMhMWsQW30y8/SUS1ETi54AOxaIsDP
	 h3n29tzpKoz+bxdnIPSHbPxGcvVTy73eVQtyDwWS5pZktDMbV5iGkmYOBXlTdg/7QgzFU
	 q8xDEQLCurmAD3e8YfirvtQ0t12c5ssGud7s54ZBCZDR6usZJv6c3tYUb2DcdWTFOvznV
	 QkcqjRR/4bzl9j6TiPIXF/7ATfVKxPAKhtq7ioDMCHERWtLOSi6t6OqoGHza2MV75pwdi
	 CNSNZueLDhQ6Lxp75efh0Z/ahOW1t5I8cRNjlPUJqAdfOU4k7oHYNKQYJDfxbvOhCFg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795194396;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Date:From:To:Cc:
	 Subject:Message-ID:References:MIME-Version:Content-Type:
	 Content-Disposition:In-Reply-To;
	bh=HawP4HaqSSCCRWTOg50sFxNueZcWIp4gg9tOLMEyCnI=;
	b=Sfrgde426MSBL+hJ6MGikbcA9CNh1bsSryp9YehwlfPBwKLyVyAM93b8R0JT66YpiCEV
	 OSxIqjEWLnA+r+jOvxapj2MOrZK3AFT08figb4v7S9MXK3IhJHdM6FrRDtQHeprGSdqSP
	 xIwv4xKr/kVwDuzftARpBAIcyvugKOnG1NSeI+OfIw6zi64uDdLQuueQL1rPzWkS+6teY
	 5A0iYyyOxgdrGyIqBpZkEE10ENmiDFJQvXnOgGOBnUL4jUKddy9Ehtdlu5GVhEUXvydk2
	 WHsF3mWw1QDgnbwFkZZknwyxNCwfVjk7EafinZXuUyQLllaBeVwm2R8YL7u13qA4oQQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=OmzPOz94;
	arc=none smtp.remote-ip=74.125.227.1
X-Received: from mail-vs2-f1.google.com (mail-vs2-f1.google.com [74.125.227.1])
	(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 5C37A60A2626
	for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 17:06:32 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5C37A60A2626
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-vs2-f1.google.com with SMTP id ada2fe7eead31-744b7f44933so125849137.0
        for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 09:06:32 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795194391; x=1795799191; darn=vger.kernel.org;
        h=in-reply-to:content-disposition:content-type:mime-version
         :references:message-id:subject:cc:to:from:date:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=HawP4HaqSSCCRWTOg50sFxNueZcWIp4gg9tOLMEyCnI=;
        b=OmzPOz94RBlShM27Fq+3M13WAvPl95uJg/Z6jfSNfiGQ/2YfUXnilB6shAptLqaJ9P
         Q8c6SFK9FjKZAJPIDtu+JPcTkDbuz4cdB3GAZiv7jYRjnKnRTSQfEouoo/pC/znPTJx0
         10Er+1on+7/EuSkAm4mFEVsyeRSMnBy4+w86KCgmbtxuczVedutAeDaY+BPKBqieVf7d
         ikOGQgdR1/RnFxqBpWY4K4JiyVTYjF/Iesthf/IODFdnaxnKWQ4mrhaK7f239Akgx2OK
         2KfAc4k+kBguar6hDm4yDh+6GZEGikuofnRnhrelhphJWWPJEGB7NlcLQUP+GSCpl/eb
         zK+g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795194391; x=1795799191;
        h=in-reply-to:content-disposition:content-type:mime-version
         :references:message-id:subject:cc:to:from:date:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=HawP4HaqSSCCRWTOg50sFxNueZcWIp4gg9tOLMEyCnI=;
        b=hpU3doOH2jDQhrVDQo1owqbSVWs5LdnyPmHDd4+SOzyawULVJFh5Tdp129n4Agy1s/
         co7ByiKK5oqRUzo2qFEce/9oSM6V/XbfWsQ07WJLWkCVAIUF9fisaeG0W44Oo+d4G/f5
         HoHcSwHg6uCJ/REmYJ2fNi/994kvhYd1C8m+Cd1cOGbxLujFsoSDe9VvviyHA+nVsPWr
         Nc3ltQ0wTg1WlieI0124b5MmzZfPmlvED+XzgehitiwvUxyH8tND5yJkbvrlTXcD3Nua
         pYjxHEJgbY0B8WCFii34wHxAYJ3fTmpStM53Yb8CEpACz52RxQ7XEp8h6rU9ubv9w6wa
         t0jw==
X-Gm-Message-State: APuU4Z//Wdxz2tlAOzGt/G0kuAvB0v3CDzgFWC+LoBe0doSCD8zy204E
	3i5CCkpBIhpmpREoGQl8N8dwzILQJJlfc6TUolvxtO7oXbVqPh2ZGRau
X-Gm-Gg: AZFdTZeWOcAZjt+Wt+JHiUxrKKaEdopJ/OnJF2iudpBPmDf5ZB36EQ2X+E3PTGicU3I
	RkYMvoXLx3k/dspcEutp4VHHtV3hCtuPe7uWb9OcBCg6V6aiEjZihPV+sSU7w0JJFW/d/kR/8RB
	c7HBTud2Qe343wzW0wHPmzE8P1SLSFg06FJA4Snu0etbt6Z4ZBe77i9R3X8iGGIrylNu7dHJMEl
	wWjvYZvtEdb4vE7mrI1bXxKY5jzrkvMZtMIgx8qkE9nChzCiuh1MoMRQJV5kybq6GxdUzi3PvFq
	J6Q2J0NMhLBleeKR03mroPwKhTtRQZTOEzP1uq6bAnKZuKy/2ht4cigDS0oA01f6kZyLk9//ba0
	4YtZRMYBGStRoIQqM74KVjvwfPK6K/briHjfwXvM7jUFlcyLLuhl1Xpx0O0M+2VIMtSmPGySToK
	o97q1sOrkzeXRsu2OqiWq1wq9Bu/nESUTM3/vqhYOwyys/AHxnH8YWiTXwuOPcCn18P+RCArbkf
	BYrj76vDz+tXY1DvOjBAJy/fGDPLfwrwgJ8Wy+kr2MixrO/HoXcq9dCB2D/zzy3MateLANh8Wg+
	hCzZBhsNgpNl6Am0zfb5xEE=
X-Received: by 2002:a05:6102:4455:b0:7c3:8150:83e7 with SMTP id ada2fe7eead31-7d7393a4a98mr1152864137.9.1795194391043;
        Fri, 20 Nov 2026 09:06:31 -0800 (PST)
X-Received: from localhost ([2a03:2880:9ff:6c::])
        by smtp.gmail.com with ESMTPSA id ada2fe7eead31-7d6e7d784b3sm3456487137.2.2026.11.20.09.06.30
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 20 Nov 2026 09:06:30 -0800 (PST)
X-Cc: netdev@vger.kernel.org, "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>, Nikolay Aleksandrov <razor@blackwall.org>, 
	David Wei <dw@davidwei.uk>, Bobby Eshleman <bobbyeshleman@meta.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
X-In-Reply-To: <20261120045918.1239746-1-almasrymina@google.com>