perf inject: Call dso__put() even if dso->hit is set
Namhyung Kim
maintainerPATCH 1/2 perf inject: Call dso__put() even if dso->hit is set
Otherwise it'll leak the refcount for the DSO. As dso__put() can handle a NULL dso pointer, we can just call it unconditionally.
--- tools/perf/builtin-inject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-inject.c +2 -2
@@ -383,8 +383,8 @@ static int perf_event__repipe_buildid_mmap(struct perf_tool *tool,if (dso && !dso->hit) { dso->hit =1 ;dso__inject_build_id (dso, tool, machine, sample->cpumode,0 ); -dso__put (dso); } +dso__put (dso);return perf_event__repipe (tool, event, sample, machine); }
@@ -447,8 +447,8 @@ static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool, dso->hit =1 ;dso__inject_build_id (dso, tool, machine, sample->cpumode, event->mmap2.flags); -dso__put (dso); } +dso__put (dso);perf_event__repipe (tool, event, sample, machine);
Signature · 1 line
2.31.1.818.g46aad6cb9e-goog
Namhyung Kim
maintainerPATCH 2/2 perf inject: Do not inject BUILD_ID record if MMAP2 has it
When PERF_RECORD_MISC_MMAP_BUILD_ID is set, the event has a build-id of the DSO already so no need to add it again.
--- tools/perf/builtin-inject.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
tools/perf/builtin-inject.c +24 -0
@@ -399,6 +399,18 @@ static int perf_event__repipe_mmap2(struct perf_tool *tool, err =perf_event__process_mmap2 (tool, event, sample, machine);perf_event__repipe (tool, event, sample, machine); +if (event->header.misc &PERF_RECORD_MISC_MMAP_BUILD_ID ) { +struct dso *dso; + + dso =findnew_dso (event->mmap2.pid, event->mmap2.tid, + event->mmap2.filename,NULL , machine); +if (dso) { +/* mark it not to inject build-id */ + dso->hit =1 ; + } +dso__put (dso); + } +return err; }
@@ -440,6 +452,18 @@ static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool, };struct dso *dso; +if (event->header.misc &PERF_RECORD_MISC_MMAP_BUILD_ID ) { +/* cannot use dso_id since it'd have invalid info */ + dso =findnew_dso (event->mmap2.pid, event->mmap2.tid, + event->mmap2.filename,NULL , machine); +if (dso) { +/* mark it not to inject build-id */ + dso->hit =1 ; + } +dso__put (dso); +return 0 ; + } + dso =findnew_dso (event->mmap2.pid, event->mmap2.tid, event->mmap2.filename, &dso_id, machine);
Signature · 1 line
2.31.1.818.g46aad6cb9e-goog
Quoted 4 lines · Namhyung Kim
Otherwise it'll leak the refcount for the DSO. As
dso__put()can handle a NULL dso pointer, we can just call it unconditionally.Signed-off-by Namhyung Kim <[email protected]>
for the patchset
thanks,
jirka
Quoted 31 lines
--- tools/perf/builtin-inject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/builtin-inject.c +2
-2@@ -383,8 +383,8 @@ static int perf_event__repipe_buildid_mmap(struct perf_tool *tool,if (dso && !dso->hit) { dso->hit =1 ;dso__inject_build_id (dso, tool, machine, sample->cpumode,0 ); -dso__put (dso); } +dso__put (dso);return perf_event__repipe (tool, event, sample, machine); }@@ -447,8 +447,8 @@ static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool, dso->hit =1 ;dso__inject_build_id (dso, tool, machine, sample->cpumode, event->mmap2.flags); -dso__put (dso); } +dso__put (dso);perf_event__repipe (tool, event, sample, machine);Signature · 1 line
2.31.1.818.g46aad6cb9e-goog
Em Wed, May 26, 2021 at 02:13:43PM +0200, Jiri Olsa escreveu:
Quoted 9 lines · Namhyung Kim
Quoted 4 lines
Otherwise it'll leak the refcount for the DSO. As
dso__put()can handle a NULL dso pointer, we can just call it unconditionally.Signed-off-by Namhyung Kim <[email protected]>for the patchset
Acked-by Jiri Olsa <[email protected]>
Thanks, applied.
- Arnaldo
Quoted 35 lines
thanks,
jirkaQuoted 31 lines
--- tools/perf/builtin-inject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/perf/builtin-inject.c +2
-2@@ -383,8 +383,8 @@ static int perf_event__repipe_buildid_mmap(struct perf_tool *tool,if (dso && !dso->hit) { dso->hit =1 ;dso__inject_build_id (dso, tool, machine, sample->cpumode,0 ); -dso__put (dso); } +dso__put (dso);return perf_event__repipe (tool, event, sample, machine); }@@ -447,8 +447,8 @@ static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool, dso->hit =1 ;dso__inject_build_id (dso, tool, machine, sample->cpumode, event->mmap2.flags); -dso__put (dso); } +dso__put (dso);perf_event__repipe (tool, event, sample, machine);Signature · 1 line
2.31.1.818.g46aad6cb9e-goog
Signature · 1 line
- Arnaldo