Skip to content

Commit 0222450

Browse files
Jan Polenskynamhyung
authored andcommitted
perf test: Ensure lock contention using pipe mode
The 'kernel lock contention analysis test' requires reliable triggering of lock contention. On some systems, previous benchmark calls failed to generate sufficient contention due to low system activity or resource limits. This patch adds the -p (pipe) option to all calls of perf bench sched messaging, ensuring consistent lock contention without relying on socket-based communication. Suggested-by: Thomas Richter <[email protected]> Signed-off-by: Jan Polensky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 59edbec commit 0222450

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tools/perf/tests/shell/lock_contention.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ check() {
4444
test_record()
4545
{
4646
echo "Testing perf lock record and perf lock contention"
47-
perf lock record -o ${perfdata} -- perf bench sched messaging > /dev/null 2>&1
47+
perf lock record -o ${perfdata} -- perf bench sched messaging -p > /dev/null 2>&1
4848
# the output goes to the stderr and we expect only 1 output (-E 1)
4949
perf lock contention -i ${perfdata} -E 1 -q 2> ${result}
5050
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
@@ -64,7 +64,7 @@ test_bpf()
6464
fi
6565

6666
# the perf lock contention output goes to the stderr
67-
perf lock con -a -b -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
67+
perf lock con -a -b -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
6868
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
6969
echo "[Fail] BPF result count is not 1:" "$(cat "${result}" | wc -l)"
7070
err=1
@@ -75,7 +75,7 @@ test_bpf()
7575
test_record_concurrent()
7676
{
7777
echo "Testing perf lock record and perf lock contention at the same time"
78-
perf lock record -o- -- perf bench sched messaging 2> /dev/null | \
78+
perf lock record -o- -- perf bench sched messaging -p 2> /dev/null | \
7979
perf lock contention -i- -E 1 -q 2> ${result}
8080
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
8181
echo "[Fail] Recorded result count is not 1:" "$(cat "${result}" | wc -l)"
@@ -99,7 +99,7 @@ test_aggr_task()
9999
fi
100100

101101
# the perf lock contention output goes to the stderr
102-
perf lock con -a -b -t -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
102+
perf lock con -a -b -t -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
103103
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
104104
echo "[Fail] BPF result count is not 1:" "$(cat "${result}" | wc -l)"
105105
err=1
@@ -122,7 +122,7 @@ test_aggr_addr()
122122
fi
123123

124124
# the perf lock contention output goes to the stderr
125-
perf lock con -a -b -l -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
125+
perf lock con -a -b -l -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
126126
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
127127
echo "[Fail] BPF result count is not 1:" "$(cat "${result}" | wc -l)"
128128
err=1
@@ -140,7 +140,7 @@ test_aggr_cgroup()
140140
fi
141141

142142
# the perf lock contention output goes to the stderr
143-
perf lock con -a -b -g -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
143+
perf lock con -a -b -g -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
144144
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
145145
echo "[Fail] BPF result count is not 1:" "$(cat "${result}" | wc -l)"
146146
err=1
@@ -162,7 +162,7 @@ test_type_filter()
162162
return
163163
fi
164164

165-
perf lock con -a -b -Y spinlock -q -- perf bench sched messaging > /dev/null 2> ${result}
165+
perf lock con -a -b -Y spinlock -q -- perf bench sched messaging -p > /dev/null 2> ${result}
166166
if [ "$(grep -c -v spinlock "${result}")" != "0" ]; then
167167
echo "[Fail] BPF result should not have non-spinlocks:" "$(cat "${result}")"
168168
err=1
@@ -194,7 +194,7 @@ test_lock_filter()
194194
return
195195
fi
196196

197-
perf lock con -a -b -L tasklist_lock -q -- perf bench sched messaging > /dev/null 2> ${result}
197+
perf lock con -a -b -L tasklist_lock -q -- perf bench sched messaging -p > /dev/null 2> ${result}
198198
if [ "$(grep -c -v "${test_lock_filter_type}" "${result}")" != "0" ]; then
199199
echo "[Fail] BPF result should not have non-${test_lock_filter_type} locks:" "$(cat "${result}")"
200200
err=1
@@ -222,7 +222,7 @@ test_stack_filter()
222222
return
223223
fi
224224

225-
perf lock con -a -b -S unix_stream -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
225+
perf lock con -a -b -S unix_stream -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
226226
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
227227
echo "[Fail] BPF result should have a lock from unix_stream:" "$(cat "${result}")"
228228
err=1
@@ -250,7 +250,7 @@ test_aggr_task_stack_filter()
250250
return
251251
fi
252252

253-
perf lock con -a -b -t -S unix_stream -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
253+
perf lock con -a -b -t -S unix_stream -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
254254
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
255255
echo "[Fail] BPF result should have a task from unix_stream:" "$(cat "${result}")"
256256
err=1
@@ -266,15 +266,15 @@ test_cgroup_filter()
266266
return
267267
fi
268268

269-
perf lock con -a -b -g -E 1 -F wait_total -q -- perf bench sched messaging > /dev/null 2> ${result}
269+
perf lock con -a -b -g -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result}
270270
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
271271
echo "[Fail] BPF result should have a cgroup result:" "$(cat "${result}")"
272272
err=1
273273
exit
274274
fi
275275

276276
cgroup=$(cat "${result}" | awk '{ print $3 }')
277-
perf lock con -a -b -g -E 1 -G "${cgroup}" -q -- perf bench sched messaging > /dev/null 2> ${result}
277+
perf lock con -a -b -g -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result}
278278
if [ "$(cat "${result}" | wc -l)" != "1" ]; then
279279
echo "[Fail] BPF result should have a result with cgroup filter:" "$(cat "${cgroup}")"
280280
err=1
@@ -309,7 +309,7 @@ test_csv_output()
309309
fi
310310

311311
# the perf lock contention output goes to the stderr
312-
perf lock con -a -b -E 1 -x , --output ${result} -- perf bench sched messaging > /dev/null 2>&1
312+
perf lock con -a -b -E 1 -x , --output ${result} -- perf bench sched messaging -p > /dev/null 2>&1
313313
output=$(grep -v "^#" ${result} | tr -d -c , | wc -c)
314314
if [ "${header}" != "${output}" ]; then
315315
echo "[Fail] BPF result does not match the number of commas: ${header} != ${output}"

0 commit comments

Comments
 (0)