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: Fix lock contention test

Couple of independent fixes:

1. Wire in SIGSEGV handler that terminates the test with a failure code.

2. Use "--lock-cgroup" instead of "-g"; "-g" was proposed but never
merged. See commit 4d1792d0a2564caf ("perf lock contention: Add
--lock-cgroup option")

3. Call cleanup() on every normal exit so trap_cleanup() doesn't mistake
it for an unexpected signal and emit a false-negative "Unexpected
signal in main" message.

Before patch:

# ./perf test -vv "lock contention"
85: kernel lock contention analysis test:
--- start ---
test child forked, pid 610711
Testing perf lock record and perf lock contention
Testing perf lock contention --use-bpf
Testing perf lock record and perf lock contention at the same time
Testing perf lock contention --threads
Testing perf lock contention --lock-addr
Testing perf lock contention --lock-cgroup
Unexpected signal in test_aggr_cgroup
---- end(0) ----
85: kernel lock contention analysis test : Ok

After patch:

# ./perf test -vv "lock contention"
85: kernel lock contention analysis test:
--- start ---
test child forked, pid 602637
Testing perf lock record and perf lock contention
Testing perf lock contention --use-bpf
Testing perf lock record and perf lock contention at the same time
Testing perf lock contention --threads
Testing perf lock contention --lock-addr
Testing perf lock contention --lock-cgroup
Testing perf lock contention --type-filter (w/ spinlock)
Testing perf lock contention --lock-filter (w/ tasklist_lock)
Testing perf lock contention --callstack-filter (w/ unix_stream)
[Skip] Could not find 'unix_stream'
Testing perf lock contention --callstack-filter with task aggregation
[Skip] Could not find 'unix_stream'
Testing perf lock contention --cgroup-filter
Testing perf lock contention CSV output
---- end(0) ----
85: kernel lock contention analysis test : Ok

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Cc: Tycho Andersen <tycho@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ravi Bangoria and committed by
Arnaldo Carvalho de Melo
3c723f44 d0206db9

+9 -5
+9 -5
tools/perf/tests/shell/lock_contention.sh
··· 13 13 rm -f ${perfdata} 14 14 rm -f ${result} 15 15 rm -f ${errout} 16 - trap - EXIT TERM INT 16 + trap - EXIT TERM INT ERR 17 17 } 18 18 19 19 trap_cleanup() { 20 + if (( $? == 139 )); then #SIGSEGV 21 + err=1 22 + fi 20 23 echo "Unexpected signal in ${FUNCNAME[1]}" 21 24 cleanup 22 25 exit ${err} 23 26 } 24 - trap trap_cleanup EXIT TERM INT 27 + trap trap_cleanup EXIT TERM INT ERR 25 28 26 29 check() { 27 30 if [ "$(id -u)" != 0 ]; then ··· 148 145 fi 149 146 150 147 # the perf lock contention output goes to the stderr 151 - perf lock con -a -b -g -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result} 148 + perf lock con -a -b --lock-cgroup -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result} 152 149 if [ "$(cat "${result}" | wc -l)" != "1" ]; then 153 150 echo "[Fail] BPF result count is not 1:" "$(cat "${result}" | wc -l)" 154 151 err=1 ··· 274 271 return 275 272 fi 276 273 277 - perf lock con -a -b -g -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result} 274 + perf lock con -a -b --lock-cgroup -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result} 278 275 if [ "$(cat "${result}" | wc -l)" != "1" ]; then 279 276 echo "[Fail] BPF result should have a cgroup result:" "$(cat "${result}")" 280 277 err=1 ··· 282 279 fi 283 280 284 281 cgroup=$(cat "${result}" | awk '{ print $3 }') 285 - perf lock con -a -b -g -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result} 282 + perf lock con -a -b --lock-cgroup -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result} 286 283 if [ "$(cat "${result}" | wc -l)" != "1" ]; then 287 284 echo "[Fail] BPF result should have a result with cgroup filter:" "$(cat "${cgroup}")" 288 285 err=1 ··· 341 338 test_cgroup_filter 342 339 test_csv_output 343 340 341 + cleanup 344 342 exit ${err}