netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net 3/3] devlink: fix a deadlock with nested instances during namespace remove
@ 2023-05-09 10:09 Jiri Pirko
  2023-05-09 10:09 ` [patch net 1/3] net: allow to ask per-net netdevice notifier to follow netdev dynamically Jiri Pirko
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Jiri Pirko @ 2023-05-09 10:09 UTC (permalink / raw)
  To: netdev; +Cc: kuba, pabeni, davem, edumazet, jacob.e.keller, saeedm, moshe

From: Jiri Pirko <jiri@nvidia.com>

The commit 565b4824c39f ("devlink: change port event netdev notifier
from per-net to global") changed original per-net notifier to be global
which fixed the issue of non-receiving events of netdev uninit if that
moved to a different namespace. That worked fine in -net tree.

However, later on when commit ee75f1fc44dd ("net/mlx5e: Create
separate devlink instance for ethernet auxiliary device") and
commit 72ed5d5624af ("net/mlx5: Suspend auxiliary devices only in
case of PCI device suspend") were merged, a deadlock was introduced
when removing a namespace with devlink instance with another nested
instance.

Here there is the bad flow example resulting in deadlock with mlx5:
net_cleanup_work -> cleanup_net (takes down_read(&pernet_ops_rwsem) ->
devlink_pernet_pre_exit() -> devlink_reload() ->
mlx5_devlink_reload_down() -> mlx5_unload_one_devl_locked() ->
mlx5_detach_device() -> del_adev() -> mlx5e_remove() ->
mlx5e_destroy_devlink() -> devlink_free() ->
unregister_netdevice_notifier() (takes down_write(&pernet_ops_rwsem)

Steps to reproduce:
$ modprobe mlx5_core
$ ip netns add ns1
$ devlink dev reload pci/0000:08:00.0 netns ns1
$ ip netns del ns1

The first two patches are just dependencies of the last one, which is
actually fixing the issue. It converts the notifier to per per-net
again. But this time also per-devlink_port and setting to follow
the netdev to different namespace.

Jiri Pirko (3):
  net: allow to ask per-net netdevice notifier to follow netdev
    dynamically
  devlink: make netdev notifier per-port
  devlink: change port event netdev notifier to be per-net and following
    netdev

 include/linux/netdevice.h   |  6 +++++
 include/net/devlink.h       |  2 ++
 net/core/dev.c              | 34 +++++++++++++++++++++++-----
 net/devlink/core.c          |  9 --------
 net/devlink/devl_internal.h |  4 ----
 net/devlink/leftover.c      | 45 ++++++++++++++++++++++++++-----------
 6 files changed, 69 insertions(+), 31 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-10 18:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-09 10:09 [patch net 3/3] devlink: fix a deadlock with nested instances during namespace remove Jiri Pirko
2023-05-09 10:09 ` [patch net 1/3] net: allow to ask per-net netdevice notifier to follow netdev dynamically Jiri Pirko
2023-05-09 10:09 ` [patch net 2/3] devlink: make netdev notifier per-port Jiri Pirko
2023-05-09 10:09 ` [patch net 3/3] devlink: change port event netdev notifier to be per-net and following netdev Jiri Pirko
2023-05-09 20:13 ` [patch net 3/3] devlink: fix a deadlock with nested instances during namespace remove Jacob Keller
2023-05-10  3:24 ` Jakub Kicinski
2023-05-10  6:11   ` Jiri Pirko
2023-05-10 18:27   ` Jacob Keller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).