* [PATCH] perf stat: Fix segfault on armv8_pmu events
@ 2020-10-07 8:13 Namhyung Kim
2020-10-07 11:42 ` Jiri Olsa
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2020-10-07 8:13 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Jiri Olsa
Cc: Ingo Molnar, Peter Zijlstra, Mark Rutland, Alexander Shishkin,
LKML, Stephane Eranian, Wei Li, Barry Song
It was reported that perf stat crashed when using with armv8_pmu (cpu)
events with the task mode. As perf stat uses an empty cpu map for
task mode but armv8_pmu has its own cpu mask, it confused which map
should use when accessing file descriptors and caused segfaults:
(gdb) bt
#0 0x0000000000603fc8 in perf_evsel__close_fd_cpu (evsel=<optimized out>,
cpu=<optimized out>) at evsel.c:122
#1 perf_evsel__close_cpu (evsel=evsel@entry=0x716e950, cpu=7) at evsel.c:156
#2 0x00000000004d4718 in evlist__close (evlist=0x70a7cb0) at util/evlist.c:1242
#3 0x0000000000453404 in __run_perf_stat (argc=3, argc@entry=1, argv=0x30,
argv@entry=0xfffffaea2f90, run_idx=119, run_idx@entry=1701998435)
at builtin-stat.c:929
#4 0x0000000000455058 in run_perf_stat (run_idx=1701998435, argv=0xfffffaea2f90,
argc=1) at builtin-stat.c:947
#5 cmd_stat (argc=1, argv=0xfffffaea2f90) at builtin-stat.c:2357
#6 0x00000000004bb888 in run_builtin (p=p@entry=0x9764b8 <commands+288>,
argc=argc@entry=4, argv=argv@entry=0xfffffaea2f90) at perf.c:312
#7 0x00000000004bbb54 in handle_internal_command (argc=argc@entry=4,
argv=argv@entry=0xfffffaea2f90) at perf.c:364
#8 0x0000000000435378 in run_argv (argcp=<synthetic pointer>,
argv=<synthetic pointer>) at perf.c:408
#9 main (argc=4, argv=0xfffffaea2f90) at perf.c:538
To fix this, I simply used the given cpu map unless the evsel actually
is not a system-wide event (like uncore events).
Reported-by: Wei Li <liwei391@huawei.com>
Tested-by: Barry Song <song.bao.hua@hisilicon.com>
Fixes: 7736627b865d ("perf stat: Use affinity for closing file descriptors")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/lib/perf/evlist.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
index 2208444ecb44..cfcdbd7be066 100644
--- a/tools/lib/perf/evlist.c
+++ b/tools/lib/perf/evlist.c
@@ -45,6 +45,9 @@ static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
if (!evsel->own_cpus || evlist->has_user_cpus) {
perf_cpu_map__put(evsel->cpus);
evsel->cpus = perf_cpu_map__get(evlist->cpus);
+ } else if (!evsel->system_wide && perf_cpu_map__empty(evlist->cpus)) {
+ perf_cpu_map__put(evsel->cpus);
+ evsel->cpus = perf_cpu_map__get(evlist->cpus);
} else if (evsel->cpus != evsel->own_cpus) {
perf_cpu_map__put(evsel->cpus);
evsel->cpus = perf_cpu_map__get(evsel->own_cpus);
--
2.28.0.806.g8561365e88-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf stat: Fix segfault on armv8_pmu events
2020-10-07 8:13 [PATCH] perf stat: Fix segfault on armv8_pmu events Namhyung Kim
@ 2020-10-07 11:42 ` Jiri Olsa
2020-10-07 13:00 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2020-10-07 11:42 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra,
Mark Rutland, Alexander Shishkin, LKML, Stephane Eranian, Wei Li,
Barry Song
On Wed, Oct 07, 2020 at 05:13:11PM +0900, Namhyung Kim wrote:
> It was reported that perf stat crashed when using with armv8_pmu (cpu)
> events with the task mode. As perf stat uses an empty cpu map for
> task mode but armv8_pmu has its own cpu mask, it confused which map
> should use when accessing file descriptors and caused segfaults:
>
> (gdb) bt
> #0 0x0000000000603fc8 in perf_evsel__close_fd_cpu (evsel=<optimized out>,
> cpu=<optimized out>) at evsel.c:122
> #1 perf_evsel__close_cpu (evsel=evsel@entry=0x716e950, cpu=7) at evsel.c:156
> #2 0x00000000004d4718 in evlist__close (evlist=0x70a7cb0) at util/evlist.c:1242
> #3 0x0000000000453404 in __run_perf_stat (argc=3, argc@entry=1, argv=0x30,
> argv@entry=0xfffffaea2f90, run_idx=119, run_idx@entry=1701998435)
> at builtin-stat.c:929
> #4 0x0000000000455058 in run_perf_stat (run_idx=1701998435, argv=0xfffffaea2f90,
> argc=1) at builtin-stat.c:947
> #5 cmd_stat (argc=1, argv=0xfffffaea2f90) at builtin-stat.c:2357
> #6 0x00000000004bb888 in run_builtin (p=p@entry=0x9764b8 <commands+288>,
> argc=argc@entry=4, argv=argv@entry=0xfffffaea2f90) at perf.c:312
> #7 0x00000000004bbb54 in handle_internal_command (argc=argc@entry=4,
> argv=argv@entry=0xfffffaea2f90) at perf.c:364
> #8 0x0000000000435378 in run_argv (argcp=<synthetic pointer>,
> argv=<synthetic pointer>) at perf.c:408
> #9 main (argc=4, argv=0xfffffaea2f90) at perf.c:538
>
> To fix this, I simply used the given cpu map unless the evsel actually
> is not a system-wide event (like uncore events).
>
> Reported-by: Wei Li <liwei391@huawei.com>
> Tested-by: Barry Song <song.bao.hua@hisilicon.com>
> Fixes: 7736627b865d ("perf stat: Use affinity for closing file descriptors")
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> tools/lib/perf/evlist.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
> index 2208444ecb44..cfcdbd7be066 100644
> --- a/tools/lib/perf/evlist.c
> +++ b/tools/lib/perf/evlist.c
> @@ -45,6 +45,9 @@ static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
> if (!evsel->own_cpus || evlist->has_user_cpus) {
> perf_cpu_map__put(evsel->cpus);
> evsel->cpus = perf_cpu_map__get(evlist->cpus);
> + } else if (!evsel->system_wide && perf_cpu_map__empty(evlist->cpus)) {
> + perf_cpu_map__put(evsel->cpus);
> + evsel->cpus = perf_cpu_map__get(evlist->cpus);
> } else if (evsel->cpus != evsel->own_cpus) {
> perf_cpu_map__put(evsel->cpus);
> evsel->cpus = perf_cpu_map__get(evsel->own_cpus);
> --
> 2.28.0.806.g8561365e88-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf stat: Fix segfault on armv8_pmu events
2020-10-07 11:42 ` Jiri Olsa
@ 2020-10-07 13:00 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-10-07 13:00 UTC (permalink / raw)
To: Jiri Olsa
Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, Mark Rutland,
Alexander Shishkin, LKML, Stephane Eranian, Wei Li, Barry Song
Em Wed, Oct 07, 2020 at 01:42:19PM +0200, Jiri Olsa escreveu:
> On Wed, Oct 07, 2020 at 05:13:11PM +0900, Namhyung Kim wrote:
> > It was reported that perf stat crashed when using with armv8_pmu (cpu)
> > events with the task mode. As perf stat uses an empty cpu map for
> > task mode but armv8_pmu has its own cpu mask, it confused which map
> > should use when accessing file descriptors and caused segfaults:
> >
> > (gdb) bt
> > #0 0x0000000000603fc8 in perf_evsel__close_fd_cpu (evsel=<optimized out>,
> > cpu=<optimized out>) at evsel.c:122
> > #1 perf_evsel__close_cpu (evsel=evsel@entry=0x716e950, cpu=7) at evsel.c:156
> > #2 0x00000000004d4718 in evlist__close (evlist=0x70a7cb0) at util/evlist.c:1242
> > #3 0x0000000000453404 in __run_perf_stat (argc=3, argc@entry=1, argv=0x30,
> > argv@entry=0xfffffaea2f90, run_idx=119, run_idx@entry=1701998435)
> > at builtin-stat.c:929
> > #4 0x0000000000455058 in run_perf_stat (run_idx=1701998435, argv=0xfffffaea2f90,
> > argc=1) at builtin-stat.c:947
> > #5 cmd_stat (argc=1, argv=0xfffffaea2f90) at builtin-stat.c:2357
> > #6 0x00000000004bb888 in run_builtin (p=p@entry=0x9764b8 <commands+288>,
> > argc=argc@entry=4, argv=argv@entry=0xfffffaea2f90) at perf.c:312
> > #7 0x00000000004bbb54 in handle_internal_command (argc=argc@entry=4,
> > argv=argv@entry=0xfffffaea2f90) at perf.c:364
> > #8 0x0000000000435378 in run_argv (argcp=<synthetic pointer>,
> > argv=<synthetic pointer>) at perf.c:408
> > #9 main (argc=4, argv=0xfffffaea2f90) at perf.c:538
> >
> > To fix this, I simply used the given cpu map unless the evsel actually
> > is not a system-wide event (like uncore events).
> >
> > Reported-by: Wei Li <liwei391@huawei.com>
> > Tested-by: Barry Song <song.bao.hua@hisilicon.com>
> > Fixes: 7736627b865d ("perf stat: Use affinity for closing file descriptors")
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
Thanks, applied.
- Arnaldo
> thanks,
> jirka
>
> > ---
> > tools/lib/perf/evlist.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
> > index 2208444ecb44..cfcdbd7be066 100644
> > --- a/tools/lib/perf/evlist.c
> > +++ b/tools/lib/perf/evlist.c
> > @@ -45,6 +45,9 @@ static void __perf_evlist__propagate_maps(struct perf_evlist *evlist,
> > if (!evsel->own_cpus || evlist->has_user_cpus) {
> > perf_cpu_map__put(evsel->cpus);
> > evsel->cpus = perf_cpu_map__get(evlist->cpus);
> > + } else if (!evsel->system_wide && perf_cpu_map__empty(evlist->cpus)) {
> > + perf_cpu_map__put(evsel->cpus);
> > + evsel->cpus = perf_cpu_map__get(evlist->cpus);
> > } else if (evsel->cpus != evsel->own_cpus) {
> > perf_cpu_map__put(evsel->cpus);
> > evsel->cpus = perf_cpu_map__get(evsel->own_cpus);
> > --
> > 2.28.0.806.g8561365e88-goog
> >
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-07 13:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-07 8:13 [PATCH] perf stat: Fix segfault on armv8_pmu events Namhyung Kim
2020-10-07 11:42 ` Jiri Olsa
2020-10-07 13:00 ` Arnaldo Carvalho de Melo
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.