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

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/shell/test_data_symbol.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/bash
  2 # Test data symbol
  3 
  4 # SPDX-License-Identifier: GPL-2.0
  5 # Leo Yan <leo.yan@linaro.org>, 2022
  6 
  7 shelldir=$(dirname "$0")
  8 # shellcheck source=lib/waiting.sh
  9 . "${shelldir}"/lib/waiting.sh
 10 
 11 # shellcheck source=lib/perf_has_symbol.sh
 12 . "${shelldir}"/lib/perf_has_symbol.sh
 13 
 14 skip_if_no_mem_event() {
 15         perf mem record -e list 2>&1 | grep -E -q 'available' && return 0
 16         return 2
 17 }
 18 
 19 skip_if_no_mem_event || exit 2
 20 
 21 skip_test_missing_symbol buf1
 22 
 23 TEST_PROGRAM="perf test -w datasym"
 24 PERF_DATA=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
 25 ERR_FILE=$(mktemp /tmp/__perf_test.stderr.XXXXX)
 26 
 27 check_result() {
 28         # The memory report format is as below:
 29         #    99.92%  ...  [.] buf1+0x38
 30         result=$(perf mem report -i ${PERF_DATA} -s symbol_daddr -q 2>&1 |
 31                  awk '/buf1/ { print $4 }')
 32 
 33         # Testing is failed if has no any sample for "buf1"
 34         [ -z "$result" ] && return 1
 35 
 36         while IFS= read -r line; do
 37                 # The "data1" and "data2" fields in structure "buf1" have
 38                 # offset "0x0" and "0x38", returns failure if detect any
 39                 # other offset value.
 40                 if [ "$line" != "buf1+0x0" ] && [ "$line" != "buf1+0x38" ]; then
 41                         return 1
 42                 fi
 43         done <<< "$result"
 44 
 45         return 0
 46 }
 47 
 48 cleanup_files()
 49 {
 50         echo "Cleaning up files..."
 51         rm -f ${PERF_DATA}
 52 }
 53 
 54 trap cleanup_files exit term int
 55 
 56 echo "Recording workload..."
 57 
 58 # perf mem/c2c internally uses IBS PMU on AMD CPU which doesn't support
 59 # user/kernel filtering and per-process monitoring, spin program on
 60 # specific CPU and test in per-CPU mode.
 61 is_amd=$(grep -E -c 'vendor_id.*AuthenticAMD' /proc/cpuinfo)
 62 if (($is_amd >= 1)); then
 63         perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}" &
 64 else
 65         perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}" &
 66 fi
 67 
 68 PERFPID=$!
 69 
 70 wait_for_perf_to_start ${PERFPID} "${ERR_FILE}"
 71 
 72 sleep 1
 73 
 74 kill $PERFPID
 75 wait $PERFPID
 76 
 77 check_result
 78 exit $?

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