linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/tests: Fix test case 95 on s390 and use same event
@ 2022-07-27 14:14 Thomas Richter
  2022-07-28  9:09 ` James Clark
  2022-07-28  9:25 ` German Gomez
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Richter @ 2022-07-27 14:14 UTC (permalink / raw)
  To: linux-kernel, linux-perf-users, acme, james.clark, german.gomez
  Cc: svens, gor, sumanthk, hca, Thomas Richter

On linux-next tree perf test 95 was added recently.
s390 does not support branch sampling at all and the test case fails
despite for checking branch support before hand.
The check for support of branching
uses the software event named dummy, as seen in the line:

 perf record -b -o- -e dummy -B true > /dev/null 2>&1 || exit 2

However when the branch recording is actually done, a different
event is used, as seen in the line:

 perf record -o $TMPDIR/... --branch-filter any,save_type,u -- ...

The event is omitted and for perf record the default event is
cycles, which is not supported by s390 and this fails when executed
on s390:

 # perf record --branch-filter any,save_type,u -- \
	/tmp/__perf_test.program.iDSmQ/a.out
 Error:
 cycles: PMU Hardware or event type doesn't support branch stack sampling.
 #

Therefore fix this and use the same event cycles for testing support
and actually running the test.

Output before:
 # ./perf test -Fv 95
 95: Check branch stack sampling                                     :
 --- start ---
 Testing user branch stack sampling
 ---- end ----
 Check branch stack sampling: FAILED!
 #

Output after:
 # ./perf test -Fv 95
 95: Check branch stack sampling                                     :
 --- start ---
 ---- end ----
 Check branch stack sampling: Skip
 #

Fixes: b55878c90ab9 ("perf test: Add test for branch stack sampling")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
---
 tools/perf/tests/shell/test_brstack.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/test_brstack.sh b/tools/perf/tests/shell/test_brstack.sh
index 113ccd17bf03..c644f94a6500 100755
--- a/tools/perf/tests/shell/test_brstack.sh
+++ b/tools/perf/tests/shell/test_brstack.sh
@@ -12,7 +12,7 @@ if ! [ -x "$(command -v cc)" ]; then
 fi
 
 # skip the test if the hardware doesn't support branch stack sampling
-perf record -b -o- -e dummy -B true > /dev/null 2>&1 || exit 2
+perf record -b -o- -B true > /dev/null 2>&1 || exit 2
 
 TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
 
-- 
2.36.1


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

* Re: [PATCH] perf/tests: Fix test case 95 on s390 and use same event
  2022-07-27 14:14 [PATCH] perf/tests: Fix test case 95 on s390 and use same event Thomas Richter
@ 2022-07-28  9:09 ` James Clark
  2022-07-28  9:25 ` German Gomez
  1 sibling, 0 replies; 5+ messages in thread
From: James Clark @ 2022-07-28  9:09 UTC (permalink / raw)
  To: Thomas Richter, linux-kernel, linux-perf-users, acme, german.gomez
  Cc: svens, gor, sumanthk, hca



On 27/07/2022 15:14, Thomas Richter wrote:
> On linux-next tree perf test 95 was added recently.
> s390 does not support branch sampling at all and the test case fails
> despite for checking branch support before hand.
> The check for support of branching
> uses the software event named dummy, as seen in the line:
> 
>  perf record -b -o- -e dummy -B true > /dev/null 2>&1 || exit 2
> 
> However when the branch recording is actually done, a different
> event is used, as seen in the line:
> 
>  perf record -o $TMPDIR/... --branch-filter any,save_type,u -- ...
> 
> The event is omitted and for perf record the default event is
> cycles, which is not supported by s390 and this fails when executed
> on s390:
> 
>  # perf record --branch-filter any,save_type,u -- \
> 	/tmp/__perf_test.program.iDSmQ/a.out
>  Error:
>  cycles: PMU Hardware or event type doesn't support branch stack sampling.
>  #
> 
> Therefore fix this and use the same event cycles for testing support
> and actually running the test.
> 
> Output before:
>  # ./perf test -Fv 95
>  95: Check branch stack sampling                                     :
>  --- start ---
>  Testing user branch stack sampling
>  ---- end ----
>  Check branch stack sampling: FAILED!
>  #
> 
> Output after:
>  # ./perf test -Fv 95
>  95: Check branch stack sampling                                     :
>  --- start ---
>  ---- end ----
>  Check branch stack sampling: Skip
>  #
> 
> Fixes: b55878c90ab9 ("perf test: Add test for branch stack sampling")
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>

Looks good to me.

Reviewed-by: James Clark <james.clark@arm.com>

> ---
>  tools/perf/tests/shell/test_brstack.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/tests/shell/test_brstack.sh b/tools/perf/tests/shell/test_brstack.sh
> index 113ccd17bf03..c644f94a6500 100755
> --- a/tools/perf/tests/shell/test_brstack.sh
> +++ b/tools/perf/tests/shell/test_brstack.sh
> @@ -12,7 +12,7 @@ if ! [ -x "$(command -v cc)" ]; then
>  fi
>  
>  # skip the test if the hardware doesn't support branch stack sampling
> -perf record -b -o- -e dummy -B true > /dev/null 2>&1 || exit 2
> +perf record -b -o- -B true > /dev/null 2>&1 || exit 2
>  
>  TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
>  

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

* Re: [PATCH] perf/tests: Fix test case 95 on s390 and use same event
  2022-07-27 14:14 [PATCH] perf/tests: Fix test case 95 on s390 and use same event Thomas Richter
  2022-07-28  9:09 ` James Clark
@ 2022-07-28  9:25 ` German Gomez
  2022-07-28 12:20   ` Thomas Richter
  1 sibling, 1 reply; 5+ messages in thread
From: German Gomez @ 2022-07-28  9:25 UTC (permalink / raw)
  To: Thomas Richter, linux-kernel, linux-perf-users, acme, james.clark
  Cc: svens, gor, sumanthk, hca, Namhyung Kim, Jiri Olsa

Thanks for the fix, Thomas

On 27/07/2022 15:14, Thomas Richter wrote:
> On linux-next tree perf test 95 was added recently.
> s390 does not support branch sampling at all and the test case fails
> despite for checking branch support before hand.
> The check for support of branching
> uses the software event named dummy, as seen in the line:
>
>  perf record -b -o- -e dummy -B true > /dev/null 2>&1 || exit 2

Just curious, do you know why the command succeeds in this platform (and
potentially others)?

I got the idea of using "dummy" from [1] but only tested on arm64 and
x86. I thought the platforms would reject it if -b was not implemented
regardless of the event. Did I misunderstand the use of dummy?

Thanks,
German

[1] https://lore.kernel.org/all/20220617073840.GA45710@leoy-ThinkPad-X240s/

>
> However when the branch recording is actually done, a different
> event is used, as seen in the line:
>
>  perf record -o $TMPDIR/... --branch-filter any,save_type,u -- ...
>
> The event is omitted and for perf record the default event is
> cycles, which is not supported by s390 and this fails when executed
> on s390:
>
>  # perf record --branch-filter any,save_type,u -- \
> 	/tmp/__perf_test.program.iDSmQ/a.out
>  Error:
>  cycles: PMU Hardware or event type doesn't support branch stack sampling.
>  #
>
> Therefore fix this and use the same event cycles for testing support
> and actually running the test.
>
> Output before:
>  # ./perf test -Fv 95
>  95: Check branch stack sampling                                     :
>  --- start ---
>  Testing user branch stack sampling
>  ---- end ----
>  Check branch stack sampling: FAILED!
>  #
>
> Output after:
>  # ./perf test -Fv 95
>  95: Check branch stack sampling                                     :
>  --- start ---
>  ---- end ----
>  Check branch stack sampling: Skip
>  #
>
> Fixes: b55878c90ab9 ("perf test: Add test for branch stack sampling")
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> ---
>  tools/perf/tests/shell/test_brstack.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/shell/test_brstack.sh b/tools/perf/tests/shell/test_brstack.sh
> index 113ccd17bf03..c644f94a6500 100755
> --- a/tools/perf/tests/shell/test_brstack.sh
> +++ b/tools/perf/tests/shell/test_brstack.sh
> @@ -12,7 +12,7 @@ if ! [ -x "$(command -v cc)" ]; then
>  fi
>  
>  # skip the test if the hardware doesn't support branch stack sampling
> -perf record -b -o- -e dummy -B true > /dev/null 2>&1 || exit 2
> +perf record -b -o- -B true > /dev/null 2>&1 || exit 2
>  
>  TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
>  

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

* Re: [PATCH] perf/tests: Fix test case 95 on s390 and use same event
  2022-07-28  9:25 ` German Gomez
@ 2022-07-28 12:20   ` Thomas Richter
  2022-07-28 12:28     ` German Gomez
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Richter @ 2022-07-28 12:20 UTC (permalink / raw)
  To: German Gomez, linux-kernel, linux-perf-users, acme, james.clark
  Cc: svens, gor, sumanthk, hca, Namhyung Kim, Jiri Olsa

On 7/28/22 11:25, German Gomez wrote:
> Thanks for the fix, Thomas
> 
> On 27/07/2022 15:14, Thomas Richter wrote:
>> On linux-next tree perf test 95 was added recently.
>> s390 does not support branch sampling at all and the test case fails
>> despite for checking branch support before hand.
>> The check for support of branching
>> uses the software event named dummy, as seen in the line:
>>
>>  perf record -b -o- -e dummy -B true > /dev/null 2>&1 || exit 2
> 
> Just curious, do you know why the command succeeds in this platform (and
> potentially others)?
> 
> I got the idea of using "dummy" from [1] but only tested on arm64 and
> x86. I thought the platforms would reject it if -b was not implemented
> regardless of the event. Did I misunderstand the use of dummy?
> 
> Thanks,
> German
> 
> [1] https://lore.kernel.org/all/20220617073840.GA45710@leoy-ThinkPad-X240s/
> 

Well, dummy is a predefined event of type software, you see that when you add
some -v options as in 
# perf record -e dummy -vvv
DEBUGINFOD_URLS=
Using CPUID IBM,3931,704,A01,3.7,002f
nr_cblocks: 0
affinity: SYS
mmap flush: 1
comp level: 0
------------------------------------------------------------
perf_event_attr:
  type                             1      <----------- type 1 is software
  size                             128
  config                           0x9
  { sample_period, sample_freq }   4000


So this event is never sent to an hardware PMU (which would have type 0) and thus
mostly succeeds where as the perf record command without event uses default
event cycles. And that one is sent to hardware PMU on s390...

-- 
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294

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

* Re: [PATCH] perf/tests: Fix test case 95 on s390 and use same event
  2022-07-28 12:20   ` Thomas Richter
@ 2022-07-28 12:28     ` German Gomez
  0 siblings, 0 replies; 5+ messages in thread
From: German Gomez @ 2022-07-28 12:28 UTC (permalink / raw)
  To: Thomas Richter, linux-kernel, linux-perf-users, acme, james.clark
  Cc: svens, gor, sumanthk, hca, Namhyung Kim, Jiri Olsa


On 28/07/2022 13:20, Thomas Richter wrote:
> On 7/28/22 11:25, German Gomez wrote:
>> Thanks for the fix, Thomas
>>
>> On 27/07/2022 15:14, Thomas Richter wrote:
>>> On linux-next tree perf test 95 was added recently.
>>> s390 does not support branch sampling at all and the test case fails
>>> despite for checking branch support before hand.
>>> The check for support of branching
>>> uses the software event named dummy, as seen in the line:
>>>
>>>  perf record -b -o- -e dummy -B true > /dev/null 2>&1 || exit 2
>> Just curious, do you know why the command succeeds in this platform (and
>> potentially others)?
>>
>> I got the idea of using "dummy" from [1] but only tested on arm64 and
>> x86. I thought the platforms would reject it if -b was not implemented
>> regardless of the event. Did I misunderstand the use of dummy?
>>
>> Thanks,
>> German
>>
>> [1] https://lore.kernel.org/all/20220617073840.GA45710@leoy-ThinkPad-X240s/
>>
> Well, dummy is a predefined event of type software, you see that when you add
> some -v options as in 
> # perf record -e dummy -vvv
> DEBUGINFOD_URLS=
> Using CPUID IBM,3931,704,A01,3.7,002f
> nr_cblocks: 0
> affinity: SYS
> mmap flush: 1
> comp level: 0
> ------------------------------------------------------------
> perf_event_attr:
>   type                             1      <----------- type 1 is software
>   size                             128
>   config                           0x9
>   { sample_period, sample_freq }   4000
>
>
> So this event is never sent to an hardware PMU (which would have type 0) and thus
> mostly succeeds where as the perf record command without event uses default
> event cycles. And that one is sent to hardware PMU on s390...

Thanks for explaining! My bad for missing this.

Acked-by: German Gomez <german.gomez@arm.com>

>

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

end of thread, other threads:[~2022-07-28 12:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 14:14 [PATCH] perf/tests: Fix test case 95 on s390 and use same event Thomas Richter
2022-07-28  9:09 ` James Clark
2022-07-28  9:25 ` German Gomez
2022-07-28 12:20   ` Thomas Richter
2022-07-28 12:28     ` German Gomez

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).