* [PATCH] perf trace: Fix some leaks of struct thread
@ 2025-03-31 18:46 Namhyung Kim
2025-04-01 20:23 ` Ian Rogers
2025-04-02 1:07 ` Howard Chu
0 siblings, 2 replies; 4+ messages in thread
From: Namhyung Kim @ 2025-03-31 18:46 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Howard Chu
I've found some leaks from 'perf trace -a'. It seems there are more
leaks but this is what I can find for now.
Cc: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-trace.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 3d0c0076884d34cb..10cd99888a9a11b5 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2835,7 +2835,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
e_machine = thread__e_machine(thread, trace->host);
sc = trace__syscall_info(trace, evsel, e_machine, id);
if (sc == NULL)
- return -1;
+ goto out_put;
ttrace = thread__trace(thread, trace);
/*
* We need to get ttrace just to make sure it is there when syscall__scnprintf_args()
@@ -4123,8 +4123,10 @@ static int trace__set_filter_loop_pids(struct trace *trace)
pids[nr++] = thread__tid(parent);
break;
}
+ thread__put(thread);
thread = parent;
}
+ thread__put(thread);
err = evlist__append_tp_filter_pids(trace->evlist, nr, pids);
if (!err && trace->filter_pids.map)
--
2.49.0.472.ge94155a9ec-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf trace: Fix some leaks of struct thread
2025-03-31 18:46 [PATCH] perf trace: Fix some leaks of struct thread Namhyung Kim
@ 2025-04-01 20:23 ` Ian Rogers
2025-04-02 1:07 ` Howard Chu
1 sibling, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2025-04-01 20:23 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Kan Liang, Jiri Olsa, Adrian Hunter,
Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users, Howard Chu
On Mon, Mar 31, 2025 at 11:46 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> I've found some leaks from 'perf trace -a'. It seems there are more
> leaks but this is what I can find for now.
>
> Cc: Howard Chu <howardchu95@gmail.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/builtin-trace.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 3d0c0076884d34cb..10cd99888a9a11b5 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -2835,7 +2835,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
> e_machine = thread__e_machine(thread, trace->host);
> sc = trace__syscall_info(trace, evsel, e_machine, id);
> if (sc == NULL)
> - return -1;
> + goto out_put;
> ttrace = thread__trace(thread, trace);
> /*
> * We need to get ttrace just to make sure it is there when syscall__scnprintf_args()
> @@ -4123,8 +4123,10 @@ static int trace__set_filter_loop_pids(struct trace *trace)
> pids[nr++] = thread__tid(parent);
> break;
> }
> + thread__put(thread);
> thread = parent;
> }
> + thread__put(thread);
>
> err = evlist__append_tp_filter_pids(trace->evlist, nr, pids);
> if (!err && trace->filter_pids.map)
> --
> 2.49.0.472.ge94155a9ec-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf trace: Fix some leaks of struct thread
2025-03-31 18:46 [PATCH] perf trace: Fix some leaks of struct thread Namhyung Kim
2025-04-01 20:23 ` Ian Rogers
@ 2025-04-02 1:07 ` Howard Chu
2025-04-03 5:30 ` Namhyung Kim
1 sibling, 1 reply; 4+ messages in thread
From: Howard Chu @ 2025-04-02 1:07 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang, Jiri Olsa,
Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users
Hello Namhyung,
On Mon, Mar 31, 2025 at 11:46 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> I've found some leaks from 'perf trace -a'. It seems there are more
> leaks but this is what I can find for now.
>
> Cc: Howard Chu <howardchu95@gmail.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/builtin-trace.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index 3d0c0076884d34cb..10cd99888a9a11b5 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -2835,7 +2835,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
> e_machine = thread__e_machine(thread, trace->host);
> sc = trace__syscall_info(trace, evsel, e_machine, id);
> if (sc == NULL)
> - return -1;
> + goto out_put;
> ttrace = thread__trace(thread, trace);
> /*
> * We need to get ttrace just to make sure it is there when syscall__scnprintf_args()
> @@ -4123,8 +4123,10 @@ static int trace__set_filter_loop_pids(struct trace *trace)
> pids[nr++] = thread__tid(parent);
I suggest adding a:
thread_put(parent);
here, just before the break.
> break;
> }
> + thread__put(thread);
> thread = parent;
> }
> + thread__put(thread);
>
> err = evlist__append_tp_filter_pids(trace->evlist, nr, pids);
> if (!err && trace->filter_pids.map)
> --
> 2.49.0.472.ge94155a9ec-goog
>
Thanks,
Howard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf trace: Fix some leaks of struct thread
2025-04-02 1:07 ` Howard Chu
@ 2025-04-03 5:30 ` Namhyung Kim
0 siblings, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2025-04-03 5:30 UTC (permalink / raw)
To: Howard Chu
Cc: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang, Jiri Olsa,
Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users
Hello Howard,
On Tue, Apr 01, 2025 at 06:07:15PM -0700, Howard Chu wrote:
> Hello Namhyung,
>
> On Mon, Mar 31, 2025 at 11:46 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > I've found some leaks from 'perf trace -a'. It seems there are more
> > leaks but this is what I can find for now.
> >
> > Cc: Howard Chu <howardchu95@gmail.com>
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/builtin-trace.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> > index 3d0c0076884d34cb..10cd99888a9a11b5 100644
> > --- a/tools/perf/builtin-trace.c
> > +++ b/tools/perf/builtin-trace.c
> > @@ -2835,7 +2835,7 @@ static int trace__fprintf_sys_enter(struct trace *trace, struct evsel *evsel,
> > e_machine = thread__e_machine(thread, trace->host);
> > sc = trace__syscall_info(trace, evsel, e_machine, id);
> > if (sc == NULL)
> > - return -1;
> > + goto out_put;
> > ttrace = thread__trace(thread, trace);
> > /*
> > * We need to get ttrace just to make sure it is there when syscall__scnprintf_args()
> > @@ -4123,8 +4123,10 @@ static int trace__set_filter_loop_pids(struct trace *trace)
> > pids[nr++] = thread__tid(parent);
>
> I suggest adding a:
> thread_put(parent);
> here, just before the break.
You're right, will add it.
Thanks,
Namhyung
>
> > break;
> > }
> > + thread__put(thread);
> > thread = parent;
> > }
> > + thread__put(thread);
> >
> > err = evlist__append_tp_filter_pids(trace->evlist, nr, pids);
> > if (!err && trace->filter_pids.map)
> > --
> > 2.49.0.472.ge94155a9ec-goog
> >
>
> Thanks,
> Howard
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-04-03 5:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31 18:46 [PATCH] perf trace: Fix some leaks of struct thread Namhyung Kim
2025-04-01 20:23 ` Ian Rogers
2025-04-02 1:07 ` Howard Chu
2025-04-03 5:30 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox