Commit 180fd0c1 authored by James Clark's avatar James Clark Committed by Arnaldo Carvalho de Melo
Browse files

perf tests: Make leader sampling test work without branch event



Arm a57 only has speculative branch events so this test fails there. The
test doesn't depend on branch instructions so change it to instructions
which is pretty much guaranteed to be everywhere. The
test_branch_counter() test above already tests for the existence of the
branches event and skips if its not present.

Reviewed-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarJames Clark <james.clark@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Link: https://lore.kernel.org/r/20241115161600.228994-1-james.clark@linaro.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 264708b8
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -231,7 +231,8 @@ test_cgroup() {

test_leader_sampling() {
  echo "Basic leader sampling test"
  if ! perf record -o "${perfdata}" -e "{branches,branches}:Su" perf test -w brstack 2> /dev/null
  if ! perf record -o "${perfdata}" -e "{instructions,instructions}:Su" -- \
    perf test -w brstack 2> /dev/null
  then
    echo "Leader sampling [Failed record]"
    err=1
@@ -241,16 +242,16 @@ test_leader_sampling() {
  perf script -i "${perfdata}" > $script_output
  while IFS= read -r line
  do
    # Check if the two branches counts are equal in each record
    branches=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="branches:") print $(i-1)}')
    if [ $(($index%2)) -ne 0 ] && [ ${branches}x != ${prev_branches}x ]
    # 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)}')
    if [ $(($index%2)) -ne 0 ] && [ ${instructions}x != ${prev_instructions}x ]
    then
      echo "Leader sampling [Failed inconsistent branches count]"
      echo "Leader sampling [Failed inconsistent instructions count]"
      err=1
      return
    fi
    index=$(($index+1))
    prev_branches=$branches
    prev_instructions=$instructions
  done < $script_output
  echo "Basic leader sampling test [Success]"
}