public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] perf test: Fix perf test 114 perf record test subtest precise_max
@ 2025-01-30 11:57 Thomas Richter
  2025-01-30 11:57 ` [PATCH 2/2] perf test: Change event in perf test 114 perf record test subtest test_leader_sampling Thomas Richter
  2025-01-30 15:05 ` [PATCH 1/2] perf test: Fix perf test 114 perf record test subtest precise_max James Clark
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Richter @ 2025-01-30 11:57 UTC (permalink / raw)
  To: linux-kernel, linux-perf-users, acme, namhyung
  Cc: agordeev, gor, sumanthk, hca, Thomas Richter, James Clark

On s390 the event instructions can not be used for recording.
This event is only supported by perf stat.

Test that each event cycles and instructions supports sampling.
If the event can not be sampled, skip it.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Suggested-by: James Clark <james.clark@linaro.org>
---
 tools/perf/tests/shell/record.sh | 43 +++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index 0fc7a909ae9b..b905acde8358 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -273,27 +273,42 @@ test_topdown_leader_sampling() {
 }
 
 test_precise_max() {
+  local -i skipped=0
+
   echo "precise_max attribute test"
-  if ! perf stat -e "cycles,instructions" true 2> /dev/null
+  # Just to make sure event cycles is supported for sampling
+  if perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null
   then
-    echo "precise_max attribute [Skipped no hardware events]"
-    return
+    if ! perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null
+    then
+      echo "precise_max attribute [Failed cycles:P event]"
+      err=1
+      return
+    fi
+  else
+    echo "precise_max attribute [Skipped no cycles:P event]"
+    ((skipped+=1))
   fi
-  # Just to make sure it doesn't fail
-  if ! perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null
+  # On s390 event instructions is not supported for perf record
+  if perf record -o "${perfdata}" -e "instructions:P" true 2> /dev/null
   then
-    echo "precise_max attribute [Failed cycles:P event]"
-    err=1
-    return
+    # On AMD, cycles and instructions events are treated differently
+    if ! perf record -o "${perfdata}" -e "instructions:P" true 2> /dev/null
+    then
+      echo "precise_max attribute [Failed instructions:P event]"
+      err=1
+      return
+    fi
+  else
+    echo "precise_max attribute [Skipped no instructions:P event]"
+    ((skipped+=1))
   fi
-  # On AMD, cycles and instructions events are treated differently
-  if ! perf record -o "${perfdata}" -e "instructions:P" true 2> /dev/null
+  if [ $skipped -eq 2 ]
   then
-    echo "precise_max attribute [Failed instructions:P event]"
-    err=1
-    return
+    echo "precise_max attribute [Skipped no hardware events]"
+  else
+    echo "precise_max attribute test [Success]"
   fi
-  echo "precise_max attribute test [Success]"
 }
 
 # raise the limit of file descriptors to minimum
-- 
2.48.1


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

* [PATCH 2/2] perf test: Change event in perf test 114 perf record test subtest test_leader_sampling
  2025-01-30 11:57 [PATCH 1/2] perf test: Fix perf test 114 perf record test subtest precise_max Thomas Richter
@ 2025-01-30 11:57 ` Thomas Richter
  2025-01-30 15:01   ` James Clark
  2025-01-30 15:05 ` [PATCH 1/2] perf test: Fix perf test 114 perf record test subtest precise_max James Clark
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Richter @ 2025-01-30 11:57 UTC (permalink / raw)
  To: linux-kernel, linux-perf-users, acme, namhyung
  Cc: agordeev, gor, sumanthk, hca, Thomas Richter, James Clark

On s390 the event instructions can not be used for recording.
This event is only supported by perf stat.

Change the event from instructions to cycles in
subtest test_leader_sampling.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Suggested-by: James Clark <james.clark@linaro.org>
---
 tools/perf/tests/shell/record.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index b905acde8358..a17018181afa 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -231,7 +231,7 @@ test_cgroup() {
 
 test_leader_sampling() {
   echo "Basic leader sampling test"
-  if ! perf record -o "${perfdata}" -e "{instructions,instructions}:Su" -- \
+  if ! perf record -o "${perfdata}" -e "{cycles,cycles}:Su" -- \
     perf test -w brstack 2> /dev/null
   then
     echo "Leader sampling [Failed record]"
@@ -243,10 +243,10 @@ test_leader_sampling() {
   while IFS= read -r line
   do
     # Check if the two instruction counts are equal in each record
-    instructions=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="instructions:") print $(i-1)}')
+    instructions=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="cycles:") print $(i-1)}')
     if [ $(($index%2)) -ne 0 ] && [ ${instructions}x != ${prev_instructions}x ]
     then
-      echo "Leader sampling [Failed inconsistent instructions count]"
+      echo "Leader sampling [Failed inconsistent cycles count]"
       err=1
       return
     fi
-- 
2.48.1


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

* Re: [PATCH 2/2] perf test: Change event in perf test 114 perf record test subtest test_leader_sampling
  2025-01-30 11:57 ` [PATCH 2/2] perf test: Change event in perf test 114 perf record test subtest test_leader_sampling Thomas Richter
@ 2025-01-30 15:01   ` James Clark
  0 siblings, 0 replies; 4+ messages in thread
From: James Clark @ 2025-01-30 15:01 UTC (permalink / raw)
  To: Thomas Richter
  Cc: agordeev, gor, sumanthk, hca, linux-kernel, linux-perf-users,
	acme, namhyung



On 30/01/2025 11:57 am, Thomas Richter wrote:
> On s390 the event instructions can not be used for recording.
> This event is only supported by perf stat.
> 
> Change the event from instructions to cycles in
> subtest test_leader_sampling.
> 
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Suggested-by: James Clark <james.clark@linaro.org>
> ---
>   tools/perf/tests/shell/record.sh | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index b905acde8358..a17018181afa 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -231,7 +231,7 @@ test_cgroup() {
>   
>   test_leader_sampling() {
>     echo "Basic leader sampling test"
> -  if ! perf record -o "${perfdata}" -e "{instructions,instructions}:Su" -- \
> +  if ! perf record -o "${perfdata}" -e "{cycles,cycles}:Su" -- \
>       perf test -w brstack 2> /dev/null
>     then
>       echo "Leader sampling [Failed record]"
> @@ -243,10 +243,10 @@ test_leader_sampling() {
>     while IFS= read -r line
>     do
>       # Check if the two instruction counts are equal in each record
> -    instructions=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="instructions:") print $(i-1)}')
> +    instructions=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="cycles:") print $(i-1)}')

Minor nit, but you could change the variable name too.

Reviewed-by: James Clark <james.clark@linaro.org>

>       if [ $(($index%2)) -ne 0 ] && [ ${instructions}x != ${prev_instructions}x ]
>       then
> -      echo "Leader sampling [Failed inconsistent instructions count]"
> +      echo "Leader sampling [Failed inconsistent cycles count]"
>         err=1
>         return
>       fi


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

* Re: [PATCH 1/2] perf test: Fix perf test 114 perf record test subtest precise_max
  2025-01-30 11:57 [PATCH 1/2] perf test: Fix perf test 114 perf record test subtest precise_max Thomas Richter
  2025-01-30 11:57 ` [PATCH 2/2] perf test: Change event in perf test 114 perf record test subtest test_leader_sampling Thomas Richter
@ 2025-01-30 15:05 ` James Clark
  1 sibling, 0 replies; 4+ messages in thread
From: James Clark @ 2025-01-30 15:05 UTC (permalink / raw)
  To: Thomas Richter
  Cc: agordeev, gor, sumanthk, hca, linux-kernel, linux-perf-users,
	acme, namhyung



On 30/01/2025 11:57 am, Thomas Richter wrote:
> On s390 the event instructions can not be used for recording.
> This event is only supported by perf stat.
> 
> Test that each event cycles and instructions supports sampling.
> If the event can not be sampled, skip it.
> 
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Suggested-by: James Clark <james.clark@linaro.org>
> ---
>   tools/perf/tests/shell/record.sh | 43 +++++++++++++++++++++-----------
>   1 file changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index 0fc7a909ae9b..b905acde8358 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -273,27 +273,42 @@ test_topdown_leader_sampling() {
>   }
>   
>   test_precise_max() {
> +  local -i skipped=0
> +
>     echo "precise_max attribute test"
> -  if ! perf stat -e "cycles,instructions" true 2> /dev/null
> +  # Just to make sure event cycles is supported for sampling
> +  if perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null

This needs to check -e cycles, not cycles:P. Otherwise the test doesn't 
do anything anymore, because it only tests that cycles:P opens anyway.

So now in failure conditions where it can't be opened the test skips 
instead of fails.

With that change:

Reviewed-by: James Clark <james.clark@linaro.org>

>     then
> -    echo "precise_max attribute [Skipped no hardware events]"
> -    return
> +    if ! perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null
> +    then
> +      echo "precise_max attribute [Failed cycles:P event]"
> +      err=1
> +      return
> +    fi
> +  else
> +    echo "precise_max attribute [Skipped no cycles:P event]"
> +    ((skipped+=1))


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

end of thread, other threads:[~2025-01-30 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-30 11:57 [PATCH 1/2] perf test: Fix perf test 114 perf record test subtest precise_max Thomas Richter
2025-01-30 11:57 ` [PATCH 2/2] perf test: Change event in perf test 114 perf record test subtest test_leader_sampling Thomas Richter
2025-01-30 15:01   ` James Clark
2025-01-30 15:05 ` [PATCH 1/2] perf test: Fix perf test 114 perf record test subtest precise_max James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox