[PATCH v2] perf test: Skip perf data type profiling tests for s390

Thomas Richter posted 1 patch 20 hours ago
tools/perf/tests/shell/data_type_profiling.sh | 24 +++++++++++++++----
1 file changed, 19 insertions(+), 5 deletions(-)
[PATCH v2] perf test: Skip perf data type profiling tests for s390
Posted by Thomas Richter 20 hours ago
Test case 'perf data type profiling tests' fails on s390 with this
error:

  # ./perf mem record -- ./perf test -w code_with_type
  failed: no PMU supports the memory events
  # echo $?
  255
  #

because s390 does not support memory events at all. According to the
man page, perf annotate --code-with-type only works with memory
instructions only.  As command 'perf mem record ...' is not supported
on s390, skip this test for s390.

Output before:
 # ./perf test 'perf data type profiling tests'
 77: perf data type profiling tests                        : FAILED!

Output after:
 # ./perf test 'perf data type profiling tests'
 77: perf data type profiling tests                        : Skip

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Suggested-by: Namhyung Kim <namhyung@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
---
 tools/perf/tests/shell/data_type_profiling.sh | 24 +++++++++++++++----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/tools/perf/tests/shell/data_type_profiling.sh b/tools/perf/tests/shell/data_type_profiling.sh
index fb47b7213b33..6eb7d96fb2b2 100755
--- a/tools/perf/tests/shell/data_type_profiling.sh
+++ b/tools/perf/tests/shell/data_type_profiling.sh
@@ -14,18 +14,26 @@ testprogs=("perf test -w code_with_type" "perf test -w datasym")
 err=0
 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
 perfout=$(mktemp /tmp/__perf_test.perf.out.XXXXX)
+perferr=$(mktemp /tmp/__perf_test.perf.err.XXXXX)
 
 cleanup() {
-  rm -rf "${perfdata}" "${perfout}"
+  rm -rf "${perfdata}" "${perfout}" "${perferr}"
   rm -rf "${perfdata}".old
 
   trap - EXIT TERM INT
 }
 
 trap_cleanup() {
-  echo "Unexpected signal in ${FUNCNAME[1]}"
+  if cat "${perferr}" | grep -q 'failed: no PMU supports the memory events'
+  then
+    echo "${mode} annotate [Skip: perf mem record] not supported"
+    rc=2
+  else
+    echo "Unexpected signal in ${FUNCNAME[1]}"
+    rc=1
+  fi
   cleanup
-  exit 1
+  exit $rc
 }
 trap trap_cleanup EXIT TERM INT
 
@@ -50,12 +58,18 @@ test_basic_annotate() {
 
   if [ "x${mode}" == "xBasic" ]
   then
-    perf mem record -o "${perfdata}" ${testprogs[$index]} 2> /dev/null
+    perf mem record -o "${perfdata}" ${testprogs[$index]} 2> "${perferr}"
   else
-    perf mem record -o - ${testprogs[$index]} 2> /dev/null > "${perfdata}"
+    perf mem record -o - ${testprogs[$index]} 2> "${perferr}" > "${perfdata}"
   fi
   if [ "x$?" != "x0" ]
   then
+    if cat "${perferr}" | grep -q 'failed: no PMU supports the memory events'
+    then
+      echo "${mode} annotate [Skip: perf mem record] not supported"
+      err=2
+      return
+    fi
     echo "${mode} annotate [Failed: perf record]"
     err=1
     return
-- 
2.53.0
Re: [PATCH v2] perf test: Skip perf data type profiling tests for s390
Posted by Ian Rogers 2 hours ago
On Tue, Mar 31, 2026 at 4:29 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> Test case 'perf data type profiling tests' fails on s390 with this
> error:
>
>   # ./perf mem record -- ./perf test -w code_with_type
>   failed: no PMU supports the memory events
>   # echo $?
>   255
>   #
>
> because s390 does not support memory events at all. According to the
> man page, perf annotate --code-with-type only works with memory
> instructions only.  As command 'perf mem record ...' is not supported
> on s390, skip this test for s390.
>
> Output before:
>  # ./perf test 'perf data type profiling tests'
>  77: perf data type profiling tests                        : FAILED!
>
> Output after:
>  # ./perf test 'perf data type profiling tests'
>  77: perf data type profiling tests                        : Skip
>
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Suggested-by: Namhyung Kim <namhyung@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
> ---
>  tools/perf/tests/shell/data_type_profiling.sh | 24 +++++++++++++++----
>  1 file changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/tests/shell/data_type_profiling.sh b/tools/perf/tests/shell/data_type_profiling.sh
> index fb47b7213b33..6eb7d96fb2b2 100755
> --- a/tools/perf/tests/shell/data_type_profiling.sh
> +++ b/tools/perf/tests/shell/data_type_profiling.sh
> @@ -14,18 +14,26 @@ testprogs=("perf test -w code_with_type" "perf test -w datasym")
>  err=0
>  perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
>  perfout=$(mktemp /tmp/__perf_test.perf.out.XXXXX)
> +perferr=$(mktemp /tmp/__perf_test.perf.err.XXXXX)
>
>  cleanup() {
> -  rm -rf "${perfdata}" "${perfout}"
> +  rm -rf "${perfdata}" "${perfout}" "${perferr}"
>    rm -rf "${perfdata}".old
>
>    trap - EXIT TERM INT
>  }
>
>  trap_cleanup() {
> -  echo "Unexpected signal in ${FUNCNAME[1]}"
> +  if cat "${perferr}" | grep -q 'failed: no PMU supports the memory events'
> +  then
> +    echo "${mode} annotate [Skip: perf mem record] not supported"
> +    rc=2

Instead of trapping and changing the error in the trap handler, can we
just explicitly test for mem events something like this:
```
perf mem record -o /dev/null true 2>&1 | grep "failed: no PMU supports
the memory events" || exit 2
```

Thanks,
Ian

> +  else
> +    echo "Unexpected signal in ${FUNCNAME[1]}"
> +    rc=1
> +  fi
>    cleanup
> -  exit 1
> +  exit $rc
>  }
>  trap trap_cleanup EXIT TERM INT
>
> @@ -50,12 +58,18 @@ test_basic_annotate() {
>
>    if [ "x${mode}" == "xBasic" ]
>    then
> -    perf mem record -o "${perfdata}" ${testprogs[$index]} 2> /dev/null
> +    perf mem record -o "${perfdata}" ${testprogs[$index]} 2> "${perferr}"
>    else
> -    perf mem record -o - ${testprogs[$index]} 2> /dev/null > "${perfdata}"
> +    perf mem record -o - ${testprogs[$index]} 2> "${perferr}" > "${perfdata}"
>    fi
>    if [ "x$?" != "x0" ]
>    then
> +    if cat "${perferr}" | grep -q 'failed: no PMU supports the memory events'
> +    then
> +      echo "${mode} annotate [Skip: perf mem record] not supported"
> +      err=2
> +      return
> +    fi
>      echo "${mode} annotate [Failed: perf record]"
>      err=1
>      return
> --
> 2.53.0
>
>