~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/shell/test_arm_spe.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/sh
  2 # Check Arm SPE trace data recording and synthesized samples
  3 
  4 # Uses the 'perf record' to record trace data of Arm SPE events;
  5 # then verify if any SPE event samples are generated by SPE with
  6 # 'perf script' and 'perf report' commands.
  7 
  8 # SPDX-License-Identifier: GPL-2.0
  9 # German Gomez <german.gomez@arm.com>, 2021
 10 
 11 skip_if_no_arm_spe_event() {
 12         perf list | grep -E -q 'arm_spe_[0-9]+//' && return 0
 13 
 14         # arm_spe event doesn't exist
 15         return 2
 16 }
 17 
 18 skip_if_no_arm_spe_event || exit 2
 19 
 20 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
 21 glb_err=0
 22 
 23 cleanup_files()
 24 {
 25         rm -f ${perfdata}
 26         rm -f ${perfdata}.old
 27         exit $glb_err
 28 }
 29 
 30 trap cleanup_files EXIT TERM INT
 31 
 32 arm_spe_report() {
 33         if [ $2 = 0 ]; then
 34                 echo "$1: PASS"
 35         elif [ $2 = 2 ]; then
 36                 echo "$1: SKIPPED"
 37         else
 38                 echo "$1: FAIL"
 39                 glb_err=$2
 40         fi
 41 }
 42 
 43 perf_script_samples() {
 44         echo "Looking at perf.data file for dumping samples:"
 45 
 46         # from arm-spe.c/arm_spe_synth_events()
 47         events="(ld1-miss|ld1-access|llc-miss|lld-access|tlb-miss|tlb-access|branch-miss|remote-access|memory)"
 48 
 49         # Below is an example of the samples dumping:
 50         #       dd  3048 [002]          1    l1d-access:      ffffaa64999c __GI___libc_write+0x3c (/lib/aarch64-linux-gnu/libc-2.27.so)
 51         #       dd  3048 [002]          1    tlb-access:      ffffaa64999c __GI___libc_write+0x3c (/lib/aarch64-linux-gnu/libc-2.27.so)
 52         #       dd  3048 [002]          1        memory:      ffffaa64999c __GI___libc_write+0x3c (/lib/aarch64-linux-gnu/libc-2.27.so)
 53         perf script -F,-time -i ${perfdata} 2>&1 | \
 54                 grep -E " +$1 +[0-9]+ .* +${events}:(.*:)? +" > /dev/null 2>&1
 55 }
 56 
 57 perf_report_samples() {
 58         echo "Looking at perf.data file for reporting samples:"
 59 
 60         # Below is an example of the samples reporting:
 61         #   73.04%    73.04%  dd    libc-2.27.so      [.] _dl_addr
 62         #    7.71%     7.71%  dd    libc-2.27.so      [.] getenv
 63         #    2.59%     2.59%  dd    ld-2.27.so        [.] strcmp
 64         perf report --stdio -i ${perfdata} 2>&1 | \
 65                 grep -E " +[0-9]+\.[0-9]+% +[0-9]+\.[0-9]+% +$1 " > /dev/null 2>&1
 66 }
 67 
 68 arm_spe_snapshot_test() {
 69         echo "Recording trace with snapshot mode $perfdata"
 70         perf record -o ${perfdata} -e arm_spe// -S \
 71                 -- dd if=/dev/zero of=/dev/null > /dev/null 2>&1 &
 72         PERFPID=$!
 73 
 74         # Wait for perf program
 75         sleep 1
 76 
 77         # Send signal to snapshot trace data
 78         kill -USR2 $PERFPID
 79 
 80         # Stop perf program
 81         kill $PERFPID
 82         wait $PERFPID
 83 
 84         perf_script_samples dd &&
 85         perf_report_samples dd
 86 
 87         err=$?
 88         arm_spe_report "SPE snapshot testing" $err
 89 }
 90 
 91 arm_spe_system_wide_test() {
 92         echo "Recording trace with system-wide mode $perfdata"
 93 
 94         perf record -o - -e dummy -a -B true > /dev/null 2>&1
 95         if [ $? != 0 ]; then
 96                 arm_spe_report "SPE system-wide testing" 2
 97                 return
 98         fi
 99 
100         perf record -o ${perfdata} -e arm_spe// -a --no-bpf-event \
101                 -- dd if=/dev/zero of=/dev/null count=100000 > /dev/null 2>&1
102 
103         perf_script_samples dd &&
104         perf_report_samples dd
105 
106         err=$?
107         arm_spe_report "SPE system-wide testing" $err
108 }
109 
110 arm_spe_snapshot_test
111 arm_spe_system_wide_test
112 
113 exit $glb_err

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php