Skip to content

Commit 3425a20

Browse files
rnavshuahkh
authored andcommitted
selftests/ftrace: Add test to exercize function tracer across cpu hotplug
Add a test to exercize cpu hotplug with the function tracer active to ensure that sensitive functions in idle path are excluded from being traced. This helps catch issues such as the one fixed by commit 4b3338a ("powerpc/ftrace: Fix stack teardown in ftrace_no_trace"). Signed-off-by: Naveen N Rao <naveen@kernel.org> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 5bc9dc0 commit 3425a20

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0-or-later
3+
# description: ftrace - function trace across cpu hotplug
4+
# requires: function:tracer
5+
6+
if ! which nproc ; then
7+
nproc() {
8+
ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l
9+
}
10+
fi
11+
12+
NP=`nproc`
13+
14+
if [ $NP -eq 1 ] ;then
15+
echo "We cannot test cpu hotplug in UP environment"
16+
exit_unresolved
17+
fi
18+
19+
# Find online cpu
20+
for i in /sys/devices/system/cpu/cpu[1-9]*; do
21+
if [ -f $i/online ] && [ "$(cat $i/online)" = "1" ]; then
22+
cpu=$i
23+
break
24+
fi
25+
done
26+
27+
if [ -z "$cpu" ]; then
28+
echo "We cannot test cpu hotplug with a single cpu online"
29+
exit_unresolved
30+
fi
31+
32+
echo 0 > tracing_on
33+
echo > trace
34+
35+
: "Set $(basename $cpu) offline/online with function tracer enabled"
36+
echo function > current_tracer
37+
echo 1 > tracing_on
38+
(echo 0 > $cpu/online)
39+
(echo "forked"; sleep 1)
40+
(echo 1 > $cpu/online)
41+
echo 0 > tracing_on
42+
echo nop > current_tracer

0 commit comments

Comments
 (0)