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

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/shell/lib/coresight.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 # SPDX-License-Identifier: GPL-2.0
  2 # Carsten Haitzler <carsten.haitzler@arm.com>, 2021
  3 
  4 # This is sourced from a driver script so no need for #!/bin... etc. at the
  5 # top - the assumption below is that it runs as part of sourcing after the
  6 # test sets up some basic env vars to say what it is.
  7 
  8 # This currently works with ETMv4 / ETF not any other packet types at thi
  9 # point. This will need changes if that changes.
 10 
 11 # perf record options for the perf tests to use
 12 PERFRECMEM="-m ,16M"
 13 PERFRECOPT="$PERFRECMEM -e cs_etm//u"
 14 
 15 TOOLS=$(dirname $0)
 16 DIR="$TOOLS/$TEST"
 17 BIN="$DIR/$TEST"
 18 # If the test tool/binary does not exist and is executable then skip the test
 19 if ! test -x "$BIN"; then exit 2; fi
 20 # If CoreSight is not available, skip the test
 21 perf list cs_etm | grep -q cs_etm || exit 2
 22 DATD="."
 23 # If the data dir env is set then make the data dir use that instead of ./
 24 if test -n "$PERF_TEST_CORESIGHT_DATADIR"; then
 25         DATD="$PERF_TEST_CORESIGHT_DATADIR";
 26 fi
 27 # If the stat dir env is set then make the data dir use that instead of ./
 28 STATD="."
 29 if test -n "$PERF_TEST_CORESIGHT_STATDIR"; then
 30         STATD="$PERF_TEST_CORESIGHT_STATDIR";
 31 fi
 32 
 33 # Called if the test fails - error code 1
 34 err() {
 35         echo "$1"
 36         exit 1
 37 }
 38 
 39 # Check that some statistics from our perf
 40 check_val_min() {
 41         STATF="$4"
 42         if test "$2" -lt "$3"; then
 43                 echo ", FAILED" >> "$STATF"
 44                 err "Sanity check number of $1 is too low ($2 < $3)"
 45         fi
 46 }
 47 
 48 perf_dump_aux_verify() {
 49         # Some basic checking that the AUX chunk contains some sensible data
 50         # to see that we are recording something and at least a minimum
 51         # amount of it. We should almost always see Fn packets in just about
 52         # anything but certainly we will see some trace info and async
 53         # packets
 54         DUMP="$DATD/perf-tmp-aux-dump.txt"
 55         perf report --stdio --dump -i "$1" | \
 56                 grep -o -e I_ATOM_F -e I_ASYNC -e I_TRACE_INFO > "$DUMP"
 57         # Simply count how many of these packets we find to see that we are
 58         # producing a reasonable amount of data - exact checks are not sane
 59         # as this is a lossy process where we may lose some blocks and the
 60         # compiler may produce different code depending on the compiler and
 61         # optimization options, so this is rough just to see if we're
 62         # either missing almost all the data or all of it
 63         ATOM_FX_NUM=$(grep -c I_ATOM_F "$DUMP")
 64         ASYNC_NUM=$(grep -c I_ASYNC "$DUMP")
 65         TRACE_INFO_NUM=$(grep -c I_TRACE_INFO "$DUMP")
 66         rm -f "$DUMP"
 67 
 68         # Arguments provide minimums for a pass
 69         CHECK_FX_MIN="$2"
 70         CHECK_ASYNC_MIN="$3"
 71         CHECK_TRACE_INFO_MIN="$4"
 72 
 73         # Write out statistics, so over time you can track results to see if
 74         # there is a pattern - for example we have less "noisy" results that
 75         # produce more consistent amounts of data each run, to see if over
 76         # time any techinques to  minimize data loss are having an effect or
 77         # not
 78         STATF="$STATD/stats-$TEST-$DATV.csv"
 79         if ! test -f "$STATF"; then
 80                 echo "ATOM Fx Count, Minimum, ASYNC Count, Minimum, TRACE INFO Count, Minimum" > "$STATF"
 81         fi
 82         echo -n "$ATOM_FX_NUM, $CHECK_FX_MIN, $ASYNC_NUM, $CHECK_ASYNC_MIN, $TRACE_INFO_NUM, $CHECK_TRACE_INFO_MIN" >> "$STATF"
 83 
 84         # Actually check to see if we passed or failed.
 85         check_val_min "ATOM_FX" "$ATOM_FX_NUM" "$CHECK_FX_MIN" "$STATF"
 86         check_val_min "ASYNC" "$ASYNC_NUM" "$CHECK_ASYNC_MIN" "$STATF"
 87         check_val_min "TRACE_INFO" "$TRACE_INFO_NUM" "$CHECK_TRACE_INFO_MIN" "$STATF"
 88         echo ", Ok" >> "$STATF"
 89 }
 90 
 91 perf_dump_aux_tid_verify() {
 92         # Specifically crafted test will produce a list of Tread ID's to
 93         # stdout that need to be checked to  see that they have had trace
 94         # info collected in AUX blocks in the perf data. This will go
 95         # through all the TID's that are listed as CID=0xabcdef and see
 96         # that all the Thread IDs the test tool reports are  in the perf
 97         # data AUX chunks
 98 
 99         # The TID test tools will print a TID per stdout line that are being
100         # tested
101         TIDS=$(cat "$2")
102         # Scan the perf report to find the TIDs that are actually CID in hex
103         # and build a list of the ones found
104         FOUND_TIDS=$(perf report --stdio --dump -i "$1" | \
105                         grep -o "CID=0x[0-9a-z]\+" | sed 's/CID=//g' | \
106                         uniq | sort | uniq)
107         # No CID=xxx found - maybe your kernel is reporting these as
108         # VMID=xxx so look there
109         if test -z "$FOUND_TIDS"; then
110                 FOUND_TIDS=$(perf report --stdio --dump -i "$1" | \
111                                 grep -o "VMID=0x[0-9a-z]\+" | sed 's/VMID=//g' | \
112                                 uniq | sort | uniq)
113         fi
114 
115         # Iterate over the list of TIDs that the test says it has and find
116         # them in the TIDs found in the perf report
117         MISSING=""
118         for TID2 in $TIDS; do
119                 FOUND=""
120                 for TIDHEX in $FOUND_TIDS; do
121                         TID=$(printf "%i" $TIDHEX)
122                         if test "$TID" -eq "$TID2"; then
123                                 FOUND="y"
124                                 break
125                         fi
126                 done
127                 if test -z "$FOUND"; then
128                         MISSING="$MISSING $TID"
129                 fi
130         done
131         if test -n "$MISSING"; then
132                 err "Thread IDs $MISSING not found in perf AUX data"
133         fi
134 }

~ [ 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