Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 # description: Test ftrace direct functions against kprobes
0004 # requires: kprobe_events
0005 
0006 rmmod ftrace-direct ||:
0007 if ! modprobe ftrace-direct ; then
0008   echo "No ftrace-direct sample module - please build with CONFIG_SAMPLE_FTRACE_DIRECT=m"
0009   exit_unresolved;
0010 fi
0011 
0012 echo "Let the module run a little"
0013 sleep 1
0014 
0015 grep -q "my_direct_func: waking up" trace
0016 
0017 rmmod ftrace-direct
0018 
0019 echo 'p:kwake wake_up_process task=$arg1' > kprobe_events
0020 
0021 start_direct() {
0022         echo > trace
0023         modprobe ftrace-direct
0024         sleep 1
0025         grep -q "my_direct_func: waking up" trace
0026 }
0027 
0028 stop_direct() {
0029         rmmod ftrace-direct
0030 }
0031 
0032 enable_probe() {
0033         echo > trace
0034         echo 1 > events/kprobes/kwake/enable
0035         sleep 1
0036         grep -q "kwake:" trace
0037 }
0038 
0039 disable_probe() {
0040         echo 0 > events/kprobes/kwake/enable
0041 }
0042 
0043 test_kprobes() {
0044         # probe -> direct -> no direct > no probe
0045         enable_probe
0046         start_direct
0047         stop_direct
0048         disable_probe
0049 
0050         # probe -> direct -> no probe > no direct
0051         enable_probe
0052         start_direct
0053         disable_probe
0054         stop_direct
0055 
0056         # direct -> probe -> no probe > no direct
0057         start_direct
0058         enable_probe
0059         disable_probe
0060         stop_direct
0061 
0062         # direct -> probe -> no direct > no noprobe
0063         start_direct
0064         enable_probe
0065         stop_direct
0066         disable_probe
0067 }
0068 
0069 test_kprobes
0070 
0071 # Now do this with a second registered direct function
0072 echo "Running with another ftrace direct function"
0073 
0074 modprobe ftrace-direct-too
0075 
0076 test_kprobes
0077 
0078 rmmod ftrace-direct-too
0079 
0080 echo > kprobe_events