[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <88f371f0-206b-a923-7e24-5631de1e7b4d@intel.com>
Date: Wed, 10 May 2023 11:27:29 -0700
From: Jacob Keller <jacob.e.keller@...el.com>
To: Jakub Kicinski <kuba@...nel.org>, Jiri Pirko <jiri@...nulli.us>
CC: <netdev@...r.kernel.org>, <pabeni@...hat.com>, <davem@...emloft.net>,
<edumazet@...gle.com>, <saeedm@...dia.com>, <moshe@...dia.com>
Subject: Re: [patch net 3/3] devlink: fix a deadlock with nested instances
during namespace remove
On 5/9/2023 8:24 PM, Jakub Kicinski wrote:
> On Tue, 9 May 2023 12:09:36 +0200 Jiri Pirko wrote:
>> 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)
>
> Why don't we have a single, static notifier for all of devlink?
> Why the per device/per port notifiers?
>
> We have the devlink port pointer in struct net_device, resolving from
> a global event to the correct devlink instance is trivial.
Ok, so if I think through all the possibilities:
1. Originally we had a namespace specific notifier for each struct devlink.
2. Then we added a global notifier for all namespaces, but still had one
for each devlink.
3. Then Jiri's proposal here was a per-namespace notifier per port, but
we then we follow the namespace when the netdev changes namespaces.
But its simpler to just have a single global notifier that is setup once
for all devlinks. Then, when we get a notification, instead of looking
up the devlink instance from the notifier using container_of we look it
up through the netdev->devlink_port connection.
Ya that seems a lot simpler and requires only one notifier instead, and
wouldn't require namespace following code.
I think that makes a lot of sense.
Powered by blists - more mailing lists