[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e7cbdbf24019ba5deac18ccf5eea770d4c641455.camel@nvidia.com>
Date: Wed, 26 Mar 2025 20:57:08 +0000
From: Cosmin Ratiu <cratiu@...dia.com>
To: "stfomichev@...il.com" <stfomichev@...il.com>
CC: "kuba@...nel.org" <kuba@...nel.org>, "edumazet@...gle.com"
<edumazet@...gle.com>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"davem@...emloft.net" <davem@...emloft.net>, "pabeni@...hat.com"
<pabeni@...hat.com>, "sdf@...ichev.me" <sdf@...ichev.me>
Subject: Re: [PATCH net-next 2/9] net: hold instance lock during
NETDEV_REGISTER/UP/UNREGISTER
On Wed, 2025-03-26 at 10:49 -0700, Stanislav Fomichev wrote:
> On 03/26, Cosmin Ratiu wrote:
> > On Wed, 2025-03-26 at 08:23 -0700, Stanislav Fomichev wrote:
> > > @@ -2028,7 +2028,7 @@ int unregister_netdevice_notifier(struct
> > > notifier_block *nb)
> > >
> > > for_each_net(net) {
> > > __rtnl_net_lock(net);
> > > - call_netdevice_unregister_net_notifiers(nb, net,
> > > true);
> > > + call_netdevice_unregister_net_notifiers(nb, net,
> > > NULL);
> > > __rtnl_net_unlock(net);
> > > }
> >
> > I tested. The deadlock is back now, because dev != NULL and if the
> > lock
> > is held (like in the below stack), the mutex_lock will be attempted
> > again:
>
> I think I'm missing something. In this case I'm not sure why the
> original
> "fix" worked.
I was misinterpreting the unregister_netdevice_notifier, it's not
reached from netif_change_net_namespace. Sorry for the confusion.
It seems this is not a deadlock by reentrance, just lockdep seeing a
*potential* deadlock because the two locks have the same lock class.
And theoretically, you can deadlock if two concurrent
netif_change_net_namespace on two different devices attempt to lock
things in the wrong order. Ah, the joys of granular locking...
Am I missing some locking annotation patch? A quick search in net-next
turned out nothing.
> You, presumably, use mlx5? And you just move this single device into
> a new netns? Or there is a couple of other mlx5 devices still hanging
> in
> the root netns?
>
> I'll try to take a look more at register_netdevice_notifier_net under
> mlx5..
I see there are two mlx5-exclusive functions,
register_netdevice_notifier_net and
register_netdevice_notifier_dev_net, which I'm not yet too clear how
are used, but those don't come into play here.
For more context: I'm adding support for the new locking behavior in
mlx5, and running multiple tests which add VFs & representors and play
with netdevs & net namespaces in general.
Cosmin.
Powered by blists - more mailing lists