perf test: Fix perf test 114 perf record test subtest precise_max
PATCH 1/2 perf test: Fix perf test 114 perf record test subtest precise_max
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.
--- tools/perf/tests/shell/record.sh | 43 +++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 14 deletions(-)
tools/perf/tests/shell/record.sh +29 -14
@@ -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
Signature · 1 line
2.48.1
PATCH 2/2 perf test: Change event in perf test 114 perf record test subtest test_leader_sampling
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.
--- tools/perf/tests/shell/record.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/tests/shell/record.sh +3 -3
@@ -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
Signature · 1 line
2.48.1
Re: [PATCH 2/2] perf test: Change event in perf test 114 perf record test subtest test_leader_sampling
Quoted 26 lines · Thomas Richter
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
subtesttest_leader_sampling.Signed-off-by Thomas Richter <[email protected]>Suggested-by James Clark <[email protected]>--- tools/perf/tests/shell/record.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/perf/tests/shell/record.sh +1
-1@@ -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]"
tools/perf/tests/shell/record.sh test_leader_sampling() { · line 246
Quoted 5 lines
tools/perf/tests/shell/record.sh +1
-1@@ -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.
Quoted 7 lines
tools/perf/tests/shell/record.sh +1
-1if [ $(($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
Quoted 17 lines · Thomas Richter
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 <[email protected]>Suggested-by James Clark <[email protected]>--- tools/perf/tests/shell/record.sh | 43 +++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 14 deletions(-)tools/perf/tests/shell/record.sh +0
-0
tools/perf/tests/shell/record.sh test_topdown_leader_sampling() { · line 280
Quoted 9 lines
tools/perf/tests/shell/record.sh +4
-1@@ -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:
Quoted 12 lines
tools/perf/tests/shell/record.sh +9
-2then - 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))