Re: [PATCH v13 19/21] perf maps: Fix lock inversion in maps__load_first()
From: Namhyung Kim
Date: Fri Nov 20 2026 - 00:33:53 EST
On Fri, Nov 13, 2026 at 08:41:50AM -0800, Ian Rogers wrote:
> In maps__load_first(), take a reference to the first map and drop
> maps__lock(maps) before calling map__load() to avoid a read-to-write
> self-deadlock when loading kernel maps inserts extra trampoline maps.
It seems this function is not used anymore.
Thanks,
Namhyung
>
> Fixes: e77b0236cd0c ("perf maps: Add maps__load_first()")
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/util/maps.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c
> index f808df2fe77b..7ca33e5218e7 100644
> --- a/tools/perf/util/maps.c
> +++ b/tools/perf/util/maps.c
> @@ -1459,10 +1459,15 @@ int maps__merge_in(struct maps *kmaps, struct map *new_map)
>
> void maps__load_first(struct maps *maps)
> {
> - down_read(maps__lock(maps));
> + struct map *first = NULL;
>
> + down_read(maps__lock(maps));
> if (maps__nr_maps(maps) > 0)
> - map__load(maps__maps_by_address(maps)[0]);
> -
> + first = map__get(maps__maps_by_address(maps)[0]);
> up_read(maps__lock(maps));
> +
> + if (first) {
> + map__load(first);
> + map__put(first);
> + }
> }
> --
> 2.56.1.703.gf848ed807c-goog
>