hc
2023-10-25 6c2073b7aa40e29d0eca7d571dd7bc590c7ecaa7
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
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function profiler with function tracing
 
# There was a bug after a rewrite of the ftrace infrastructure that
# caused the function_profiler not to be able to run with the function
# tracer, because the function_profiler used the function_graph tracer
# and it was assumed the two could not run simultaneously.
#
# There was another related bug where the solution to the first bug
# broke the way filtering of the function tracer worked.
#
# This test triggers those bugs on those kernels.
#
# We need function_graph and profiling to to run this test
if ! grep -q function_graph available_tracers; then
    echo "no function graph tracer configured"
    exit_unsupported;
fi
 
if [ ! -f set_ftrace_filter ]; then
    echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
    exit_unsupported
fi
 
if [ ! -f function_profile_enabled ]; then
    echo "function_profile_enabled not found, function profiling enabled?"
    exit_unsupported
fi
 
fail() { # mesg
    reset_tracer
    echo > set_ftrace_filter
    echo $1
    exit_fail
}
 
echo "Testing function tracer with profiler:"
echo "enable function tracer"
echo function > current_tracer
echo "enable profiler"
echo 1 > function_profile_enabled
 
sleep 1
 
echo "Now filter on just schedule"
echo '*schedule' > set_ftrace_filter
clear_trace
 
echo "Now disable function profiler"
echo 0 > function_profile_enabled
 
sleep 1
 
# make sure only schedule functions exist
 
echo "testing if only schedule is being traced"
if grep -v -e '^#' -e 'schedule' trace; then
   fail "more than schedule was found"
fi
 
echo "Make sure schedule was traced"
if ! grep -e 'schedule' trace > /dev/null; then
   cat trace
   fail "can not find schedule in trace"
fi
 
echo > set_ftrace_filter
clear_trace
 
sleep 1
 
echo "make sure something other than scheduler is being traced"
if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then
   cat trace
   fail "no other functions besides schedule was found"
fi
 
reset_tracer
 
exit 0