All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf trace: Segfault when trying to trace events by cgroup
@ 2020-10-09  6:45 Stanislav Ivanichkin
  2020-10-19  7:43 ` Stanislav Ivanichkin
  0 siblings, 1 reply; 3+ messages in thread
From: Stanislav Ivanichkin @ 2020-10-09  6:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: dmtrmonakhov

 # ./perf trace -e sched:sched_switch -G test -a sleep 1
 perf: Segmentation fault
 Obtained 11 stack frames.
 ./perf(sighandler_dump_stack+0x43) [0x55cfdc636db3]
 /lib/x86_64-linux-gnu/libc.so.6(+0x3efcf) [0x7fd23eecafcf]
 ./perf(parse_cgroups+0x36) [0x55cfdc673f36]
 ./perf(+0x3186ed) [0x55cfdc70d6ed]
 ./perf(parse_options_subcommand+0x629) [0x55cfdc70e999]
 ./perf(cmd_trace+0x9c2) [0x55cfdc5ad6d2]
 ./perf(+0x1e8ae0) [0x55cfdc5ddae0]
 ./perf(+0x1e8ded) [0x55cfdc5ddded]
 ./perf(main+0x370) [0x55cfdc556f00]
 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe6) [0x7fd23eeadb96]
 ./perf(_start+0x29) [0x55cfdc557389]
 Segmentation fault

 It happens because "struct trace" in option->value is passed to
 parse_cgroups function instead of "struct evlist".

Signed-off-by: Stanislav Ivanichkin <sivanichkin@yandex-team.ru>
Reviewed-by: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
---
 tools/perf/builtin-trace.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index bea461b6f937..cbc4de6840db 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -4651,9 +4651,12 @@ static int trace__parse_cgroups(const struct option *opt, const char *str, int u
 {
 	struct trace *trace = opt->value;
 
-	if (!list_empty(&trace->evlist->core.entries))
-		return parse_cgroups(opt, str, unset);
-
+	if (!list_empty(&trace->evlist->core.entries)) {
+		struct option o = OPT_CALLBACK('G', "cgroup", &trace->evlist,
+			"name", "monitor event in cgroup name only",
+			parse_cgroups);
+		return parse_cgroups(&o, str, unset);
+	}
 	trace->cgroup = evlist__findnew_cgroup(trace->evlist, str);
 
 	return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf trace: Segfault when trying to trace events by cgroup
  2020-10-09  6:45 [PATCH] perf trace: Segfault when trying to trace events by cgroup Stanislav Ivanichkin
@ 2020-10-19  7:43 ` Stanislav Ivanichkin
  2020-10-23  2:48   ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Stanislav Ivanichkin @ 2020-10-19  7:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Monakhov, linux-perf-users

Hi,

+linux-perf-users@

Gentle ping for this patch

Many Thanks

--
Stanislav Ivanichkin

> On 9 Oct 2020, at 09:45, Stanislav Ivanichkin <sivanichkin@yandex-team.ru> wrote:
> 
> # ./perf trace -e sched:sched_switch -G test -a sleep 1
> perf: Segmentation fault
> Obtained 11 stack frames.
> ./perf(sighandler_dump_stack+0x43) [0x55cfdc636db3]
> /lib/x86_64-linux-gnu/libc.so.6(+0x3efcf) [0x7fd23eecafcf]
> ./perf(parse_cgroups+0x36) [0x55cfdc673f36]
> ./perf(+0x3186ed) [0x55cfdc70d6ed]
> ./perf(parse_options_subcommand+0x629) [0x55cfdc70e999]
> ./perf(cmd_trace+0x9c2) [0x55cfdc5ad6d2]
> ./perf(+0x1e8ae0) [0x55cfdc5ddae0]
> ./perf(+0x1e8ded) [0x55cfdc5ddded]
> ./perf(main+0x370) [0x55cfdc556f00]
> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe6) [0x7fd23eeadb96]
> ./perf(_start+0x29) [0x55cfdc557389]
> Segmentation fault
> 
> It happens because "struct trace" in option->value is passed to
> parse_cgroups function instead of "struct evlist".
> 
> Signed-off-by: Stanislav Ivanichkin <sivanichkin@yandex-team.ru>
> Reviewed-by: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
> ---
> tools/perf/builtin-trace.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> index bea461b6f937..cbc4de6840db 100644
> --- a/tools/perf/builtin-trace.c
> +++ b/tools/perf/builtin-trace.c
> @@ -4651,9 +4651,12 @@ static int trace__parse_cgroups(const struct option *opt, const char *str, int u
> {
> 	struct trace *trace = opt->value;
> 
> -	if (!list_empty(&trace->evlist->core.entries))
> -		return parse_cgroups(opt, str, unset);
> -
> +	if (!list_empty(&trace->evlist->core.entries)) {
> +		struct option o = OPT_CALLBACK('G', "cgroup", &trace->evlist,
> +			"name", "monitor event in cgroup name only",
> +			parse_cgroups);
> +		return parse_cgroups(&o, str, unset);
> +	}
> 	trace->cgroup = evlist__findnew_cgroup(trace->evlist, str);
> 
> 	return 0;
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf trace: Segfault when trying to trace events by cgroup
  2020-10-19  7:43 ` Stanislav Ivanichkin
@ 2020-10-23  2:48   ` Namhyung Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2020-10-23  2:48 UTC (permalink / raw)
  To: Stanislav Ivanichkin; +Cc: linux-kernel, Dmitry Monakhov, linux-perf-users

Hello,

On Tue, Oct 20, 2020 at 5:48 AM Stanislav Ivanichkin
<sivanichkin@yandex-team.ru> wrote:
>
> Hi,
>
> +linux-perf-users@
>
> Gentle ping for this patch
>
> Many Thanks
>
> --
> Stanislav Ivanichkin
>
> > On 9 Oct 2020, at 09:45, Stanislav Ivanichkin <sivanichkin@yandex-team.ru> wrote:
> >
> > # ./perf trace -e sched:sched_switch -G test -a sleep 1
> > perf: Segmentation fault
> > Obtained 11 stack frames.
> > ./perf(sighandler_dump_stack+0x43) [0x55cfdc636db3]
> > /lib/x86_64-linux-gnu/libc.so.6(+0x3efcf) [0x7fd23eecafcf]
> > ./perf(parse_cgroups+0x36) [0x55cfdc673f36]
> > ./perf(+0x3186ed) [0x55cfdc70d6ed]
> > ./perf(parse_options_subcommand+0x629) [0x55cfdc70e999]
> > ./perf(cmd_trace+0x9c2) [0x55cfdc5ad6d2]
> > ./perf(+0x1e8ae0) [0x55cfdc5ddae0]
> > ./perf(+0x1e8ded) [0x55cfdc5ddded]
> > ./perf(main+0x370) [0x55cfdc556f00]
> > /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe6) [0x7fd23eeadb96]
> > ./perf(_start+0x29) [0x55cfdc557389]
> > Segmentation fault
> >
> > It happens because "struct trace" in option->value is passed to
> > parse_cgroups function instead of "struct evlist".
> >
> > Signed-off-by: Stanislav Ivanichkin <sivanichkin@yandex-team.ru>
> > Reviewed-by: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>

It seems we should add this too:
Fixes: 9ea42ba4411ac ("perf trace: Support setting cgroups as targets")

> > ---
> > tools/perf/builtin-trace.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
> > index bea461b6f937..cbc4de6840db 100644
> > --- a/tools/perf/builtin-trace.c
> > +++ b/tools/perf/builtin-trace.c
> > @@ -4651,9 +4651,12 @@ static int trace__parse_cgroups(const struct option *opt, const char *str, int u
> > {
> >       struct trace *trace = opt->value;
> >
> > -     if (!list_empty(&trace->evlist->core.entries))
> > -             return parse_cgroups(opt, str, unset);
> > -
> > +     if (!list_empty(&trace->evlist->core.entries)) {
> > +             struct option o = OPT_CALLBACK('G', "cgroup", &trace->evlist,
> > +                     "name", "monitor event in cgroup name only",
> > +                     parse_cgroups);

Just make it simple and clear what parse_cgroups() expects:

        struct option o = {
                .value = &trace->evlist,
        };

Or else, we can change parse_cgroups() to take evlist directly.
But it needs to change other callsites too.

Either is fine to me.

Thanks
Namhyung

> > +             return parse_cgroups(&o, str, unset);
> > +     }
> >       trace->cgroup = evlist__findnew_cgroup(trace->evlist, str);
> >
> >       return 0;
> > --
> > 2.17.1
> >
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-23  2:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09  6:45 [PATCH] perf trace: Segfault when trying to trace events by cgroup Stanislav Ivanichkin
2020-10-19  7:43 ` Stanislav Ivanichkin
2020-10-23  2:48   ` Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.