* [PATCH] perf metricgroup: Fix segmentation fault for metrics with no pmu event
@ 2021-02-02 2:24 Jin Yao
2021-02-02 8:15 ` John Garry
0 siblings, 1 reply; 6+ messages in thread
From: Jin Yao @ 2021-02-02 2:24 UTC (permalink / raw)
To: acme, jolsa, peterz, mingo, alexander.shishkin
Cc: Linux-kernel, ak, kan.liang, yao.jin, john.garry, Jin Yao
Hit a segmentation fault for DRAM_BW_Use on SKL/KBL.
# perf stat -M DRAM_BW_Use -a -- sleep 1
Segmentation fault (core dumped)
(gdb) backtrace
#0 __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:31
#1 0x0000555c9facd9ce in find_evsel_group (evlist_used=0x555ca16d09c0, metric_events=0x555ca16e9160, has_constraint=false, metric_no_merge=false,
pctx=0x555ca16c8ff0, perf_evlist=0x555ca16c5340) at util/metricgroup.c:281
#2 metricgroup__setup_events (metric_events_list=0x555ca0044378 <stat_config+280>, perf_evlist=0x555ca16c5340, metric_no_merge=<optimized out>,
groups=0x7ffc599193f0) at util/metricgroup.c:323
#3 parse_groups (perf_evlist=perf_evlist@entry=0x555ca16c5340, str=str@entry=0x7ffc599205f8 "DRAM_BW_Use", metric_no_group=metric_no_group@entry=false,
metric_no_merge=metric_no_merge@entry=false, fake_pmu=fake_pmu@entry=0x0, metric_events=metric_events@entry=0x555ca0044378 <stat_config+280>,
map=0x555ca004e780 <pmu_events_map+768>) at util/metricgroup.c:1235
#4 0x0000555c9face096 in metricgroup__parse_groups (opt=<optimized out>, str=0x7ffc599205f8 "DRAM_BW_Use", metric_no_group=<optimized out>,
metric_no_merge=<optimized out>, metric_events=0x555ca0044378 <stat_config+280>) at util/metricgroup.c:1253
#5 0x0000555c9fbd084e in get_value (p=p@entry=0x7ffc599196b0, opt=0x555ca0043f60 <stat_options+4032>, flags=flags@entry=1) at parse-options.c:251
#6 0x0000555c9fbd1aa2 in parse_short_opt (options=<optimized out>, p=<optimized out>) at parse-options.c:351
#7 parse_options_step (usagestr=0x7ffc59919830, options=0x555ca0042fa0 <stat_options>, ctx=0x7ffc599196b0) at parse-options.c:539
#8 parse_options_subcommand (argc=argc@entry=7, argv=argv@entry=0x7ffc5991e6c0, options=options@entry=0x555ca0042fa0 <stat_options>,
subcommands=subcommands@entry=0x7ffc59919840, usagestr=usagestr@entry=0x7ffc59919830, flags=flags@entry=2) at parse-options.c:654
#9 0x0000555c9fa15154 in cmd_stat (argc=7, argv=0x7ffc5991e6c0) at builtin-stat.c:2136
#10 0x0000555c9fa8bafd in run_builtin (p=0x555ca004df20 <commands+288>, argc=7, argv=0x7ffc5991e6c0) at perf.c:312
#11 0x0000555c9f9f413a in handle_internal_command (argv=0x7ffc5991e6c0, argc=7) at perf.c:364
#12 run_argv (argcp=<synthetic pointer>, argv=<synthetic pointer>) at perf.c:408
#13 main (argc=7, argv=0x7ffc5991e6c0) at perf.c:538
DRAM_BW_Use uses an event 'duration_time' but it doesn't have pmu, so
ev->leader->pmu_name is NULL for this case. See following code piece:
!strcmp(ev->leader->pmu_name,
metric_events[i]->leader->pmu_name)
It causes the segmentation fault. Now check the pmu_name before strcmp.
Fixes: c2337d67199a("perf metricgroup: Fix metrics using aliases covering multiple PMUs")
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
tools/perf/util/metricgroup.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index ee94d3e8dd65..a36a1305c506 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -280,6 +280,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
*/
if (!has_constraint &&
ev->leader != metric_events[i]->leader &&
+ ev->leader->pmu_name &&
!strcmp(ev->leader->pmu_name,
metric_events[i]->leader->pmu_name))
break;
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] perf metricgroup: Fix segmentation fault for metrics with no pmu event
2021-02-02 2:24 [PATCH] perf metricgroup: Fix segmentation fault for metrics with no pmu event Jin Yao
@ 2021-02-02 8:15 ` John Garry
2021-02-03 0:46 ` Jin, Yao
0 siblings, 1 reply; 6+ messages in thread
From: John Garry @ 2021-02-02 8:15 UTC (permalink / raw)
To: Jin Yao, acme, jolsa, peterz, mingo, alexander.shishkin
Cc: Linux-kernel, ak, kan.liang, yao.jin
On 02/02/2021 02:24, Jin Yao wrote:
> Hit a segmentation fault for DRAM_BW_Use on SKL/KBL.
>
> # perf stat -M DRAM_BW_Use -a -- sleep 1
>
> Segmentation fault (core dumped)
>
> (gdb) backtrace
> #0 __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:31
> #1 0x0000555c9facd9ce in find_evsel_group (evlist_used=0x555ca16d09c0, metric_events=0x555ca16e9160, has_constraint=false, metric_no_merge=false,
> pctx=0x555ca16c8ff0, perf_evlist=0x555ca16c5340) at util/metricgroup.c:281
> #2 metricgroup__setup_events (metric_events_list=0x555ca0044378 <stat_config+280>, perf_evlist=0x555ca16c5340, metric_no_merge=<optimized out>,
> groups=0x7ffc599193f0) at util/metricgroup.c:323
> #3 parse_groups (perf_evlist=perf_evlist@entry=0x555ca16c5340, str=str@entry=0x7ffc599205f8 "DRAM_BW_Use", metric_no_group=metric_no_group@entry=false,
> metric_no_merge=metric_no_merge@entry=false, fake_pmu=fake_pmu@entry=0x0, metric_events=metric_events@entry=0x555ca0044378 <stat_config+280>,
> map=0x555ca004e780 <pmu_events_map+768>) at util/metricgroup.c:1235
> #4 0x0000555c9face096 in metricgroup__parse_groups (opt=<optimized out>, str=0x7ffc599205f8 "DRAM_BW_Use", metric_no_group=<optimized out>,
> metric_no_merge=<optimized out>, metric_events=0x555ca0044378 <stat_config+280>) at util/metricgroup.c:1253
> #5 0x0000555c9fbd084e in get_value (p=p@entry=0x7ffc599196b0, opt=0x555ca0043f60 <stat_options+4032>, flags=flags@entry=1) at parse-options.c:251
> #6 0x0000555c9fbd1aa2 in parse_short_opt (options=<optimized out>, p=<optimized out>) at parse-options.c:351
> #7 parse_options_step (usagestr=0x7ffc59919830, options=0x555ca0042fa0 <stat_options>, ctx=0x7ffc599196b0) at parse-options.c:539
> #8 parse_options_subcommand (argc=argc@entry=7, argv=argv@entry=0x7ffc5991e6c0, options=options@entry=0x555ca0042fa0 <stat_options>,
> subcommands=subcommands@entry=0x7ffc59919840, usagestr=usagestr@entry=0x7ffc59919830, flags=flags@entry=2) at parse-options.c:654
> #9 0x0000555c9fa15154 in cmd_stat (argc=7, argv=0x7ffc5991e6c0) at builtin-stat.c:2136
> #10 0x0000555c9fa8bafd in run_builtin (p=0x555ca004df20 <commands+288>, argc=7, argv=0x7ffc5991e6c0) at perf.c:312
> #11 0x0000555c9f9f413a in handle_internal_command (argv=0x7ffc5991e6c0, argc=7) at perf.c:364
> #12 run_argv (argcp=<synthetic pointer>, argv=<synthetic pointer>) at perf.c:408
> #13 main (argc=7, argv=0x7ffc5991e6c0) at perf.c:538
>
> DRAM_BW_Use uses an event 'duration_time' but it doesn't have pmu, so
> ev->leader->pmu_name is NULL for this case. See following code piece:
>
> !strcmp(ev->leader->pmu_name,
> metric_events[i]->leader->pmu_name)
>
> It causes the segmentation fault. Now check the pmu_name before strcmp.
>
> Fixes: c2337d67199a("perf metricgroup: Fix metrics using aliases covering multiple PMUs")
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
This should be fixed in v5.11-rc6 - please check it.
9c880c24cb0d perf metricgroup: Fix for metrics containing duration_time
Thanks,
John
> ---
> tools/perf/util/metricgroup.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index ee94d3e8dd65..a36a1305c506 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -280,6 +280,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
> */
> if (!has_constraint &&
> ev->leader != metric_events[i]->leader &&
> + ev->leader->pmu_name &&
> !strcmp(ev->leader->pmu_name,
> metric_events[i]->leader->pmu_name))
> break;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf metricgroup: Fix segmentation fault for metrics with no pmu event
2021-02-02 8:15 ` John Garry
@ 2021-02-03 0:46 ` Jin, Yao
2021-02-03 8:28 ` John Garry
2021-02-03 15:36 ` Arnaldo Carvalho de Melo
0 siblings, 2 replies; 6+ messages in thread
From: Jin, Yao @ 2021-02-03 0:46 UTC (permalink / raw)
To: John Garry, acme, jolsa, peterz, mingo, alexander.shishkin
Cc: Linux-kernel, ak, kan.liang, yao.jin
Hi John,
On 2/2/2021 4:15 PM, John Garry wrote:
> On 02/02/2021 02:24, Jin Yao wrote:
>> Hit a segmentation fault for DRAM_BW_Use on SKL/KBL.
>>
>> # perf stat -M DRAM_BW_Use -a -- sleep 1
>>
>> Segmentation fault (core dumped)
>>
>> (gdb) backtrace
>> #0 __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:31
>> #1 0x0000555c9facd9ce in find_evsel_group (evlist_used=0x555ca16d09c0,
>> metric_events=0x555ca16e9160, has_constraint=false, metric_no_merge=false,
>> pctx=0x555ca16c8ff0, perf_evlist=0x555ca16c5340) at util/metricgroup.c:281
>> #2 metricgroup__setup_events (metric_events_list=0x555ca0044378 <stat_config+280>,
>> perf_evlist=0x555ca16c5340, metric_no_merge=<optimized out>,
>> groups=0x7ffc599193f0) at util/metricgroup.c:323
>> #3 parse_groups (perf_evlist=perf_evlist@entry=0x555ca16c5340, str=str@entry=0x7ffc599205f8
>> "DRAM_BW_Use", metric_no_group=metric_no_group@entry=false,
>> metric_no_merge=metric_no_merge@entry=false, fake_pmu=fake_pmu@entry=0x0,
>> metric_events=metric_events@entry=0x555ca0044378 <stat_config+280>,
>> map=0x555ca004e780 <pmu_events_map+768>) at util/metricgroup.c:1235
>> #4 0x0000555c9face096 in metricgroup__parse_groups (opt=<optimized out>, str=0x7ffc599205f8
>> "DRAM_BW_Use", metric_no_group=<optimized out>,
>> metric_no_merge=<optimized out>, metric_events=0x555ca0044378 <stat_config+280>) at
>> util/metricgroup.c:1253
>> #5 0x0000555c9fbd084e in get_value (p=p@entry=0x7ffc599196b0, opt=0x555ca0043f60
>> <stat_options+4032>, flags=flags@entry=1) at parse-options.c:251
>> #6 0x0000555c9fbd1aa2 in parse_short_opt (options=<optimized out>, p=<optimized out>) at
>> parse-options.c:351
>> #7 parse_options_step (usagestr=0x7ffc59919830, options=0x555ca0042fa0 <stat_options>,
>> ctx=0x7ffc599196b0) at parse-options.c:539
>> #8 parse_options_subcommand (argc=argc@entry=7, argv=argv@entry=0x7ffc5991e6c0,
>> options=options@entry=0x555ca0042fa0 <stat_options>,
>> subcommands=subcommands@entry=0x7ffc59919840, usagestr=usagestr@entry=0x7ffc59919830,
>> flags=flags@entry=2) at parse-options.c:654
>> #9 0x0000555c9fa15154 in cmd_stat (argc=7, argv=0x7ffc5991e6c0) at builtin-stat.c:2136
>> #10 0x0000555c9fa8bafd in run_builtin (p=0x555ca004df20 <commands+288>, argc=7,
>> argv=0x7ffc5991e6c0) at perf.c:312
>> #11 0x0000555c9f9f413a in handle_internal_command (argv=0x7ffc5991e6c0, argc=7) at perf.c:364
>> #12 run_argv (argcp=<synthetic pointer>, argv=<synthetic pointer>) at perf.c:408
>> #13 main (argc=7, argv=0x7ffc5991e6c0) at perf.c:538
>>
>> DRAM_BW_Use uses an event 'duration_time' but it doesn't have pmu, so
>> ev->leader->pmu_name is NULL for this case. See following code piece:
>>
>> !strcmp(ev->leader->pmu_name,
>> metric_events[i]->leader->pmu_name)
>>
>> It causes the segmentation fault. Now check the pmu_name before strcmp.
>>
>> Fixes: c2337d67199a("perf metricgroup: Fix metrics using aliases covering multiple PMUs")
>> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
>
> This should be fixed in v5.11-rc6 - please check it.
>
> 9c880c24cb0d perf metricgroup: Fix for metrics containing duration_time
>
> Thanks,
> John
Oh, I see, your patch is in Arnaldo's perf/urgent branch. Sorry about that, I just tested Arnaldo's
perf/core branch. :(
Thanks
Jin Yao
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf metricgroup: Fix segmentation fault for metrics with no pmu event
2021-02-03 0:46 ` Jin, Yao
@ 2021-02-03 8:28 ` John Garry
2021-03-05 17:35 ` Arnaldo Carvalho de Melo
2021-02-03 15:36 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 6+ messages in thread
From: John Garry @ 2021-02-03 8:28 UTC (permalink / raw)
To: Jin, Yao, acme, jolsa, peterz, mingo, alexander.shishkin
Cc: Linux-kernel, ak, kan.liang, yao.jin
On 03/02/2021 00:46, Jin, Yao wrote:
>>
>> This should be fixed in v5.11-rc6 - please check it.
>>
>> 9c880c24cb0d perf metricgroup: Fix for metrics containing duration_time
>>
>> Thanks,
>> John
>
> Oh, I see, your patch is in Arnaldo's perf/urgent branch. Sorry about
> that, I just tested Arnaldo's perf/core branch. :(
Yeah, I'm not sure on the policy to merge back/rebase there. But sorry
for the hassle with this issue.
john
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf metricgroup: Fix segmentation fault for metrics with no pmu event
2021-02-03 0:46 ` Jin, Yao
2021-02-03 8:28 ` John Garry
@ 2021-02-03 15:36 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-02-03 15:36 UTC (permalink / raw)
To: Jin, Yao
Cc: John Garry, jolsa, peterz, mingo, alexander.shishkin,
Linux-kernel, ak, kan.liang, yao.jin
Em Wed, Feb 03, 2021 at 08:46:52AM +0800, Jin, Yao escreveu:
> On 2/2/2021 4:15 PM, John Garry wrote:
> > On 02/02/2021 02:24, Jin Yao wrote:
> > > It causes the segmentation fault. Now check the pmu_name before strcmp.
> > > Fixes: c2337d67199a("perf metricgroup: Fix metrics using aliases covering multiple PMUs")
> > > Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> > This should be fixed in v5.11-rc6 - please check it.
> > 9c880c24cb0d perf metricgroup: Fix for metrics containing duration_time
> Oh, I see, your patch is in Arnaldo's perf/urgent branch. Sorry about that,
> I just tested Arnaldo's perf/core branch. :(
As soon as I finish processing patches today and get perf/core thru the
usual set of tests, it'll all be in perf/core.
- Arnaldo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] perf metricgroup: Fix segmentation fault for metrics with no pmu event
2021-02-03 8:28 ` John Garry
@ 2021-03-05 17:35 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-03-05 17:35 UTC (permalink / raw)
To: John Garry
Cc: Jin, Yao, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel,
ak, kan.liang, yao.jin
Em Wed, Feb 03, 2021 at 08:28:23AM +0000, John Garry escreveu:
> On 03/02/2021 00:46, Jin, Yao wrote:
> > >
> > > This should be fixed in v5.11-rc6 - please check it.
> > >
> > > 9c880c24cb0d perf metricgroup: Fix for metrics containing duration_time
> > >
> > > Thanks,
> > > John
> >
> > Oh, I see, your patch is in Arnaldo's perf/urgent branch. Sorry about
> > that, I just tested Arnaldo's perf/core branch. :(
>
> Yeah, I'm not sure on the policy to merge back/rebase there. But sorry for
> the hassle with this issue.
I merge into perf/core as soon as perf/urgent is upstream.
- Arnaldo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-03-05 17:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 2:24 [PATCH] perf metricgroup: Fix segmentation fault for metrics with no pmu event Jin Yao
2021-02-02 8:15 ` John Garry
2021-02-03 0:46 ` Jin, Yao
2021-02-03 8:28 ` John Garry
2021-03-05 17:35 ` Arnaldo Carvalho de Melo
2021-02-03 15:36 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).