From: Jakub Kicinski <kuba@kernel.org>
To: Mina Almasry <almasrymina@google.com>, sdf@fomichev.me
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
ap420073@gmail.com, asml.silence@gmail.com, dw@davidwei.uk
Subject: Re: [PATCH net 2/2] net: avoid false positive warnings in __net_mp_close_rxq()
Date: Wed, 2 Apr 2025 18:27:19 -0700 [thread overview]
Message-ID: <20250402182719.26c390fe@kernel.org> (raw)
In-Reply-To: <20250402162428.4afc90cb@kernel.org>
On Wed, 2 Apr 2025 16:24:28 -0700 Jakub Kicinski wrote:
> On Wed, 2 Apr 2025 11:52:50 -0700 Mina Almasry wrote:
> > > netdev_lock(dev);
> > > - __net_mp_close_rxq(dev, ifq_idx, old_p);
> > > + /* Callers holding a netdev ref may get here after we already
> > > + * went thru shutdown via dev_memory_provider_uninstall().
> > > + */
> > > + if (dev->reg_state <= NETREG_REGISTERED)
> > > + __net_mp_close_rxq(dev, ifq_idx, old_p);
> >
> > Not obvious to me why this check was moved. Do you expect to call
> > __net_mp_close_rxq on an unregistered netdev and expect it to succeed
> > in io_uring binding or something?
>
> Yes, iouring state is under spin lock it can't call in here atomically.
> device unregister may race with iouring shutdown.
>
> Now that I look at it I think we need
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index be17e0660144..0a70080a1209 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -11947,6 +11947,7 @@ void unregister_netdevice_many_notify(struct list_head *head,
> unlist_netdevice(dev);
> netdev_lock(dev);
> WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERING);
> + dev_memory_provider_uninstall(dev);
> netdev_unlock(dev);
> }
> flush_all_backlogs();
> @@ -11961,7 +11962,6 @@ void unregister_netdevice_many_notify(struct list_head *head,
> dev_tcx_uninstall(dev);
> netdev_lock_ops(dev);
> dev_xdp_uninstall(dev);
> - dev_memory_provider_uninstall(dev);
> netdev_unlock_ops(dev);
> bpf_dev_bound_netdev_unregister(dev);
>
> since 1d22d3060b9b ("net: drop rtnl_lock for queue_mgmt operations")
> we drop the lock after setting UNREGISTERING so we may call .uninstall
> after iouring torn down its side.
>
> Right, Stan?
Actually, if I don't split the check here things will just work.
Let me do that in v2. Thanks for flagging!
next prev parent reply other threads:[~2025-04-03 1:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 19:42 [PATCH net 0/2] net: make memory provider install / close paths more common Jakub Kicinski
2025-03-31 19:43 ` [PATCH net 1/2] net: move mp dev config validation to __net_mp_open_rxq() Jakub Kicinski
2025-03-31 20:39 ` Stanislav Fomichev
2025-04-01 11:37 ` Pavel Begunkov
2025-04-01 15:00 ` Jakub Kicinski
2025-04-02 12:22 ` Pavel Begunkov
2025-04-02 18:46 ` Mina Almasry
2025-03-31 19:43 ` [PATCH net 2/2] net: avoid false positive warnings in __net_mp_close_rxq() Jakub Kicinski
2025-03-31 20:41 ` Stanislav Fomichev
2025-04-02 18:52 ` Mina Almasry
2025-04-02 23:24 ` Jakub Kicinski
2025-04-03 1:27 ` Jakub Kicinski [this message]
2025-04-02 15:35 ` [PATCH net 0/2] net: make memory provider install / close paths more common Taehee Yoo
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=20250402182719.26c390fe@kernel.org \
--to=kuba@kernel.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=asml.silence@gmail.com \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.