[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220725184744.4e486fd6@kernel.org>
Date: Mon, 25 Jul 2022 18:47:44 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Jiri Pirko <jiri@...nulli.us>
Cc: netdev@...r.kernel.org, davem@...emloft.net, idosch@...dia.com,
petrm@...dia.com, pabeni@...hat.com, edumazet@...gle.com,
mlxsw@...dia.com, saeedm@...dia.com, snelson@...sando.io
Subject: Re: [patch net-next v4 01/12] net: devlink: make sure that
devlink_try_get() works with valid pointer during xarray iteration
On Mon, 25 Jul 2022 10:29:14 +0200 Jiri Pirko wrote:
> From: Jiri Pirko <jiri@...dia.com>
>
> Remove dependency on devlink_mutex during devlinks xarray iteration.
>
> The reason is that devlink_register/unregister() functions taking
> devlink_mutex would deadlock during devlink reload operation of devlink
> instance which registers/unregisters nested devlink instances.
>
> The devlinks xarray consistency is ensured internally by xarray.
> There is a reference taken when working with devlink using
> devlink_try_get(). But there is no guarantee that devlink pointer
> picked during xarray iteration is not freed before devlink_try_get()
> is called.
>
> Make sure that devlink_try_get() works with valid pointer.
> Achieve it by:
> 1) Splitting devlink_put() so the completion is sent only
> after grace period. Completion unblocks the devlink_unregister()
> routine, which is followed-up by devlink_free()
> 2) During devlinks xa_array iteration, get devlink pointer from xa_array
> holding RCU read lock and taking reference using devlink_try_get()
> before unlock.
>
> Signed-off-by: Jiri Pirko <jiri@...dia.com>
Reviewed-by: Jakub Kicinski <kuba@...nel.org>
Powered by blists - more mailing lists