• Jiri Pirko's avatar
    RDMA/mlx5: Track netdev to avoid deadlock during netdev notifier unregister · dca55da0
    Jiri Pirko authored
    When removing a network namespace with mlx5 devlink instance being in
    it, following callchain is performed:
    
    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()
    mlx5r_remove()
    __mlx5_ib_remove()
    mlx5_ib_roce_cleanup()
    mlx5_remove_netdev_notifier()
    unregister_netdevice_notifier (takes down_write(&pernet_ops_rwsem)
    
    This deadlocks.
    
    Resolve this by converting to register_netdevice_notifier_dev_net()
    which does not take pernet_ops_rwsem and moves the notifier block around
    according to netdev it takes as arg.
    
    Use previously introduced netdev added/removed events to track uplink
    netdev to be used for register_netdevice_notifier_dev_net() purposes.
    Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
    Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
    Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
    dca55da0
main.c 117 KB