* [PATCH] selftests/ftrace: Let fprobe test consider already enabled functions
@ 2025-02-26 14:27 Heiko Carstens
2025-02-26 14:54 ` Masami Hiramatsu
0 siblings, 1 reply; 6+ messages in thread
From: Heiko Carstens @ 2025-02-26 14:27 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers,
Andrew Morton, Sven Schnelle, Vasily Gorbik, Alexander Gordeev
Cc: linux-kernel, linux-trace-kernel
The fprobe test fails on Fedora 41 since the fprobe test assumption that
the number of enabled_functions is zero before the test starts is not
necessarily true. Some user space tools, like systemd, add BPF programs
that attach to functions. Those will show up in the enabled_functions table
and must be taken into account by the fprobe test.
Therefore count the number of lines of enabled_functions before tests
start, and use that as base when comparing expected results.
Fixes: e85c5e9792b9 ("selftests/ftrace: Update fprobe test to check enabled_functions file")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
.../test.d/dynevent/add_remove_fprobe.tc | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc
index 449f9d8be746..73f6c6fcecab 100644
--- a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc
+++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc
@@ -10,12 +10,16 @@ PLACE=$FUNCTION_FORK
PLACE2="kmem_cache_free"
PLACE3="schedule_timeout"
+# Some functions may have BPF programs attached, therefore
+# count already enabled_functions before tests start
+ocnt=`cat enabled_functions | wc -l`
+
echo "f:myevent1 $PLACE" >> dynamic_events
# Make sure the event is attached and is the only one
grep -q $PLACE enabled_functions
cnt=`cat enabled_functions | wc -l`
-if [ $cnt -ne 1 ]; then
+if [ $cnt -ne $((ocnt + 1)) ]; then
exit_fail
fi
@@ -23,7 +27,7 @@ echo "f:myevent2 $PLACE%return" >> dynamic_events
# It should till be the only attached function
cnt=`cat enabled_functions | wc -l`
-if [ $cnt -ne 1 ]; then
+if [ $cnt -ne $((ocnt + 1)) ]; then
exit_fail
fi
@@ -32,7 +36,7 @@ echo "f:myevent3 $PLACE2" >> dynamic_events
grep -q $PLACE2 enabled_functions
cnt=`cat enabled_functions | wc -l`
-if [ $cnt -ne 2 ]; then
+if [ $cnt -ne $((ocnt + 2)) ]; then
exit_fail
fi
@@ -49,7 +53,7 @@ grep -q myevent1 dynamic_events
# should still have 2 left
cnt=`cat enabled_functions | wc -l`
-if [ $cnt -ne 2 ]; then
+if [ $cnt -ne $((ocnt + 2)) ]; then
exit_fail
fi
@@ -57,7 +61,7 @@ echo > dynamic_events
# Should have none left
cnt=`cat enabled_functions | wc -l`
-if [ $cnt -ne 0 ]; then
+if [ $cnt -ne $ocnt ]; then
exit_fail
fi
@@ -65,7 +69,7 @@ echo "f:myevent4 $PLACE" >> dynamic_events
# Should only have one enabled
cnt=`cat enabled_functions | wc -l`
-if [ $cnt -ne 1 ]; then
+if [ $cnt -ne $((ocnt + 1)) ]; then
exit_fail
fi
@@ -73,7 +77,7 @@ echo > dynamic_events
# Should have none left
cnt=`cat enabled_functions | wc -l`
-if [ $cnt -ne 0 ]; then
+if [ $cnt -ne $ocnt ]; then
exit_fail
fi
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/ftrace: Let fprobe test consider already enabled functions
2025-02-26 14:27 [PATCH] selftests/ftrace: Let fprobe test consider already enabled functions Heiko Carstens
@ 2025-02-26 14:54 ` Masami Hiramatsu
2025-02-26 15:28 ` Heiko Carstens
2025-02-26 16:13 ` Steven Rostedt
0 siblings, 2 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2025-02-26 14:54 UTC (permalink / raw)
To: Heiko Carstens
Cc: Steven Rostedt, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
Sven Schnelle, Vasily Gorbik, Alexander Gordeev, linux-kernel,
linux-trace-kernel
On Wed, 26 Feb 2025 15:27:03 +0100
Heiko Carstens <hca@linux.ibm.com> wrote:
> The fprobe test fails on Fedora 41 since the fprobe test assumption that
> the number of enabled_functions is zero before the test starts is not
> necessarily true. Some user space tools, like systemd, add BPF programs
> that attach to functions. Those will show up in the enabled_functions table
> and must be taken into account by the fprobe test.
Hmm, this ftrace selftests has been expected to be run without
any BPF programs... Is there any other issue on other test cases?
Anyway, this looks good to me.
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thank you!
>
> Therefore count the number of lines of enabled_functions before tests
> start, and use that as base when comparing expected results.
>
> Fixes: e85c5e9792b9 ("selftests/ftrace: Update fprobe test to check enabled_functions file")
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> ---
> .../test.d/dynevent/add_remove_fprobe.tc | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc
> index 449f9d8be746..73f6c6fcecab 100644
> --- a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc
> +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc
> @@ -10,12 +10,16 @@ PLACE=$FUNCTION_FORK
> PLACE2="kmem_cache_free"
> PLACE3="schedule_timeout"
>
> +# Some functions may have BPF programs attached, therefore
> +# count already enabled_functions before tests start
> +ocnt=`cat enabled_functions | wc -l`
> +
> echo "f:myevent1 $PLACE" >> dynamic_events
>
> # Make sure the event is attached and is the only one
> grep -q $PLACE enabled_functions
> cnt=`cat enabled_functions | wc -l`
> -if [ $cnt -ne 1 ]; then
> +if [ $cnt -ne $((ocnt + 1)) ]; then
> exit_fail
> fi
>
> @@ -23,7 +27,7 @@ echo "f:myevent2 $PLACE%return" >> dynamic_events
>
> # It should till be the only attached function
> cnt=`cat enabled_functions | wc -l`
> -if [ $cnt -ne 1 ]; then
> +if [ $cnt -ne $((ocnt + 1)) ]; then
> exit_fail
> fi
>
> @@ -32,7 +36,7 @@ echo "f:myevent3 $PLACE2" >> dynamic_events
>
> grep -q $PLACE2 enabled_functions
> cnt=`cat enabled_functions | wc -l`
> -if [ $cnt -ne 2 ]; then
> +if [ $cnt -ne $((ocnt + 2)) ]; then
> exit_fail
> fi
>
> @@ -49,7 +53,7 @@ grep -q myevent1 dynamic_events
>
> # should still have 2 left
> cnt=`cat enabled_functions | wc -l`
> -if [ $cnt -ne 2 ]; then
> +if [ $cnt -ne $((ocnt + 2)) ]; then
> exit_fail
> fi
>
> @@ -57,7 +61,7 @@ echo > dynamic_events
>
> # Should have none left
> cnt=`cat enabled_functions | wc -l`
> -if [ $cnt -ne 0 ]; then
> +if [ $cnt -ne $ocnt ]; then
> exit_fail
> fi
>
> @@ -65,7 +69,7 @@ echo "f:myevent4 $PLACE" >> dynamic_events
>
> # Should only have one enabled
> cnt=`cat enabled_functions | wc -l`
> -if [ $cnt -ne 1 ]; then
> +if [ $cnt -ne $((ocnt + 1)) ]; then
> exit_fail
> fi
>
> @@ -73,7 +77,7 @@ echo > dynamic_events
>
> # Should have none left
> cnt=`cat enabled_functions | wc -l`
> -if [ $cnt -ne 0 ]; then
> +if [ $cnt -ne $ocnt ]; then
> exit_fail
> fi
>
> --
> 2.45.2
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/ftrace: Let fprobe test consider already enabled functions
2025-02-26 14:54 ` Masami Hiramatsu
@ 2025-02-26 15:28 ` Heiko Carstens
2025-02-26 16:18 ` Steven Rostedt
2025-02-26 16:13 ` Steven Rostedt
1 sibling, 1 reply; 6+ messages in thread
From: Heiko Carstens @ 2025-02-26 15:28 UTC (permalink / raw)
To: Masami Hiramatsu
Cc: Steven Rostedt, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
Sven Schnelle, Vasily Gorbik, Alexander Gordeev, linux-kernel,
linux-trace-kernel
On Wed, Feb 26, 2025 at 11:54:47PM +0900, Masami Hiramatsu wrote:
> On Wed, 26 Feb 2025 15:27:03 +0100
> Heiko Carstens <hca@linux.ibm.com> wrote:
>
> > The fprobe test fails on Fedora 41 since the fprobe test assumption that
> > the number of enabled_functions is zero before the test starts is not
> > necessarily true. Some user space tools, like systemd, add BPF programs
> > that attach to functions. Those will show up in the enabled_functions table
> > and must be taken into account by the fprobe test.
>
> Hmm, this ftrace selftests has been expected to be run without
> any BPF programs... Is there any other issue on other test cases?
At least on s390 all tests pass now.
That is of course except for the "add/remove/test uprobe events" test
where I sent a patch. Not sure what will happen with that one:
https://lore.kernel.org/all/20250220130102.2079179-1-hca@linux.ibm.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/ftrace: Let fprobe test consider already enabled functions
2025-02-26 14:54 ` Masami Hiramatsu
2025-02-26 15:28 ` Heiko Carstens
@ 2025-02-26 16:13 ` Steven Rostedt
2025-02-26 23:51 ` Masami Hiramatsu
1 sibling, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2025-02-26 16:13 UTC (permalink / raw)
To: Masami Hiramatsu (Google)
Cc: Heiko Carstens, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
Sven Schnelle, Vasily Gorbik, Alexander Gordeev, linux-kernel,
linux-trace-kernel
On Wed, 26 Feb 2025 23:54:47 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> Hmm, this ftrace selftests has been expected to be run without
> any BPF programs... Is there any other issue on other test cases?
Unfortunately, systemd is starting to add BPF programs :-p
I noticed that my laptop has users.
-- Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/ftrace: Let fprobe test consider already enabled functions
2025-02-26 15:28 ` Heiko Carstens
@ 2025-02-26 16:18 ` Steven Rostedt
0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2025-02-26 16:18 UTC (permalink / raw)
To: Heiko Carstens
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
Sven Schnelle, Vasily Gorbik, Alexander Gordeev, linux-kernel,
linux-trace-kernel
On Wed, 26 Feb 2025 16:28:35 +0100
Heiko Carstens <hca@linux.ibm.com> wrote:
> That is of course except for the "add/remove/test uprobe events" test
> where I sent a patch. Not sure what will happen with that one:
>
> https://lore.kernel.org/all/20250220130102.2079179-1-hca@linux.ibm.com/
Shuah's kernel.org emails seem to be bouncing. I'll try her Linux
Foundation one for that.
-- Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/ftrace: Let fprobe test consider already enabled functions
2025-02-26 16:13 ` Steven Rostedt
@ 2025-02-26 23:51 ` Masami Hiramatsu
0 siblings, 0 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2025-02-26 23:51 UTC (permalink / raw)
To: Steven Rostedt
Cc: Heiko Carstens, Mark Rutland, Mathieu Desnoyers, Andrew Morton,
Sven Schnelle, Vasily Gorbik, Alexander Gordeev, linux-kernel,
linux-trace-kernel
On Wed, 26 Feb 2025 11:13:00 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Wed, 26 Feb 2025 23:54:47 +0900
> Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
>
> > Hmm, this ftrace selftests has been expected to be run without
> > any BPF programs... Is there any other issue on other test cases?
>
> Unfortunately, systemd is starting to add BPF programs :-p
>
> I noticed that my laptop has users.
Ah, I might need systemd-busybox to build minimum test environment :-(
Thanks,
>
> -- Steve
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-26 23:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 14:27 [PATCH] selftests/ftrace: Let fprobe test consider already enabled functions Heiko Carstens
2025-02-26 14:54 ` Masami Hiramatsu
2025-02-26 15:28 ` Heiko Carstens
2025-02-26 16:18 ` Steven Rostedt
2025-02-26 16:13 ` Steven Rostedt
2025-02-26 23:51 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox