Skip to content

Commit f574e72

Browse files
namhyungKernel Patches Daemon
authored andcommitted
perf offcpu: Update offcpu test for child process
Record off-cpu data with perf bench sched messaging workload and count the number of offcpu-time events. Also update the test script not to run next tests if failed already and revise the error messages. $ sudo ./perf test offcpu -v 88: perf record offcpu profiling tests : --- start --- test child forked, pid 344780 Checking off-cpu privilege Basic off-cpu test Basic off-cpu test [Success] Child task off-cpu test Child task off-cpu test [Success] test child finished with 0 ---- end ---- perf record offcpu profiling tests: Ok Signed-off-by: Namhyung Kim <[email protected]>
1 parent c5b1985 commit f574e72

File tree

1 file changed

+50
-7
lines changed

1 file changed

+50
-7
lines changed

tools/perf/tests/shell/record_offcpu.sh

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,26 @@ trap_cleanup() {
1919
}
2020
trap trap_cleanup exit term int
2121

22-
test_offcpu() {
23-
echo "Basic off-cpu test"
22+
test_offcpu_priv() {
23+
echo "Checking off-cpu privilege"
24+
2425
if [ `id -u` != 0 ]
2526
then
26-
echo "Basic off-cpu test [Skipped permission]"
27+
echo "off-cpu test [Skipped permission]"
2728
err=2
2829
return
2930
fi
30-
if perf record --off-cpu -o ${perfdata} --quiet true 2>&1 | grep BUILD_BPF_SKEL
31+
if perf record --off-cpu -o /dev/null --quiet true 2>&1 | grep BUILD_BPF_SKEL
3132
then
32-
echo "Basic off-cpu test [Skipped missing BPF support]"
33+
echo "off-cpu test [Skipped missing BPF support]"
3334
err=2
3435
return
3536
fi
37+
}
38+
39+
test_offcpu_basic() {
40+
echo "Basic off-cpu test"
41+
3642
if ! perf record --off-cpu -e dummy -o ${perfdata} sleep 1 2> /dev/null
3743
then
3844
echo "Basic off-cpu test [Failed record]"
@@ -41,7 +47,7 @@ test_offcpu() {
4147
fi
4248
if ! perf evlist -i ${perfdata} | grep -q "offcpu-time"
4349
then
44-
echo "Basic off-cpu test [Failed record]"
50+
echo "Basic off-cpu test [Failed no event]"
4551
err=1
4652
return
4753
fi
@@ -54,7 +60,44 @@ test_offcpu() {
5460
echo "Basic off-cpu test [Success]"
5561
}
5662

57-
test_offcpu
63+
test_offcpu_child() {
64+
echo "Child task off-cpu test"
65+
66+
# perf bench sched messaging creates 400 processes
67+
if ! perf record --off-cpu -e dummy -o ${perfdata} -- \
68+
perf bench sched messaging -g 10 > /dev/null 2&>1
69+
then
70+
echo "Child task off-cpu test [Failed record]"
71+
err=1
72+
return
73+
fi
74+
if ! perf evlist -i ${perfdata} | grep -q "offcpu-time"
75+
then
76+
echo "Child task off-cpu test [Failed no event]"
77+
err=1
78+
return
79+
fi
80+
# each process waits for read and write, so it should be more than 800 events
81+
if ! perf report -i ${perfdata} -s comm -q -n -t ';' --percent-limit=90 | \
82+
awk -F ";" '{ if (NF > 3 && int($3) < 800) exit 1; }'
83+
then
84+
echo "Child task off-cpu test [Failed invalid output]"
85+
err=1
86+
return
87+
fi
88+
echo "Child task off-cpu test [Success]"
89+
}
90+
91+
92+
test_offcpu_priv
93+
94+
if [ $err = 0 ]; then
95+
test_offcpu_basic
96+
fi
97+
98+
if [ $err = 0 ]; then
99+
test_offcpu_child
100+
fi
58101

59102
cleanup
60103
exit $err

0 commit comments

Comments
 (0)