selftests/ftrace: Add test to exercize function tracer across cpu hotplug
PATCH v2 1/1 selftests/ftrace: Add test to exercize function tracer across cpu hotplug
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").
---
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
tools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc new file +42 -0
@@ -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
Signature · 1 line
2.43.0
Quoted 5 lines · On Wed, 13 Dec 2023 17:08:02 +0530 Naveen N Rao <[email protected]> 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 inftrace_no_trace").
Looks good to me.
Thank you,
Quoted 61 lines
Signed-off-by Naveen N Rao <[email protected]>---
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.tctools/testing/selftests/ftrace/test.d/ftrace/func_hotplug.tc new file +42
-0@@ -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_tracerbase-commit:
b85ea95d086471afb4ad062012a4d73cd328fa86Signature · 1 line
2.43.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Steven Rostedt
maintainerQuoted 9 lines · On Wed, 13 Dec 2023 21:54:50 +0900 Masami Hiramatsu (Google)…
Quoted 5 lines · On Wed, 13 Dec 2023 17:08:02 +0530 Naveen N Rao <[email protected]> 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 inftrace_no_trace").
Quoted 6 lines
Looks good to me.
Thank you,
Thanks Naveen and Masami!
Shuah, can you take this through your tree?
-- Steve
Hi Shuah,
Quoted 14 lines · Steven Rostedt
Quoted 11 lines · On Wed, 13 Dec 2023 21:54:50 +0900 Masami Hiramatsu (Google)…
Quoted 5 lines · On Wed, 13 Dec 2023 17:08:02 +0530 Naveen N Rao <[email protected]> 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 inftrace_no_trace").Looks good to me.
Quoted 8 lines
Quoted 4 lines
Thank you,
Thanks Naveen and Masami!
Shuah, can you take this through your tree?
Can you please pick up this patch?
- Naveen