mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/ftrace: Add debugfs requirement suffix
@ 2026-10-25  7:29 Jaewon Jung
  2026-10-26  8:52 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Jaewon Jung @ 2026-10-25  7:29 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Shuah Khan
  Cc: linux-kernel, linux-trace-kernel, linux-kselftest

Add a :debugfs requirement suffix to check interfaces under debugfs.
Use it in the kprobe optimization test to report unsupported instead
of failed when debugfs is unavailable.

Tested on x86_64 with QEMU:
- debugfs not mounted: UNSUPPORTED
- debugfs mounted: PASS

Signed-off-by: Jaewon Jung <jaewon8868@gmail.com>
---
 tools/testing/selftests/ftrace/test.d/functions        | 10 ++++++++++
 .../selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc |  4 ++--
 tools/testing/selftests/ftrace/test.d/template         |  1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index 826141e299e5..3cf8ac5fb4d4 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -145,6 +145,7 @@ check_requires() { # Check required files and tracers
 	p=${i%:program}
         r=${i%:README}
         t=${i%:tracer}
+	d=${i%:debugfs}
 	if [ "$p" != "$i" ]; then
 	    if ! which "$p" ; then
                 echo "Required program $p is not found."
@@ -166,6 +167,15 @@ check_requires() { # Check required files and tracers
                 echo "Required feature pattern \"$r\" is not in README."
                 exit_unsupported
             fi
+	elif [ "$d" != "$i" ]; then
+	    DEBUGFS_DIR=$(awk '$3 == "debugfs" { print $2; exit }' /proc/mounts)
+	    if [ -z "$DEBUGFS_DIR" ]; then
+		echo "Required filesystem debugfs is not mounted."
+		exit_unsupported
+	    elif [ ! -e "$DEBUGFS_DIR/$d" ]; then
+		echo "Required debugfs interface $d doesn't exist."
+		exit_unsupported
+	    fi
         elif [ ! -e "$i" ]; then
             echo "Required feature interface $i doesn't exist."
             exit_unsupported
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc
index 9f5d99328086..25f7192f887b 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc
@@ -2,7 +2,7 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (C) 2023 Akanksha J N, IBM corporation
 # description: Register/unregister optimized probe
-# requires: kprobe_events
+# requires: kprobe_events kprobes/list:debugfs
 
 case `uname -m` in
 x86_64)
@@ -22,7 +22,7 @@ for i in `seq 0 255`; do
         echo  "p:testprobe $FUNCTION_FORK+${i}" > kprobe_events || continue
         echo 1 > events/kprobes/enable || continue
         (echo "forked")
-	PROBE=$(grep $FUNCTION_FORK /sys/kernel/debug/kprobes/list)
+	PROBE=$(grep $FUNCTION_FORK "$DEBUGFS_DIR/kprobes/list")
         echo 0 > events/kprobes/enable
         echo > kprobe_events
 	if echo $PROBE | grep -q OPTIMIZED; then
diff --git a/tools/testing/selftests/ftrace/test.d/template b/tools/testing/selftests/ftrace/test.d/template
index 2cd8947edf72..d4a2500498f6 100644
--- a/tools/testing/selftests/ftrace/test.d/template
+++ b/tools/testing/selftests/ftrace/test.d/template
@@ -5,6 +5,7 @@
 # The required tracer needs :tracer suffix, e.g. function:tracer
 # The required README string needs :README suffix, e.g. "x8/16/32/64":README
 # and the README string is treated as a fixed-string instead of regexp pattern.
+# The required debugfs interface needs :debugfs suffix, e.g. kprobes/list:debugfs
 # you have to add ".tc" extention for your testcase file
 # Note that all tests are run with "errexit" option.
 
-- 
2.43.0


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

* Re: [PATCH] selftests/ftrace: Add debugfs requirement suffix
  2026-10-25  7:29 [PATCH] selftests/ftrace: Add debugfs requirement suffix Jaewon Jung
@ 2026-10-26  8:52 ` Masami Hiramatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2026-10-26  8:52 UTC (permalink / raw)
  To: Jaewon Jung
  Cc: Steven Rostedt, Mathieu Desnoyers, Shuah Khan, linux-kernel,
	linux-trace-kernel, linux-kselftest

On Sun, 25 Oct 2026 16:29:41 +0900, Jaewon Jung <jaewon8868@gmail.com> wrote:
> Add a :debugfs requirement suffix to check interfaces under debugfs.
> Use it in the kprobe optimization test to report unsupported instead
> of failed when debugfs is unavailable.
> 
> Tested on x86_64 with QEMU:
> - debugfs not mounted: UNSUPPORTED
> - debugfs mounted: PASS
> 
> Signed-off-by: Jaewon Jung <jaewon8868@gmail.com>

Good improvement! Let me pick it.

Thanks!

> ---
>  tools/testing/selftests/ftrace/test.d/functions        | 10 ++++++++++
>  .../selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc |  4 ++--
>  tools/testing/selftests/ftrace/test.d/template         |  1 +
>  3 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
> index 826141e299e5..3cf8ac5fb4d4 100644
> --- a/tools/testing/selftests/ftrace/test.d/functions
> +++ b/tools/testing/selftests/ftrace/test.d/functions
> @@ -145,6 +145,7 @@ check_requires() { # Check required files and tracers
>  	p=${i%:program}
>          r=${i%:README}
>          t=${i%:tracer}
> +	d=${i%:debugfs}
>  	if [ "$p" != "$i" ]; then
>  	    if ! which "$p" ; then
>                  echo "Required program $p is not found."
> @@ -166,6 +167,15 @@ check_requires() { # Check required files and tracers
>                  echo "Required feature pattern \"$r\" is not in README."
>                  exit_unsupported
>              fi
> +	elif [ "$d" != "$i" ]; then
> +	    DEBUGFS_DIR=$(awk '$3 == "debugfs" { print $2; exit }' /proc/mounts)
> +	    if [ -z "$DEBUGFS_DIR" ]; then
> +		echo "Required filesystem debugfs is not mounted."
> +		exit_unsupported
> +	    elif [ ! -e "$DEBUGFS_DIR/$d" ]; then
> +		echo "Required debugfs interface $d doesn't exist."
> +		exit_unsupported
> +	    fi
>          elif [ ! -e "$i" ]; then
>              echo "Required feature interface $i doesn't exist."
>              exit_unsupported
> diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc
> index 9f5d99328086..25f7192f887b 100644
> --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc
> +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_opt_types.tc
> @@ -2,7 +2,7 @@
>  # SPDX-License-Identifier: GPL-2.0-or-later
>  # Copyright (C) 2023 Akanksha J N, IBM corporation
>  # description: Register/unregister optimized probe
> -# requires: kprobe_events
> +# requires: kprobe_events kprobes/list:debugfs
>  
>  case `uname -m` in
>  x86_64)
> @@ -22,7 +22,7 @@ for i in `seq 0 255`; do
>          echo  "p:testprobe $FUNCTION_FORK+${i}" > kprobe_events || continue
>          echo 1 > events/kprobes/enable || continue
>          (echo "forked")
> -	PROBE=$(grep $FUNCTION_FORK /sys/kernel/debug/kprobes/list)
> +	PROBE=$(grep $FUNCTION_FORK "$DEBUGFS_DIR/kprobes/list")
>          echo 0 > events/kprobes/enable
>          echo > kprobe_events
>  	if echo $PROBE | grep -q OPTIMIZED; then
> diff --git a/tools/testing/selftests/ftrace/test.d/template b/tools/testing/selftests/ftrace/test.d/template
> index 2cd8947edf72..d4a2500498f6 100644
> --- a/tools/testing/selftests/ftrace/test.d/template
> +++ b/tools/testing/selftests/ftrace/test.d/template
> @@ -5,6 +5,7 @@
>  # The required tracer needs :tracer suffix, e.g. function:tracer
>  # The required README string needs :README suffix, e.g. "x8/16/32/64":README
>  # and the README string is treated as a fixed-string instead of regexp pattern.
> +# The required debugfs interface needs :debugfs suffix, e.g. kprobes/list:debugfs
>  # you have to add ".tc" extention for your testcase file
>  # Note that all tests are run with "errexit" option.
>  
> -- 
> 2.43.0
> 
>

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

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

end of thread, other threads:[~2026-10-26  8:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25  7:29 [PATCH] selftests/ftrace: Add debugfs requirement suffix Jaewon Jung
2026-10-26  8:52 ` Masami Hiramatsu

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®