* [PATCH] tracing/selftests: Fix kprobe event name test for .isra. functions
@ 2024-05-21 0:57 Steven Rostedt
2024-05-21 1:49 ` Masami Hiramatsu
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2024-05-21 0:57 UTC (permalink / raw)
To: LKML, Linux Trace Kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Shuah Khan, linux-kselftest
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
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: 604e3548236de ("selftests/ftrace: Select an existing function in kprobe_eventname test")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
.../testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
index 1f6981ef7afa..ba19b81cef39 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
@@ -30,7 +30,8 @@ find_dot_func() {
fi
grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
- if grep -s $f available_filter_functions; then
+ cnt=`grep -s $f available_filter_functions | wc -l`;
+ if [ $cnt -eq 1 ]; then
echo $f
break
fi
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/selftests: Fix kprobe event name test for .isra. functions
2024-05-21 0:57 [PATCH] tracing/selftests: Fix kprobe event name test for .isra. functions Steven Rostedt
@ 2024-05-21 1:49 ` Masami Hiramatsu
2024-05-21 1:51 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2024-05-21 1:49 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
Shuah Khan, linux-kselftest
On Mon, 20 May 2024 20:57:37 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> 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.
>
Looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks!
> Cc: stable@vger.kernel.org
> Fixes: 604e3548236de ("selftests/ftrace: Select an existing function in kprobe_eventname test")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> .../testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> index 1f6981ef7afa..ba19b81cef39 100644
> --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_eventname.tc
> @@ -30,7 +30,8 @@ find_dot_func() {
> fi
>
> grep " [tT] .*\.isra\..*" /proc/kallsyms | cut -f 3 -d " " | while read f; do
> - if grep -s $f available_filter_functions; then
> + cnt=`grep -s $f available_filter_functions | wc -l`;
> + if [ $cnt -eq 1 ]; then
> echo $f
> break
> fi
> --
> 2.43.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/selftests: Fix kprobe event name test for .isra. functions
2024-05-21 1:49 ` Masami Hiramatsu
@ 2024-05-21 1:51 ` Steven Rostedt
2024-05-21 15:10 ` Shuah Khan
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2024-05-21 1:51 UTC (permalink / raw)
To: Masami Hiramatsu (Google), Shuah Khan, Shuah Khan, Shuah Khan
Cc: LKML, Linux Trace Kernel, Mathieu Desnoyers, linux-kselftest
On Tue, 21 May 2024 10:49:19 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> > 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.
> >
>
> Looks good to me.
>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
Thanks Masami,
Shuah, can you take this through your tree?
Thanks,
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tracing/selftests: Fix kprobe event name test for .isra. functions
2024-05-21 1:51 ` Steven Rostedt
@ 2024-05-21 15:10 ` Shuah Khan
0 siblings, 0 replies; 4+ messages in thread
From: Shuah Khan @ 2024-05-21 15:10 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu (Google), Shuah Khan, Shuah Khan
Cc: LKML, Linux Trace Kernel, Mathieu Desnoyers, linux-kselftest,
Shuah Khan
On 5/20/24 19:51, Steven Rostedt wrote:
> On Tue, 21 May 2024 10:49:19 +0900
> Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
>
>>> 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.
>>>
>>
>> Looks good to me.
>>
>> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>>
>
> Thanks Masami,
>
> Shuah, can you take this through your tree?
Yes. I will take this though mine.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-21 15:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 0:57 [PATCH] tracing/selftests: Fix kprobe event name test for .isra. functions Steven Rostedt
2024-05-21 1:49 ` Masami Hiramatsu
2024-05-21 1:51 ` Steven Rostedt
2024-05-21 15:10 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox