mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/ftrace: Add test to exercize function tracer across cpu hotplug
@ 2023-12-12  8:56 Naveen N Rao
  2023-12-13  0:40 ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Naveen N Rao @ 2023-12-12  8:56 UTC (permalink / raw)
  To: linux-kselftest, linux-kernel
  Cc: Steven Rostedt, Masami Hiramatsu, Shuah Khan, Michael Ellerman

Add a test to exercize cpu hotplug with the function tracer active to
ensure that sensitive functions in idle path are excluded from being
traced. This helps catch issues such as the one fixed by commit
4b3338aaa74d ("powerpc/ftrace: Fix stack teardown in ftrace_no_trace").

Signed-off-by: Naveen N Rao <naveen@kernel.org>
---
 .../ftrace/test.d/ftrace/func_hotplug.tc      | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc

diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
new file mode 100644
index 000000000000..49731a2b5c23
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
@@ -0,0 +1,30 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: ftrace - function trace across cpu hotplug
+# requires: function:tracer
+
+if ! which nproc ; then
+  nproc() {
+    ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l
+  }
+fi
+
+NP=`nproc`
+
+if [ $NP -eq 1 ] ;then
+  echo "We can not test cpu hotplug in UP environment"
+  exit_unresolved
+fi
+
+echo 0 > tracing_on
+echo > trace
+: "Set CPU1 offline/online with function tracer enabled"
+echo function > current_tracer
+echo 1 > tracing_on
+(echo 0 > /sys/devices/system/cpu/cpu1/online)
+(echo "forked"; sleep 1)
+(echo 1 > /sys/devices/system/cpu/cpu1/online)
+echo 0 > tracing_on
+
+: "Check CPU1 events are recorded"
+grep -q -e "\[001\]" trace

base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/ftrace: Add test to exercize function tracer across cpu hotplug
  2023-12-12  8:56 [PATCH] selftests/ftrace: Add test to exercize function tracer across cpu hotplug Naveen N Rao
@ 2023-12-13  0:40 ` Masami Hiramatsu
  2023-12-13 11:30   ` Naveen N Rao
  0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2023-12-13  0:40 UTC (permalink / raw)
  To: Naveen N Rao
  Cc: linux-kselftest, linux-kernel, Steven Rostedt, Masami Hiramatsu,
	Shuah Khan, Michael Ellerman

Hi Naveen,

On Tue, 12 Dec 2023 14:26:07 +0530
Naveen N Rao <naveen@kernel.org> wrote:

> Add a test to exercize cpu hotplug with the function tracer active to
> ensure that sensitive functions in idle path are excluded from being
> traced. This helps catch issues such as the one fixed by commit
> 4b3338aaa74d ("powerpc/ftrace: Fix stack teardown in ftrace_no_trace").
> 
> Signed-off-by: Naveen N Rao <naveen@kernel.org>
> ---
>  .../ftrace/test.d/ftrace/func_hotplug.tc      | 30 +++++++++++++++++++
>  1 file changed, 30 insertions(+)
>  create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
> 
> diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
> new file mode 100644
> index 000000000000..49731a2b5c23
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
> @@ -0,0 +1,30 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: ftrace - function trace across cpu hotplug
> +# requires: function:tracer
> +
> +if ! which nproc ; then
> +  nproc() {
> +    ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l
> +  }
> +fi
> +
> +NP=`nproc`
> +
> +if [ $NP -eq 1 ] ;then
> +  echo "We can not test cpu hotplug in UP environment"
> +  exit_unresolved
> +fi

This looks good, but can you find the 2nd online CPU before
this test?
I mean, there is a case that cpu1 is already offlined and others
like cpu2 is onlined. So we need to use the 2nd online cpu.

Thank you,

> +
> +echo 0 > tracing_on
> +echo > trace
> +: "Set CPU1 offline/online with function tracer enabled"
> +echo function > current_tracer
> +echo 1 > tracing_on
> +(echo 0 > /sys/devices/system/cpu/cpu1/online)
> +(echo "forked"; sleep 1)
> +(echo 1 > /sys/devices/system/cpu/cpu1/online)
> +echo 0 > tracing_on
> +
> +: "Check CPU1 events are recorded"
> +grep -q -e "\[001\]" trace
> 
> base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86
> -- 
> 2.43.0
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selftests/ftrace: Add test to exercize function tracer across cpu hotplug
  2023-12-13  0:40 ` Masami Hiramatsu
@ 2023-12-13 11:30   ` Naveen N Rao
  0 siblings, 0 replies; 3+ messages in thread
From: Naveen N Rao @ 2023-12-13 11:30 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: linux-kselftest, linux-kernel, Steven Rostedt, Shuah Khan,
	Michael Ellerman

On Wed, Dec 13, 2023 at 09:40:38AM +0900, Masami Hiramatsu wrote:
> Hi Naveen,
> 
> On Tue, 12 Dec 2023 14:26:07 +0530
> Naveen N Rao <naveen@kernel.org> wrote:
> 
> > Add a test to exercize cpu hotplug with the function tracer active to
> > ensure that sensitive functions in idle path are excluded from being
> > traced. This helps catch issues such as the one fixed by commit
> > 4b3338aaa74d ("powerpc/ftrace: Fix stack teardown in ftrace_no_trace").
> > 
> > Signed-off-by: Naveen N Rao <naveen@kernel.org>
> > ---
> >  .../ftrace/test.d/ftrace/func_hotplug.tc      | 30 +++++++++++++++++++
> >  1 file changed, 30 insertions(+)
> >  create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
> > 
> > diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
> > new file mode 100644
> > index 000000000000..49731a2b5c23
> > --- /dev/null
> > +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
> > @@ -0,0 +1,30 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0
> > +# description: ftrace - function trace across cpu hotplug
> > +# requires: function:tracer
> > +
> > +if ! which nproc ; then
> > +  nproc() {
> > +    ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l
> > +  }
> > +fi
> > +
> > +NP=`nproc`
> > +
> > +if [ $NP -eq 1 ] ;then
> > +  echo "We can not test cpu hotplug in UP environment"
> > +  exit_unresolved
> > +fi
> 
> This looks good, but can you find the 2nd online CPU before
> this test?
> I mean, there is a case that cpu1 is already offlined and others
> like cpu2 is onlined. So we need to use the 2nd online cpu.

Good point, thanks. I will send a v2.

- Naveen


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-13 11:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12  8:56 [PATCH] selftests/ftrace: Add test to exercize function tracer across cpu hotplug Naveen N Rao
2023-12-13  0:40 ` Masami Hiramatsu
2023-12-13 11:30   ` Naveen N Rao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®