public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] selftests/ftrace: Add test to exercize function tracer across cpu hotplug
@ 2023-12-13 11:38 Naveen N Rao
  2023-12-13 12:54 ` Masami Hiramatsu
  0 siblings, 1 reply; 4+ messages in thread
From: Naveen N Rao @ 2023-12-13 11:38 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>
---
v2: Add a check for next available online cpu, as suggested by Masami.

 .../ftrace/test.d/ftrace/func_hotplug.tc      | 42 +++++++++++++++++++
 1 file changed, 42 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..ccfbfde3d942
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
@@ -0,0 +1,42 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# 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 cannot test cpu hotplug in UP environment"
+  exit_unresolved
+fi
+
+# Find online cpu
+for i in /sys/devices/system/cpu/cpu[1-9]*; do
+	if [ -f $i/online ] && [ "$(cat $i/online)" = "1" ]; then
+		cpu=$i
+		break
+	fi
+done
+
+if [ -z "$cpu" ]; then
+	echo "We cannot test cpu hotplug with a single cpu online"
+	exit_unresolved
+fi
+
+echo 0 > tracing_on
+echo > trace
+
+: "Set $(basename $cpu) offline/online with function tracer enabled"
+echo function > current_tracer
+echo 1 > tracing_on
+(echo 0 > $cpu/online)
+(echo "forked"; sleep 1)
+(echo 1 > $cpu/online)
+echo 0 > tracing_on
+echo nop > current_tracer

base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86
-- 
2.43.0


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

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

On Wed, 13 Dec 2023 17:08:02 +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").
> 

Looks good to me.

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

Thank you,

> Signed-off-by: Naveen N Rao <naveen@kernel.org>
> ---
> v2: Add a check for next available online cpu, as suggested by Masami.
> 
>  .../ftrace/test.d/ftrace/func_hotplug.tc      | 42 +++++++++++++++++++
>  1 file changed, 42 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..ccfbfde3d942
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc
> @@ -0,0 +1,42 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# 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 cannot test cpu hotplug in UP environment"
> +  exit_unresolved
> +fi
> +
> +# Find online cpu
> +for i in /sys/devices/system/cpu/cpu[1-9]*; do
> +	if [ -f $i/online ] && [ "$(cat $i/online)" = "1" ]; then
> +		cpu=$i
> +		break
> +	fi
> +done
> +
> +if [ -z "$cpu" ]; then
> +	echo "We cannot test cpu hotplug with a single cpu online"
> +	exit_unresolved
> +fi
> +
> +echo 0 > tracing_on
> +echo > trace
> +
> +: "Set $(basename $cpu) offline/online with function tracer enabled"
> +echo function > current_tracer
> +echo 1 > tracing_on
> +(echo 0 > $cpu/online)
> +(echo "forked"; sleep 1)
> +(echo 1 > $cpu/online)
> +echo 0 > tracing_on
> +echo nop > current_tracer
> 
> base-commit: b85ea95d086471afb4ad062012a4d73cd328fa86
> -- 
> 2.43.0
> 


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

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

* Re: [PATCH v2] selftests/ftrace: Add test to exercize function tracer across cpu hotplug
  2023-12-13 12:54 ` Masami Hiramatsu
@ 2023-12-13 15:06   ` Steven Rostedt
  2024-01-12  7:35     ` Naveen N Rao
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2023-12-13 15:06 UTC (permalink / raw)
  To: Masami Hiramatsu (Google)
  Cc: Naveen N Rao, linux-kselftest, linux-kernel, Shuah Khan,
	Michael Ellerman

On Wed, 13 Dec 2023 21:54:50 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Wed, 13 Dec 2023 17:08:02 +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").
> >   
> 
> Looks good to me.
> 
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Thank you,
> 

Thanks Naveen and Masami!

Shuah, can you take this through your tree?

-- Steve

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

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

Hi Shuah,

On Wed, Dec 13, 2023 at 10:06:29AM -0500, Steven Rostedt wrote:
> On Wed, 13 Dec 2023 21:54:50 +0900
> Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> 
> > On Wed, 13 Dec 2023 17:08:02 +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").
> > >   
> > 
> > Looks good to me.
> > 
> > Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > 
> > Thank you,
> > 
> 
> Thanks Naveen and Masami!
> 
> Shuah, can you take this through your tree?

Can you please pick up this patch?

- Naveen


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

end of thread, other threads:[~2024-01-12  7:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-13 11:38 [PATCH v2] selftests/ftrace: Add test to exercize function tracer across cpu hotplug Naveen N Rao
2023-12-13 12:54 ` Masami Hiramatsu
2023-12-13 15:06   ` Steven Rostedt
2024-01-12  7:35     ` 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