Skip to content

Commit 604e354

Browse files
committed
selftests/ftrace: Select an existing function in kprobe_eventname test
Running the ftrace selftests on the latest kernel caused the kprobe_eventname test to fail. It was due to the test that searches for a function with at "dot" in the name and adding a probe to that. Unfortunately, for this test, it picked: optimize_nops.isra.2.cold.4 Which happens to be marked as "__init", which means it no longer exists in the kernel! (kallsyms keeps those function names around for tracing purposes) As only functions that still exist are in the available_filter_functions file, as they are removed when the functions are freed at boot or module exit, have the test search for a function with ".isra." in the name as well as being in the available_filter_functions (if the file exists). Link: http://lkml.kernel.org/r/[email protected] Acked-by: Masami Hiramatsu <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent d59fae6 commit 604e354

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,21 @@ test -d events/kprobes2/event2 || exit_failure
2424

2525
:;: "Add an event on dot function without name" ;:
2626

27-
FUNC=`grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "`
27+
find_dot_func() {
28+
if [ ! -f available_filter_functions ]; then
29+
grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "
30+
return;
31+
fi
32+
33+
grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
34+
if grep -s $f available_filter_functions; then
35+
echo $f
36+
break
37+
fi
38+
done
39+
}
40+
41+
FUNC=`find_dot_func | tail -n 1`
2842
[ "x" != "x$FUNC" ] || exit_unresolved
2943
echo "p $FUNC" > kprobe_events
3044
EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`

0 commit comments

Comments
 (0)