[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBL3nVZ4LVWUPRva@localhost.localdomain>
Date: Thu, 16 Mar 2023 12:03:57 +0100
From: Lorenzo Bianconi <lorenzo@...nel.org>
To: Tariq Toukan <ttoukan.linux@...il.com>
Cc: Jakub Kicinski <kuba@...nel.org>, davem@...emloft.net,
netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
ast@...nel.org, daniel@...earbox.net, hawk@...nel.org,
john.fastabend@...il.com, tariqt@...dia.com, bpf@...r.kernel.org
Subject: Re: [PATCH net] net: xdp: don't call notifiers during driver init
>
>
> On 16/03/2023 2:29, Jakub Kicinski wrote:
> > Drivers will commonly perform feature setting during init, if they use
> > the xdp_set_features_flag() helper they'll likely run into an ASSERT_RTNL()
> > inside call_netdevice_notifiers_info().
> >
> > Don't call the notifier until the device is actually registered.
> > Nothing should be tracking the device until its registered.
> >
> > Fixes: 4d5ab0ad964d ("net/mlx5e: take into account device reconfiguration for xdp_features flag")
> > Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> > ---
> > CC: ast@...nel.org
> > CC: daniel@...earbox.net
> > CC: hawk@...nel.org
> > CC: john.fastabend@...il.com
> > CC: lorenzo@...nel.org
> > CC: tariqt@...dia.com
> > CC: bpf@...r.kernel.org
> > ---
> > net/core/xdp.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/net/core/xdp.c b/net/core/xdp.c
> > index 87e654b7d06c..5722a1fc6e9e 100644
> > --- a/net/core/xdp.c
> > +++ b/net/core/xdp.c
> > @@ -781,6 +781,9 @@ void xdp_set_features_flag(struct net_device *dev, xdp_features_t val)
> > return;
> > dev->xdp_features = val;
> > +
> > + if (dev->reg_state < NETREG_REGISTERED)
> > + return;
>
> I maybe need to dig deeper, but, it looks strange to still
> call_netdevice_notifiers in cases > NETREG_REGISTERED.
>
> Isn't it problematic to call it with NETREG_UNREGISTERED ?
>
> For comparison, netif_set_real_num_tx_queues has this ASSERT_RTNL() only
> under dev->reg_state == NETREG_REGISTERED || dev->reg_state ==
> NETREG_UNREGISTERING.
does it make sense to run call_netdevice_notifiers() in xdp_set_features_flag()
just if dev->reg_state is NETREG_REGISTERED?
Moreover, looking at the code it seems netdev code can run with dev->reg_state
set to NETREG_UNREGISTERED and without holding RTNL lock, right?
Regards,
Lorenzo
>
> > call_netdevice_notifiers(NETDEV_XDP_FEAT_CHANGE, dev);
> > }
> > EXPORT_SYMBOL_GPL(xdp_set_features_flag);
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists