Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf test: Add syscall and address tests to brstack test

Test that SYSCALL type branches are emitted from the expected 'getppid'
symbol. Test that when only 'k' is used, sources addresses are all in
the kernel. Test that no kernel addresses leak by checking for them in
the 'u' test.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Adam Young <admiyo@os.amperecomputing.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

James Clark and committed by
Arnaldo Carvalho de Melo
11e59335 f15548b2

+60 -1
+60 -1
tools/perf/tests/shell/test_brstack.sh
··· 64 64 do 65 65 check_branches "$x" 66 66 done 67 + 68 + # Dump addresses only this time 69 + perf script -i "$TMPDIR/perf.data" --fields brstack | \ 70 + tr ' ' '\n' > "$TMPDIR/perf.script" 71 + 72 + # There should be no kernel addresses with the u option, in either 73 + # source or target addresses. 74 + if grep -E -m1 "0x[89a-f][0-9a-f]{15}" $TMPDIR/perf.script; then 75 + echo "ERROR: Kernel address found in user mode" 76 + err=1 77 + fi 67 78 # some branch types are still not being tested: 68 - # IND COND_CALL COND_RET SYSCALL SYSRET IRQ SERROR NO_TX 79 + # IND COND_CALL COND_RET SYSRET IRQ SERROR NO_TX 80 + } 81 + 82 + 83 + test_kernel_branches() { 84 + echo "Testing that k option only includes kernel source addresses" 85 + 86 + if ! perf record --branch-filter any,k -o- -- true > /dev/null; then 87 + echo "skip: not enough privileges" 88 + else 89 + perf record -o $TMPDIR/perf.data --branch-filter any,k -- \ 90 + perf bench syscall basic --loop 1000 91 + perf script -i $TMPDIR/perf.data --fields brstack | \ 92 + tr ' ' '\n' > $TMPDIR/perf.script 93 + 94 + # Example of branch entries: 95 + # "0xffffffff93bda241/0xffffffff93bda20f/M/-/-/..." 96 + # Source addresses come first and target address can be either 97 + # userspace or kernel even with k option, as long as the source 98 + # is in kernel. 99 + 100 + #Look for source addresses with top bit set 101 + if ! grep -E -m1 "^0x[89a-f][0-9a-f]{15}" $TMPDIR/perf.script; then 102 + echo "ERROR: Kernel branches missing" 103 + err=1 104 + fi 105 + # Look for no source addresses without top bit set 106 + if grep -E -m1 "^0x[0-7][0-9a-f]{0,15}" $TMPDIR/perf.script; then 107 + echo "ERROR: User branches found with kernel filter" 108 + err=1 109 + fi 110 + fi 69 111 } 70 112 71 113 # first argument <arg0> is the argument passed to "--branch-stack <arg0>,save_type,u" ··· 142 100 fi 143 101 } 144 102 103 + test_syscall() { 104 + echo "Testing syscalls" 105 + # skip if perf doesn't have enough privileges 106 + if ! perf record --branch-filter any,k -o- -- true > /dev/null; then 107 + echo "skip: not enough privileges" 108 + else 109 + perf record -o $TMPDIR/perf.data --branch-filter \ 110 + any_call,save_type,u,k -c 10000 -- \ 111 + perf bench syscall basic --loop 1000 112 + perf script -i $TMPDIR/perf.data --fields brstacksym | \ 113 + tr ' ' '\n' > $TMPDIR/perf.script 114 + 115 + check_branches "getppid[^ ]*/SYSCALL/" 116 + fi 117 + } 145 118 set -e 146 119 147 120 test_user_branches 121 + test_syscall 122 + test_kernel_branches 148 123 149 124 any_call="CALL|IND_CALL|COND_CALL|SYSCALL|IRQ" 150 125