[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Zjki4arHA6DifQ1n@x1>
Date: Mon, 6 May 2024 15:35:13 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>,
James Clark <james.clark@....com>,
Athira Rajeev <atrajeev@...ux.vnet.ibm.com>,
Colin Ian King <colin.i.king@...il.com>,
nabijaczleweli@...ijaczleweli.xyz, Leo Yan <leo.yan@...ux.dev>,
Song Liu <song@...nel.org>,
Ilkka Koskinen <ilkka@...amperecomputing.com>,
Ben Gainey <ben.gainey@....com>,
K Prateek Nayak <kprateek.nayak@....com>,
Yanteng Si <siyanteng@...ngson.cn>,
Sun Haiyong <sunhaiyong@...ngson.cn>,
Changbin Du <changbin.du@...wei.com>,
Andi Kleen <ak@...ux.intel.com>,
Thomas Richter <tmricht@...ux.ibm.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Dima Kogan <dima@...retsauce.net>,
zhaimingbing <zhaimingbing@...s.chinamobile.com>,
Paran Lee <p4ranlee@...il.com>, Li Dong <lidong@...o.com>,
Tiezhu Yang <yangtiezhu@...ngson.cn>,
Chengen Du <chengen.du@...onical.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6 6/7] perf dso: Reference counting related fixes
On Mon, May 06, 2024 at 08:26:02AM -0700, Ian Rogers wrote:
> On Mon, May 6, 2024 at 7:44 AM Arnaldo Carvalho de Melo <acme@...nel.org> wrote:
> > On Sat, May 04, 2024 at 02:38:02PM -0700, Ian Rogers wrote:
> > > Ensure gets and puts are better aligned fixing reference couting
> > > checking problems.
> > >
> > > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > > ---
> > > tools/perf/util/machine.c | 4 +--
> > > tools/perf/util/map.c | 1 +
> > > tools/perf/util/symbol-elf.c | 51 ++++++++++++++++++------------------
> > > 3 files changed, 28 insertions(+), 28 deletions(-)
> > >
> > > diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> > > index 0b8fb14f5ff6..4a4541a2e887 100644
> > > --- a/tools/perf/util/machine.c
> > > +++ b/tools/perf/util/machine.c
> > > @@ -683,7 +683,7 @@ static int machine__process_ksymbol_register(struct machine *machine,
> > > struct perf_sample *sample __maybe_unused)
> > > {
> > > struct symbol *sym;
> > > - struct dso *dso;
> > > + struct dso *dso = NULL;
> > > struct map *map = maps__find(machine__kernel_maps(machine), event->ksymbol.addr);
> > > int err = 0;
> > >
> > > @@ -696,7 +696,6 @@ static int machine__process_ksymbol_register(struct machine *machine,
> > > }
> > > dso__set_kernel(dso, DSO_SPACE__KERNEL);
> > > map = map__new2(0, dso);
> > > - dso__put(dso);
> > > if (!map) {
> > > err = -ENOMEM;
> > > goto out;
> > > @@ -735,6 +734,7 @@ static int machine__process_ksymbol_register(struct machine *machine,
> > > dso__insert_symbol(dso, sym);
> > > out:
> > > map__put(map);
> > > + dso__put(dso);
> > > return err;
> > > }
> >
> > This seems to match the patch description, good, just aligning the puts
> >
> > > diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
> > > index 117c4bb78b35..e1d14936a60d 100644
> > > --- a/tools/perf/util/map.c
> > > +++ b/tools/perf/util/map.c
> > > @@ -200,6 +200,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
> > > dso__set_build_id(dso, dso__bid(header_bid_dso));
> > > dso__set_header_build_id(dso, 1);
> > > }
> > > + dso__put(header_bid_dso);
> > > }
> > > dso__put(dso);
> > > }
> >
> > But this is a missing one, so not aligning, but fixing a separate issue,
> > i.e. a missing put? Should go on a different patch, probably with a
> > Fixes.
>
> The Fixes would be for a patch in the series - albeit that we've spent
Well, if it fixes something that got merged before, it should have the
Fixes, please then have it in the patch fixing it:
Fixes: f649ed80f3cabbf1 ("perf dsos: Tidy reference counting and locking")
> over half a year landing this and a month since that change landed:
> https://lore.kernel.org/all/20240410064214.2755936-3-irogers@google.com/
> The issue is that previously a find wouldn't do a get, so per the old
> code no put is necessary. Gets were added to finds to cover the race
> between a dso being returned from dsos and the item potentially being
> removed from dsos.
The last patch applied:
⬢[acme@...lbox perf-tools-next]$ git log --oneline -1
ee756ef7491eafd7 (HEAD -> perf-tools-next, perf-tools-next.korg/tmp.perf-tools-next) perf dso: Add reference count checking and accessor functions
⬢[acme@...lbox perf-tools-next]$
Needed this, which I applied and pushed to tmp.perf-tools-next:
util/symbol.c: In function ‘dso__load_bfd_symbols’:
util/symbol.c:1683:9: error: too few arguments to function ‘dso__set_adjust_symbols’
1683 | dso__set_adjust_symbols(dso);
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from util/symbol.c:21:
util/dso.h:268:20: note: declared here
268 | static inline void dso__set_adjust_symbols(struct dso *dso, bool val)
| ^~~~~~~~~~~~~~~~~~~~~~~
make[6]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:106: /tmp/tmp.ZWHbQftdN6/util/symbol.o] Error 1
MKDIR /tmp/tmp.ZWHbQftdN6/tests/workloads/
make[6]: *** Waiting for unfinished jobs....
This was updated:
- symbols__fixup_end(&dso->symbols, false);
- symbols__fixup_duplicate(&dso->symbols);
- dso->adjust_symbols = 1;
+ symbols__fixup_end(dso__symbols(dso), false);
+ symbols__fixup_duplicate(dso__symbols(dso));
+ dso__set_adjust_symbols(dso);
But not build tested with BUILD_NONDISTRO and libbfd devel files installed
(binutils-devel on fedora), I noticed it using 'make -C tools/perf build-test'.
Add the missing argument:
symbols__fixup_end(dso__symbols(dso), false);
symbols__fixup_duplicate(dso__symbols(dso));
- dso__set_adjust_symbols(dso);
+ dso__set_adjust_symbols(dso, true);
Powered by blists - more mailing lists