blob: cc9ceb9e19cafac295f7ce926fc02ab632eadf53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
#!/bin/sh
# kernel lock contention analysis test
# SPDX-License-Identifier: GPL-2.0
set -e
err=0
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
result=$(mktemp /tmp/__perf_test.result.XXXXX)
cleanup() {
rm -f ${perfdata}
rm -f ${result}
trap - exit term int
}
trap_cleanup() {
cleanup
exit ${err}
}
trap trap_cleanup exit term int
check() {
if [ `id -u` != 0 ]; then
echo "[Skip] No root permission"
err=2
exit
fi
if ! perf list | grep -q lock:contention_begin; then
echo "[Skip] No lock contention tracepoints"
err=2
exit
fi
}
test_record()
{
echo "Testing perf lock record and perf lock contention"
perf lock record -o ${perfdata} -- perf bench sched messaging > /dev/null 2>&1
# the output goes to the stderr and we expect only 1 output (-E 1)
perf lock contention -i ${perfdata} -E 1 -q 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] Recorded result count is not 1:" $(cat "${result}" | wc -l)
err=1
exit
fi
}
test_bpf()
{
echo "Testing perf lock contention --use-bpf"
if ! perf lock con -b true > /dev/null 2>&1 ; then
echo "[Skip] No BPF support"
return
fi
# the perf lock contention output goes to the stderr
perf lock con -a -b -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] BPF result count is not 1:" $(cat "${result}" | wc -l)
err=1
exit
fi
}
test_record_concurrent()
{
echo "Testing perf lock record and perf lock contention at the same time"
perf lock record -o- -- perf bench sched messaging 2> /dev/null | \
perf lock contention -i- -E 1 -q 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] Recorded result count is not 1:" $(cat "${result}" | wc -l)
err=1
exit
fi
}
test_aggr_task()
{
echo "Testing perf lock contention --threads"
perf lock contention -i ${perfdata} -t -E 1 -q 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] Recorded result count is not 1:" $(cat "${result}" | wc -l)
err=1
exit
fi
if ! perf lock con -b true > /dev/null 2>&1 ; then
return
fi
# the perf lock contention output goes to the stderr
perf lock con -a -b -t -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] BPF result count is not 1:" $(cat "${result}" | wc -l)
err=1
exit
fi
}
test_aggr_addr()
{
echo "Testing perf lock contention --lock-addr"
perf lock contention -i ${perfdata} -l -E 1 -q 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] Recorded result count is not 1:" $(cat "${result}" | wc -l)
err=1
exit
fi
if ! perf lock con -b true > /dev/null 2>&1 ; then
return
fi
# the perf lock contention output goes to the stderr
perf lock con -a -b -t -E 1 -q -- perf bench sched messaging > /dev/null 2> ${result}
if [ $(cat "${result}" | wc -l) != "1" ]; then
echo "[Fail] BPF result count is not 1:" $(cat "${result}" | wc -l)
err=1
exit
fi
}
check
test_record
test_bpf
test_record_concurrent
test_aggr_task
test_aggr_addr
exit ${err}
|