* [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler
@ 2024-08-21 19:09 Steven Rostedt
2024-08-22 3:54 ` Shuah Khan
2024-08-25 15:14 ` Masami Hiramatsu
0 siblings, 2 replies; 5+ messages in thread
From: Steven Rostedt @ 2024-08-21 19:09 UTC (permalink / raw)
To: LKML, Linux Trace Kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Mark Rutland, Shuah Khan,
Shuah Khan, linux-kselftest
From: Steven Rostedt <rostedt@goodmis.org>
Masami reported a bug when running function graph tracing then the
function profiler. The following commands would cause a kernel crash:
# cd /sys/kernel/tracing/
# echo function_graph > current_tracer
# echo 1 > function_profile_enabled
In that order. Create a test to test this two to make sure this does not
come back as a regression.
Link: https://lore.kernel.org/172398528350.293426.8347220120333730248.stgit@devnote2
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
.../ftrace/test.d/ftrace/fgraph-profiler.tc | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
new file mode 100644
index 000000000000..62d44a1395da
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
@@ -0,0 +1,30 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: ftrace - function profiler with function graph tracing
+# requires: function_profile_enabled set_ftrace_filter function_graph:tracer
+
+# The function graph tracer can now be run along side of the function
+# profiler. But there was a bug that caused the combination of the two
+# to crash. It also required the function graph tracer to be started
+# first.
+#
+# This test triggers that bug
+#
+# We need function_graph and profiling to to run this test
+
+fail() { # mesg
+ echo $1
+ exit_fail
+}
+
+echo "Enabling function graph tracer:"
+echo function_graph > current_tracer
+echo "enable profiler"
+
+# Older kernels do not allow function_profile to be enabled with
+# function graph tracer. If the below fails, mark it as unsupported
+echo 1 > function_profile_enabled || exit_unsupported
+
+sleep 1
+
+exit 0
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler
2024-08-21 19:09 [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler Steven Rostedt
@ 2024-08-22 3:54 ` Shuah Khan
2024-08-22 13:19 ` Steven Rostedt
2024-08-25 15:14 ` Masami Hiramatsu
1 sibling, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2024-08-22 3:54 UTC (permalink / raw)
To: Steven Rostedt, LKML, Linux Trace Kernel
Cc: Masami Hiramatsu, Mathieu Desnoyers, Mark Rutland, Shuah Khan,
linux-kselftest, Shuah Khan
On 8/21/24 13:09, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> Masami reported a bug when running function graph tracing then the
> function profiler. The following commands would cause a kernel crash:
>
> # cd /sys/kernel/tracing/
> # echo function_graph > current_tracer
> # echo 1 > function_profile_enabled
>
> In that order. Create a test to test this two to make sure this does not
> come back as a regression.
>
> Link: https://lore.kernel.org/172398528350.293426.8347220120333730248.stgit@devnote2
>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> .../ftrace/test.d/ftrace/fgraph-profiler.tc | 30 +++++++++++++++++++
> 1 file changed, 30 insertions(+)
> create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
>
> diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
> new file mode 100644
> index 000000000000..62d44a1395da
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
> @@ -0,0 +1,30 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: ftrace - function profiler with function graph tracing
> +# requires: function_profile_enabled set_ftrace_filter function_graph:tracer
> +
> +# The function graph tracer can now be run along side of the function
> +# profiler. But there was a bug that caused the combination of the two
> +# to crash. It also required the function graph tracer to be started
> +# first.
> +#
> +# This test triggers that bug
> +#
> +# We need function_graph and profiling to to run this test
> +
> +fail() { # mesg
> + echo $1
> + exit_fail
> +}
> +
> +echo "Enabling function graph tracer:"
> +echo function_graph > current_tracer
> +echo "enable profiler"
> +
> +# Older kernels do not allow function_profile to be enabled with
> +# function graph tracer. If the below fails, mark it as unsupported
> +echo 1 > function_profile_enabled || exit_unsupported
> +
> +sleep 1
Any specific reason for this sleep 1 - can you add a comment on top?
> +
> +exit 0
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Let me know if you would like v2 for this to be taken through my tree.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler
2024-08-22 3:54 ` Shuah Khan
@ 2024-08-22 13:19 ` Steven Rostedt
2024-08-26 13:53 ` Shuah Khan
0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2024-08-22 13:19 UTC (permalink / raw)
To: Shuah Khan
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
Mark Rutland, Shuah Khan, linux-kselftest
On Wed, 21 Aug 2024 21:54:42 -0600
Shuah Khan <skhan@linuxfoundation.org> wrote:
> On 8/21/24 13:09, Steven Rostedt wrote:
> > From: Steven Rostedt <rostedt@goodmis.org>
> >
> > Masami reported a bug when running function graph tracing then the
> > function profiler. The following commands would cause a kernel crash:
> >
> > # cd /sys/kernel/tracing/
> > # echo function_graph > current_tracer
> > # echo 1 > function_profile_enabled
> >
> > In that order. Create a test to test this two to make sure this does not
> > come back as a regression.
> >
> > Link: https://lore.kernel.org/172398528350.293426.8347220120333730248.stgit@devnote2
> >
> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> > ---
> > .../ftrace/test.d/ftrace/fgraph-profiler.tc | 30 +++++++++++++++++++
> > 1 file changed, 30 insertions(+)
> > create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
> >
> > diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
> > new file mode 100644
> > index 000000000000..62d44a1395da
> > --- /dev/null
> > +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
> > @@ -0,0 +1,30 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0
> > +# description: ftrace - function profiler with function graph tracing
> > +# requires: function_profile_enabled set_ftrace_filter function_graph:tracer
> > +
> > +# The function graph tracer can now be run along side of the function
> > +# profiler. But there was a bug that caused the combination of the two
> > +# to crash. It also required the function graph tracer to be started
> > +# first.
> > +#
> > +# This test triggers that bug
> > +#
> > +# We need function_graph and profiling to to run this test
> > +
> > +fail() { # mesg
> > + echo $1
> > + exit_fail
> > +}
> > +
> > +echo "Enabling function graph tracer:"
> > +echo function_graph > current_tracer
> > +echo "enable profiler"
> > +
> > +# Older kernels do not allow function_profile to be enabled with
> > +# function graph tracer. If the below fails, mark it as unsupported
> > +echo 1 > function_profile_enabled || exit_unsupported
> > +
> > +sleep 1
>
> Any specific reason for this sleep 1 - can you add a comment on top?
We add sleep 1 in several locations of the ftrace selftests to let the
tracing run for a bit just to see if it triggers anything. Otherwise the
clean up can happen before anything gets traced. Although, it's highly
unlikely in this case, but still.
I could add a comment if you want of just:
# let it run for a bit
sleep 1
> > +
> > +exit 0
>
> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
>
> Let me know if you would like v2 for this to be taken through my tree.
I'll make a v2 if you want me to.
-- Steve
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler
2024-08-21 19:09 [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler Steven Rostedt
2024-08-22 3:54 ` Shuah Khan
@ 2024-08-25 15:14 ` Masami Hiramatsu
1 sibling, 0 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2024-08-25 15:14 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
Mark Rutland, Shuah Khan, Shuah Khan, linux-kselftest
On Wed, 21 Aug 2024 15:09:03 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> Masami reported a bug when running function graph tracing then the
> function profiler. The following commands would cause a kernel crash:
>
> # cd /sys/kernel/tracing/
> # echo function_graph > current_tracer
> # echo 1 > function_profile_enabled
>
> In that order. Create a test to test this two to make sure this does not
> come back as a regression.
>
> Link: https://lore.kernel.org/172398528350.293426.8347220120333730248.stgit@devnote2
This looks good to me, but note that this depends on the above fix, unless
that, this may crash the kernel. I think the above fix should be merged in
v6.11-rcX so this may be safe for released kernel.
Thanks,
>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---
> .../ftrace/test.d/ftrace/fgraph-profiler.tc | 30 +++++++++++++++++++
> 1 file changed, 30 insertions(+)
> create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
>
> diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
> new file mode 100644
> index 000000000000..62d44a1395da
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
> @@ -0,0 +1,30 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: ftrace - function profiler with function graph tracing
> +# requires: function_profile_enabled set_ftrace_filter function_graph:tracer
> +
> +# The function graph tracer can now be run along side of the function
> +# profiler. But there was a bug that caused the combination of the two
> +# to crash. It also required the function graph tracer to be started
> +# first.
> +#
> +# This test triggers that bug
> +#
> +# We need function_graph and profiling to to run this test
> +
> +fail() { # mesg
> + echo $1
> + exit_fail
> +}
> +
> +echo "Enabling function graph tracer:"
> +echo function_graph > current_tracer
> +echo "enable profiler"
> +
> +# Older kernels do not allow function_profile to be enabled with
> +# function graph tracer. If the below fails, mark it as unsupported
> +echo 1 > function_profile_enabled || exit_unsupported
> +
> +sleep 1
> +
> +exit 0
> --
> 2.43.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler
2024-08-22 13:19 ` Steven Rostedt
@ 2024-08-26 13:53 ` Shuah Khan
0 siblings, 0 replies; 5+ messages in thread
From: Shuah Khan @ 2024-08-26 13:53 UTC (permalink / raw)
To: Steven Rostedt
Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Mathieu Desnoyers,
Mark Rutland, Shuah Khan, linux-kselftest, Shuah Khan
On 8/22/24 07:19, Steven Rostedt wrote:
> On Wed, 21 Aug 2024 21:54:42 -0600
> Shuah Khan <skhan@linuxfoundation.org> wrote:
>
>> On 8/21/24 13:09, Steven Rostedt wrote:
>>> From: Steven Rostedt <rostedt@goodmis.org>
>>>
>>> Masami reported a bug when running function graph tracing then the
>>> function profiler. The following commands would cause a kernel crash:
>>>
>>> # cd /sys/kernel/tracing/
>>> # echo function_graph > current_tracer
>>> # echo 1 > function_profile_enabled
>>>
>>> In that order. Create a test to test this two to make sure this does not
>>> come back as a regression.
>>>
>>> Link: https://lore.kernel.org/172398528350.293426.8347220120333730248.stgit@devnote2
>>>
>>> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
>>> ---
>>> .../ftrace/test.d/ftrace/fgraph-profiler.tc | 30 +++++++++++++++++++
>>> 1 file changed, 30 insertions(+)
>>> create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
>>>
>>> diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
>>> new file mode 100644
>>> index 000000000000..62d44a1395da
>>> --- /dev/null
>>> +++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-profiler.tc
>>> @@ -0,0 +1,30 @@
>>> +#!/bin/sh
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +# description: ftrace - function profiler with function graph tracing
>>> +# requires: function_profile_enabled set_ftrace_filter function_graph:tracer
>>> +
>>> +# The function graph tracer can now be run along side of the function
>>> +# profiler. But there was a bug that caused the combination of the two
>>> +# to crash. It also required the function graph tracer to be started
>>> +# first.
>>> +#
>>> +# This test triggers that bug
>>> +#
>>> +# We need function_graph and profiling to to run this test
>>> +
>>> +fail() { # mesg
>>> + echo $1
>>> + exit_fail
>>> +}
>>> +
>>> +echo "Enabling function graph tracer:"
>>> +echo function_graph > current_tracer
>>> +echo "enable profiler"
>>> +
>>> +# Older kernels do not allow function_profile to be enabled with
>>> +# function graph tracer. If the below fails, mark it as unsupported
>>> +echo 1 > function_profile_enabled || exit_unsupported
>>> +
>>> +sleep 1
>>
>> Any specific reason for this sleep 1 - can you add a comment on top?
>
> We add sleep 1 in several locations of the ftrace selftests to let the
> tracing run for a bit just to see if it triggers anything. Otherwise the
> clean up can happen before anything gets traced. Although, it's highly
> unlikely in this case, but still.
>
> I could add a comment if you want of just:
>
> # let it run for a bit
> sleep 1
>
>
>>> +
>>> +exit 0
>>
>> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
>>
>> Let me know if you would like v2 for this to be taken through my tree.
>
> I'll make a v2 if you want me to.
No need for a v2
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-26 13:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21 19:09 [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler Steven Rostedt
2024-08-22 3:54 ` Shuah Khan
2024-08-22 13:19 ` Steven Rostedt
2024-08-26 13:53 ` Shuah Khan
2024-08-25 15:14 ` Masami Hiramatsu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).