From: Paolo Abeni <pabeni@redhat.com>
To: Mina Almasry <almasrymina@google.com>, netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, 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>,
Stanislav Fomichev <sdf.kernel@gmail.com>,
Bobby Eshleman <bobbyeshleman@meta.com>,
Stanislav Fomichev <sdf@fomichev.me>
Subject: Re: [PATCH net-next v4 3/7] net: guard memory provider RX queue open and close on unregister
Date: Tue, 24 Nov 2026 12:07:20 +0100 [thread overview]
Message-ID: <adb6840a-26cc-4b66-a732-abe9f6bba60f@redhat.com> (raw)
In-Reply-To: <20261120045918.1239746-4-almasrymina@google.com>
On 11/20/26 05:59, Mina Almasry wrote:
> When an RX queue is leased from a physical backing net_device to a
> virtual net_device (e.g., netkit), memory provider operations reach the
> physical net_device through rxq->lease and lock it directly via
> netdev_lock(dev) rather than looking it up via
> netdev_get_by_index_lock().
>
> Introduce a netif_lease_valid() helper checking netif_is_alive(dev)
> under netdev_lock(dev) and use it in the lease-aware callers while
> keeping __netif_mp_open_rxq() and __netif_mp_close_rxq() unaware of
> queue leasing:
>
> 1. In netif_mp_open_rxq(), if the leased physical device is already
> unregistering (!netif_lease_valid(dev)), netdev_get_by_index_lock()
> on the virtual netdev succeeds before cascaded unregistration runs,
> allowing a new memory provider to be installed on the physical device
> while it is unregistering. Reject the open with -ENODEV.
>
> 2. In netif_mp_close_rxq() and netif_rxq_cleanup_unlease(),
> __netif_mp_close_rxq() reconfigures the physical RX queue so that it
> can continue operating with a regular page_pool when the physical
> netdev outlives the virtual queue or memory provider. When the
> physical backing netdev is itself unregistering
> (!netif_lease_valid(dev)), its queue will not outlive the lease and,
> matching the non-leased unregistration path (where
> dev_memory_provider_uninstall() detaches the provider without calling
> netdev_rx_queue_reconfig()), the physical queue should not be
> reconfigured. However, unlike non-leased queues,
> mp_dmabuf_devmem_uninstall() on the physical netdev does not match
> bound_rxqs (which stores the virtual rxq), leaving
> phys_rxq->mp_params populated until socket teardown or the virtual
> leasee's netif_rxq_cleanup_unlease() runs. When
> !netif_lease_valid(dev), skip __netif_mp_close_rxq() and clear
> mp_params on the physical queue directly so that a subsequent
> netif_rxq_cleanup_unlease() or dev_memory_provider_uninstall() sees
> !mp_ops and does not uninstall a second time.
>
> These issues were discovered during AI code review (Sashiko) of the
> earlier non-leased devmem unregister series 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.
>
> Suggested-by: Stanislav Fomichev <sdf@fomichev.me>
> Signed-off-by: Mina Almasry <almasrymina@google.com>
> ---
> net/core/dev.h | 7 +++++++
> net/core/netdev_rx_queue.c | 31 ++++++++++++++++++++++++++-----
> 2 files changed, 33 insertions(+), 5 deletions(-)
>
> diff --git a/net/core/dev.h b/net/core/dev.h
> index 4e9e8cd156977..50cfede051db1 100644
> --- a/net/core/dev.h
> +++ b/net/core/dev.h
> @@ -119,6 +119,13 @@ bool netif_rxq_has_mp(struct net_device *dev, unsigned int rxq_idx);
> bool netif_rxq_is_leased(struct net_device *dev, unsigned int rxq_idx);
> bool netif_is_queue_leasee(const struct net_device *dev);
>
> +static inline bool netif_lease_valid(const struct net_device *dev)
> +{
> + netdev_assert_locked(dev);
> +
> + return netif_is_alive(dev);
> +}
> +
> void __netif_mp_uninstall_rxq(struct netdev_rx_queue *rxq,
> const struct pp_memory_provider_params *p);
>
> diff --git a/net/core/netdev_rx_queue.c b/net/core/netdev_rx_queue.c
> index a7261fedd5e76..98b51b2ac8ee1 100644
> --- a/net/core/netdev_rx_queue.c
> +++ b/net/core/netdev_rx_queue.c
> @@ -270,7 +270,12 @@ int netif_mp_open_rxq(struct net_device *dev, unsigned int rxq_idx,
> }
>
> netdev_lock(dev);
> - ret = __netif_mp_open_rxq(dev, rxq_idx, p, extack);
> + if (netif_lease_valid(dev)) {
> + ret = __netif_mp_open_rxq(dev, rxq_idx, p, extack);
I'm sorry for the late feedback, but it looks like the above patter could/should
be embedded into a single helper?
I mean something alike:
bool netif_lock_if_alive(const struct net_device *dev)
{
netdev_lock(dev);
if (netif_is_alive(dev))
return true;
netdev_unlock(dev);
return false;
}
That could be possibly later used elsewhere.
Other opinions welcome!
/P
next prev parent reply other threads:[~2026-11-24 11:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 4:59 [PATCH net-next v4 0/7] net: devmem: support leased RX and TX queues on netdev unregister Mina Almasry
2026-11-20 4:59 ` [PATCH net-next v4 1/7] net: devmem: pass net_device pointer to net_devmem_lock_dev() Mina Almasry
2026-11-20 4:59 ` [PATCH net-next v4 2/7] net: devmem: rename binding dev and vdev to map_dev and bind_dev Mina Almasry
2026-11-20 4:59 ` [PATCH net-next v4 3/7] net: guard memory provider RX queue open and close on unregister Mina Almasry
2026-11-23 4:59 ` netdev-bot+sashiko
2026-11-24 11:07 ` Paolo Abeni [this message]
2026-11-20 4:59 ` [PATCH net-next v4 4/7] net: devmem: fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() Mina Almasry
2026-11-23 4:59 ` netdev-bot+sashiko
2026-11-20 4:59 ` [PATCH net-next v4 5/7] net: devmem: always populate bind_dev and detach both devices on unregister Mina Almasry
2026-11-23 4:59 ` netdev-bot+sashiko
2026-11-23 15:09 ` Mina Almasry
2026-11-24 11:26 ` Paolo Abeni
2026-11-20 4:59 ` [PATCH net-next v4 6/7] net: devmem: resolve physical map_dev for leased RX bindings Mina Almasry
2026-11-23 4:59 ` netdev-bot+sashiko
2026-11-20 4:59 ` [PATCH net-next v4 7/7] selftests: net: add leased devmem RX and TX netdev unregister tests Mina Almasry
2026-11-20 17:04 ` [PATCH net-next v4 0/7] net: devmem: support leased RX and TX queues on netdev unregister Stanislav Fomichev
2026-11-22 9:16 ` Nikolay Aleksandrov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adb6840a-26cc-4b66-a732-abe9f6bba60f@redhat.com \
--to=pabeni@redhat.com \
--cc=almasrymina@google.com \
--cc=bestswngs@gmail.com \
--cc=bobbyeshleman@meta.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=razor@blackwall.org \
--cc=sdf.kernel@gmail.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox