Re: [PATCH 1/5] maple_tree: Allow external locks to be configured with their map

From: Matthew Wilcox
Date: Thu Aug 22 2024 - 15:21:58 EST


On Thu, Aug 22, 2024 at 08:13:35PM +0100, Mark Brown wrote:
> Currently the maple tree code allows external locks to be configured by
> passing the lock itself. This is generally helpful and convenient but is

No, it's a really bad idea. Stop doing it. Use the internal lock.
It's a temporary hack we put in and I'm really regretting allowing it.

> not ideal for situations like the regmap maple tree cache where we support
> configurable locking at the regmap level and don't have the lock type when
> we are configuring the maple tree. Add a helper that allows us to pass the
> dep map directly to help with these situations. Since such code is already
> peering at the lockdep internals enough to be looking at the map no stub
> is provided.
>
> Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
> ---
> include/linux/maple_tree.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h
> index a53ad4dabd7e..bdc6b133abdc 100644
> --- a/include/linux/maple_tree.h
> +++ b/include/linux/maple_tree.h
> @@ -193,6 +193,9 @@ typedef struct lockdep_map *lockdep_map_p;
> #define mt_set_external_lock(mt, lock) \
> (mt)->ma_external_lock = &(lock)->dep_map
>
> +#define mt_set_external_lock_dep_map(mt, dep_map) \
> + (mt)->ma_external_lock = dep_map
> +
> #define mt_on_stack(mt) (mt).ma_external_lock = NULL
> #else
> typedef struct { /* nothing */ } lockdep_map_p;
>
> --
> 2.39.2
>
>
> --
> maple-tree mailing list
> maple-tree@xxxxxxxxxxxxxxxxxxx
> https://lists.infradead.org/mailman/listinfo/maple-tree