Commit 69757962 authored by Kan Liang's avatar Kan Liang Committed by Arnaldo Carvalho de Melo
Browse files

perf test: Basic branch counter support



Add a basic test for the branch counter feature.

The test verifies that
- The new filter can be successfully applied on the supported platforms.
- The counter value can be outputted via the perf report -D

Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Tested-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tinghao Zhang <tinghao.zhang@intel.com>
Link: https://lore.kernel.org/r/20231107184020.1497571-1-kan.liang@linux.intel.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent cd38d6b5
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ err=0
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
testprog="perf test -w thloop"
testsym="test_loop"
cpu_pmu_dir="/sys/bus/event_source/devices/cpu*"
br_cntr_file="/caps/branch_counter_nr"
br_cntr_output="branch stack counters"

cleanup() {
  rm -rf "${perfdata}"
@@ -155,10 +158,37 @@ test_workload() {
  echo "Basic target workload test [Success]"
}

test_branch_counter() {
  echo "Basic branch counter test"
  # Check if the branch counter feature is supported
  for dir in $cpu_pmu_dir
  do
    if [ ! -e "$dir$br_cntr_file" ]
    then
      echo "branch counter feature not supported on all core PMUs ($dir) [Skipped]"
      return
    fi
  done
  if ! perf record -o "${perfdata}" -j any,counter ${testprog} 2> /dev/null
  then
    echo "Basic branch counter test [Failed record]"
    err=1
    return
  fi
  if ! perf report -i "${perfdata}" -D -q | grep -q "$br_cntr_output"
  then
    echo "Basic branch record test [Failed missing output]"
    err=1
    return
  fi
  echo "Basic branch counter test [Success]"
}

test_per_thread
test_register_capture
test_system_wide
test_workload
test_branch_counter

cleanup
exit $err