perf test: Add precise_max subtest to the perf record shell test
authorNamhyung Kim <namhyung@kernel.org>
Wed, 16 Oct 2024 06:23:59 +0000 (23:23 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Tue, 22 Oct 2024 16:55:08 +0000 (09:55 -0700)
It's a very simply test just to run with cycles:P and instructions:P
events.

Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: James Clark <james.clark@arm.com>
Cc: Atish Patra <atishp@atishpatra.org>
Cc: Mingwei Zhang <mizhang@google.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/r/20241016062359.264929-10-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/tests/shell/record.sh

index 3eee72242290d1fb0c875f5fa133e470a42bc60a..f0e79200b9813c3a571235f2f9645ca0ec066e8b 100755 (executable)
@@ -271,6 +271,30 @@ test_topdown_leader_sampling() {
   echo "Topdown leader sampling test [Success]"
 }
 
+test_precise_max() {
+  echo "precise_max attribute test"
+  if ! perf stat -e "cycles,instructions" true 2> /dev/null
+  then
+    echo "precise_max attribute [Skipped no hardware events]"
+    return
+  fi
+  # Just to make sure it doesn't fail
+  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
+  # 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
+  echo "precise_max attribute test [Success]"
+}
+
 # raise the limit of file descriptors to minimum
 if [[ $default_fd_limit -lt $min_fd_limit ]]; then
        ulimit -Sn $min_fd_limit
@@ -284,6 +308,7 @@ test_branch_counter
 test_cgroup
 test_leader_sampling
 test_topdown_leader_sampling
+test_precise_max
 
 # restore the default value
 ulimit -Sn $default_fd_limit