Skip to content

Commit 3c723f4

Browse files
Ravi Bangoriaacmel
authored andcommitted
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 4d1792d ("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 <[email protected]> Signed-off-by: Ravi Bangoria <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ananth Narayan <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Sandipan Das <[email protected]> Cc: Santosh Shukla <[email protected]> Cc: Tycho Andersen <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d0206db commit 3c723f4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tools/perf/tests/shell/lock_contention.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ cleanup() {
1313
rm -f ${perfdata}
1414
rm -f ${result}
1515
rm -f ${errout}
16-
trap - EXIT TERM INT
16+
trap - EXIT TERM INT ERR
1717
}
1818

1919
trap_cleanup() {
20+
if (( $? == 139 )); then #SIGSEGV
21+
err=1
22+
fi
2023
echo "Unexpected signal in ${FUNCNAME[1]}"
2124
cleanup
2225
exit ${err}
2326
}
24-
trap trap_cleanup EXIT TERM INT
27+
trap trap_cleanup EXIT TERM INT ERR
2528

2629
check() {
2730
if [ "$(id -u)" != 0 ]; then
@@ -145,7 +148,7 @@ test_aggr_cgroup()
145148
fi
146149

147150
# the perf lock contention output goes to the stderr
148-
perf lock con -a -b -g -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
151+
perf lock con -a -b --lock-cgroup -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
149152
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
150153
echo "[Fail] BPF result count is not 1:" "$(cat "${result}" | wc -l)"
151154
err=1
@@ -271,15 +274,15 @@ test_cgroup_filter()
271274
return
272275
fi
273276

274-
perf lock con -a -b -g -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result}
277+
perf lock con -a -b --lock-cgroup -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result}
275278
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
276279
echo "[Fail] BPF result should have a cgroup result:" "$(cat "${result}")"
277280
err=1
278281
exit
279282
fi
280283

281284
cgroup=$(cat "${result}" | awk '{ print $3 }')
282-
perf lock con -a -b -g -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result}
285+
perf lock con -a -b --lock-cgroup -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result}
283286
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
284287
echo "[Fail] BPF result should have a result with cgroup filter:" "$(cat "${cgroup}")"
285288
err=1
@@ -338,4 +341,5 @@ test_aggr_task_stack_filter
338341
test_cgroup_filter
339342
test_csv_output
340343

344+
cleanup
341345
exit ${err}

0 commit comments

Comments
 (0)