2 # perf record offcpu profiling tests
3 # SPDX-License-Identifier: GPL-2.0
8 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
20 trap trap_cleanup exit term int
23 echo "Checking off-cpu privilege"
27 echo "off-cpu test [Skipped permission]"
31 if perf record --off-cpu -o /dev/null --quiet true 2>&1 | grep BUILD_BPF_SKEL
33 echo "off-cpu test [Skipped missing BPF support]"
40 echo "Basic off-cpu test"
42 if ! perf record --off-cpu -e dummy -o ${perfdata} sleep 1 2> /dev/null
44 echo "Basic off-cpu test [Failed record]"
48 if ! perf evlist -i ${perfdata} | grep -q "offcpu-time"
50 echo "Basic off-cpu test [Failed no event]"
54 if ! perf report -i ${perfdata} -q --percent-limit=90 | egrep -q sleep
56 echo "Basic off-cpu test [Failed missing output]"
60 echo "Basic off-cpu test [Success]"
64 echo "Child task off-cpu test"
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
70 echo "Child task off-cpu test [Failed record]"
74 if ! perf evlist -i ${perfdata} | grep -q "offcpu-time"
76 echo "Child task off-cpu test [Failed no event]"
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; }'
84 echo "Child task off-cpu test [Failed invalid output]"
88 echo "Child task off-cpu test [Success]"