stat_all_pmu.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # perf all PMU test (exclusive)
  3. # SPDX-License-Identifier: GPL-2.0
  4. err=0
  5. result=""
  6. trap_cleanup() {
  7. echo "Unexpected signal in ${FUNCNAME[1]}"
  8. echo "$result"
  9. exit 1
  10. }
  11. trap trap_cleanup EXIT TERM INT
  12. # Test all PMU events; however exclude parameterized ones (name contains '?')
  13. for p in $(perf list --raw-dump pmu | sed 's/[[:graph:]]\+?[[:graph:]]\+[[:space:]]//g')
  14. do
  15. echo -n "Testing $p -- "
  16. output=$(perf stat -e "$p" true 2>&1)
  17. stat_result=$?
  18. if echo "$output" | grep -q "$p"
  19. then
  20. # Event seen in output.
  21. if [ $stat_result -eq 0 ] && ! echo "$output" | grep -q "<not supported>"
  22. then
  23. # Event supported.
  24. echo "supported"
  25. continue
  26. elif echo "$output" | grep -q "<not supported>"
  27. then
  28. # Event not supported, so ignore.
  29. echo "not supported"
  30. continue
  31. elif echo "$output" | grep -q "No permission to enable"
  32. then
  33. # No permissions, so ignore.
  34. echo "no permission to enable"
  35. continue
  36. elif echo "$output" | grep -q "Bad event name"
  37. then
  38. # Non-existent event.
  39. echo "Error: Bad event name"
  40. echo "$output"
  41. err=1
  42. continue
  43. fi
  44. fi
  45. if echo "$output" | grep -q "Access to performance monitoring and observability operations is limited."
  46. then
  47. # Access is limited, so ignore.
  48. echo "access limited"
  49. continue
  50. fi
  51. # We failed to see the event and it is supported. Possibly the workload was
  52. # too small so retry with something longer.
  53. output=$(perf stat -e "$p" perf bench internals synthesize 2>&1)
  54. if echo "$output" | grep -q "$p"
  55. then
  56. # Event seen in output.
  57. echo "supported"
  58. continue
  59. fi
  60. echo "Error: event '$p' not printed in:"
  61. echo "$output"
  62. err=1
  63. done
  64. trap - EXIT TERM INT
  65. exit $err