~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/shell/record_offcpu.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/sh
  2 # perf record offcpu profiling tests
  3 # SPDX-License-Identifier: GPL-2.0
  4 
  5 set -e
  6 
  7 err=0
  8 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
  9 
 10 cleanup() {
 11   rm -f ${perfdata}
 12   rm -f ${perfdata}.old
 13   trap - EXIT TERM INT
 14 }
 15 
 16 trap_cleanup() {
 17   cleanup
 18   exit 1
 19 }
 20 trap trap_cleanup EXIT TERM INT
 21 
 22 test_offcpu_priv() {
 23   echo "Checking off-cpu privilege"
 24 
 25   if [ "$(id -u)" != 0 ]
 26   then
 27     echo "off-cpu test [Skipped permission]"
 28     err=2
 29     return
 30   fi
 31   if perf version --build-options 2>&1 | grep HAVE_BPF_SKEL | grep -q OFF
 32   then
 33     echo "off-cpu test [Skipped missing BPF support]"
 34     err=2
 35     return
 36   fi
 37 }
 38 
 39 test_offcpu_basic() {
 40   echo "Basic off-cpu test"
 41 
 42   if ! perf record --off-cpu -e dummy -o ${perfdata} sleep 1 2> /dev/null
 43   then
 44     echo "Basic off-cpu test [Failed record]"
 45     err=1
 46     return
 47   fi
 48   if ! perf evlist -i ${perfdata} | grep -q "offcpu-time"
 49   then
 50     echo "Basic off-cpu test [Failed no event]"
 51     err=1
 52     return
 53   fi
 54   if ! perf report -i ${perfdata} -q --percent-limit=90 | grep -E -q sleep
 55   then
 56     echo "Basic off-cpu test [Failed missing output]"
 57     err=1
 58     return
 59   fi
 60   echo "Basic off-cpu test [Success]"
 61 }
 62 
 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 at least for poll, so it should be more than 400 events
 81   if ! perf report -i ${perfdata} -s comm -q -n -t ';' --percent-limit=90 | \
 82     awk -F ";" '{ if (NF > 3 && int($3) < 400) 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
101 
102 cleanup
103 exit $err

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php