Skip to content

Commit 5985329

Browse files
akanksha216mhiramat
authored andcommitted
selftests/ftrace: Add new test case which checks for optimized probes
Add new test case kprobe_opt_types.tc which enables and checks if each probe has been optimized in order to test potential issues with optimized probes. The '|| continue' is added with the echo statement to ignore errors that are caused by trying to add kprobes to non probeable lines and continue with the test. Link: Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Signed-off-by: Akanksha J N <[email protected]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Acked-by: Shuah Khan <[email protected]> Acked-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent cf9071d commit 5985329

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0-or-later
3+
# Copyright (C) 2023 Akanksha J N, IBM corporation
4+
# description: Register/unregister optimized probe
5+
# requires: kprobe_events
6+
7+
case `uname -m` in
8+
x86_64)
9+
;;
10+
arm*)
11+
;;
12+
ppc*)
13+
;;
14+
*)
15+
echo "Please implement other architecture here"
16+
exit_unsupported
17+
esac
18+
19+
DEFAULT=$(cat /proc/sys/debug/kprobes-optimization)
20+
echo 1 > /proc/sys/debug/kprobes-optimization
21+
for i in `seq 0 255`; do
22+
echo "p:testprobe $FUNCTION_FORK+${i}" > kprobe_events || continue
23+
echo 1 > events/kprobes/enable || continue
24+
(echo "forked")
25+
PROBE=$(grep $FUNCTION_FORK /sys/kernel/debug/kprobes/list)
26+
echo 0 > events/kprobes/enable
27+
echo > kprobe_events
28+
if echo $PROBE | grep -q OPTIMIZED; then
29+
echo "$DEFAULT" > /proc/sys/debug/kprobes-optimization
30+
exit_pass
31+
fi
32+
done
33+
echo "$DEFAULT" > /proc/sys/debug/kprobes-optimization
34+
exit_unresolved

0 commit comments

Comments
 (0)