mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-09 08:31:17 +00:00

The kprobe_eventname.tc test checks if a function with .isra. can have a
kprobe attached to it. It loops through the kallsyms file for all the
functions that have the .isra. name, and checks if it exists in the
available_filter_functions file, and if it does, it uses it to attach a
kprobe to it.
The issue is that kprobes can not attach to functions that are listed more
than once in available_filter_functions. With the latest kernel, the
function that is found is: rapl_event_update.isra.0
# grep rapl_event_update.isra.0 /sys/kernel/tracing/available_filter_functions
rapl_event_update.isra.0
rapl_event_update.isra.0
It is listed twice. This causes the attached kprobe to it to fail which in
turn fails the test. Instead of just picking the function function that is
found in available_filter_functions, pick the first one that is listed
only once in available_filter_functions.
Cc: stable@vger.kernel.org
Fixes: 604e354823
("selftests/ftrace: Select an existing function in kprobe_eventname test")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
47 lines
1.3 KiB
Bash
47 lines
1.3 KiB
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# description: Kprobe event auto/manual naming
|
|
# requires: kprobe_events
|
|
|
|
:;: "Add an event on function without name" ;:
|
|
|
|
FUNC=`grep " [tT] .*vfs_read$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "`
|
|
[ "x" != "x$FUNC" ] || exit_unresolved
|
|
echo "p $FUNC" > kprobe_events
|
|
PROBE_NAME=`echo $FUNC | tr ".:" "_"`
|
|
test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure
|
|
|
|
:;: "Add an event on function with new name" ;:
|
|
|
|
echo "p:event1 $FUNC" > kprobe_events
|
|
test -d events/kprobes/event1 || exit_failure
|
|
|
|
:;: "Add an event on function with new name and group" ;:
|
|
|
|
echo "p:kprobes2/event2 $FUNC" > kprobe_events
|
|
test -d events/kprobes2/event2 || exit_failure
|
|
|
|
:;: "Add an event on dot function without name" ;:
|
|
|
|
find_dot_func() {
|
|
if [ ! -f available_filter_functions ]; then
|
|
grep -m 10 " [tT] .*\.isra\..*$" /proc/kallsyms | tail -n 1 | cut -f 3 -d " "
|
|
return;
|
|
fi
|
|
|
|
grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
|
|
cnt=`grep -s $f available_filter_functions | wc -l`;
|
|
if [ $cnt -eq 1 ]; then
|
|
echo $f
|
|
break
|
|
fi
|
|
done
|
|
}
|
|
|
|
FUNC=`find_dot_func | tail -n 1`
|
|
[ "x" != "x$FUNC" ] || exit_unresolved
|
|
echo "p $FUNC" > kprobe_events
|
|
EVENT=`grep $FUNC kprobe_events | cut -f 1 -d " " | cut -f 2 -d:`
|
|
[ "x" != "x$EVENT" ] || exit_failure
|
|
test -d events/$EVENT || exit_failure
|