Re: [PATCH v13 19/21] perf maps: Fix lock inversion in maps__load_first()

From: Ian Rogers

Date: Sat Nov 21 2026 - 01:45:48 EST


On Thu, Nov 19, 2026 at 9:33 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> 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.

Good catch! Commit 553d18c98a89 ("perf lock contention: Load kernel map
before lookup") removed the last caller. I'll replace this patch with
one removing maps__load_first() in v15.

Thanks,
Ian

> 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
> >
>