common/tracing: use /sys/kernel/tracing at first
PATCH 1/1 common/tracing: use /sys/kernel/tracing at first
To avoid the dependence of debugfs, tracefs is mounted on another place -- /sys/kernel/tracing now. But for the compatibility, the /sys/kernel/debug/tracing is still there. So change _require_ftrace helper, try to use the new /sys/kernel/tracing path at first, or fallback to the old one if it's not supported.
xfs/499 uses ftrace, so call _require_ftrace in it.
--- common/tracing | 13 +++++++++---- tests/xfs/499 | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-)
common/tracing +9 -4
@@ -4,11 +4,16 @@ # # Routines for dealing with ftrace (or any other tracing). -FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances/" - _require_ftrace() { - test -d "$FTRACE_INSTANCES_DIR" || \ - _notrun "kernel does not support ftrace" + if [ -d /sys/kernel/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/tracing/instances" + elif [ -d /sys/kernel/debug/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/debug/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances" + else + _notrun "The ftrace is not supported, or tracefs is not mounted" + fi } _ftrace_cleanup() {
tests/xfs/499 +3 -3
@@ -14,18 +14,18 @@ _begin_fstest auto quick _register_cleanup "_cleanup" BUS # Import common functions. +. ./common/tracing # real QA test starts here _supported_fs xfs +_require_ftrace _require_command "$CC_PROG" "cc" cprog=$tmp.ftrace.c oprog=$tmp.ftrace sedprog=$tmp.ftrace.sed -ftrace_dir=$DEBUGFS_MNT/tracing/events/xfs - -test -d $ftrace_dir || _notrun "ftrace not enabled" +ftrace_dir=$FTRACE_ROOT/events/xfs # The second argument to __print_symbolic is stringified in the tracepoint's # fmt file, so we look for "{ NUM, STRING }" and try to separate each of them
Signature · 1 line
2.44.0
Quoted 20 lines · Zorro Lang
To avoid the dependence of debugfs, tracefs is mounted on another place --
/sys/kernel/tracingnow. But for the compatibility, the/sys/kernel/debug/tracingis still there. So change_require_ftracehelper, try to use the new/sys/kernel/tracingpath at first, or fallback to the old one if it's not supported.xfs/499 uses ftrace, so call
_require_ftracein it.Signed-off-by Zorro Lang <[email protected]>--- common/tracing | 13 +++++++++---- tests/xfs/499 | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-)common/tracing +0
-0@@ -4,11 +4,16 @@ #
common/tracing line 10
Quoted 10 lines
common/tracing +3
-4# Routines for dealing with ftrace (or any other tracing). -FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances/" - _require_ftrace() { - test -d "$FTRACE_INSTANCES_DIR" || \ - _notrun "kernel does not support ftrace" + if [ -d /sys/kernel/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/tracing/instances"
To answer my own question, this new path has been in Debian since at least 2021.
Quoted 14 lines
common/tracing +6
-0+ elif [ -d /sys/kernel/debug/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/debug/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances" + else + _notrun "The ftrace is not supported, or tracefs is not mounted" + fi } _ftrace_cleanup() {tests/xfs/499 +0
-0
tests/xfs/499 _begin_fstest auto quick · line 17
Quoted 4 lines
tests/xfs/499 +1
-0@@ -14,18 +14,18 @@ _begin_fstest auto quick _register_cleanup "_cleanup" BUS # Import common functions. +. ./common/tracing
You could probably get rid of the "Import common functions" comment.
This looks good!
--D
Quoted 21 lines
tests/xfs/499 +2
-3# real QA test starts here _supported_fs xfs +_require_ftrace _require_command "$CC_PROG" "cc" cprog=$tmp.ftrace.c oprog=$tmp.ftrace sedprog=$tmp.ftrace.sed -ftrace_dir=$DEBUGFS_MNT/tracing/events/xfs - -test -d $ftrace_dir || _notrun "ftrace not enabled" +ftrace_dir=$FTRACE_ROOT/events/xfs # The second argument to __print_symbolic is stringified in the tracepoint's # fmt file, so we look for "{ NUM, STRING }" and try to separate each of themSignature · 1 line
2.44.0
Quoted 23 lines · Darrick J. Wong
Quoted 22 lines · Zorro Lang
To avoid the dependence of debugfs, tracefs is mounted on another place --
/sys/kernel/tracingnow. But for the compatibility, the/sys/kernel/debug/tracingis still there. So change_require_ftracehelper, try to use the new/sys/kernel/tracingpath at first, or fallback to the old one if it's not supported.xfs/499 uses ftrace, so call
_require_ftracein it.Signed-off-by Zorro Lang <[email protected]>--- common/tracing | 13 +++++++++---- tests/xfs/499 | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-)common/tracing +0
-0@@ -4,11 +4,16 @@ # # Routines for dealing with ftrace (or any other tracing).
Quoted 11 lines
common/tracing line 10
Quoted 8 lines
common/tracing +3
-4-FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances/" - _require_ftrace() { - test -d "$FTRACE_INSTANCES_DIR" || \ - _notrun "kernel does not support ftrace" + if [ -d /sys/kernel/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/tracing/instances"To answer my own question, this new path has been in Debian since at least 2021.
Oh, I thought the /sys/kernel/tracing was created in linux v4.1 :
cc31004a4aa7 ("tracefs: Add directory /sys/kernel/tracing")
But might be used in different distro widely later.
Quoted 17 lines
Quoted 17 lines
common/tracing +6
-0+ elif [ -d /sys/kernel/debug/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/debug/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances" + else + _notrun "The ftrace is not supported, or tracefs is not mounted" + fi } _ftrace_cleanup() {tests/xfs/499 +0
-0@@ -14,18 +14,18 @@ _begin_fstest auto quick _register_cleanup "_cleanup" BUS
Quoted 4 lines
tests/xfs/499 _begin_fstest auto quick · line 17
Quoted 2 lines
tests/xfs/499 +1
-0# Import common functions. +. ./common/tracingYou could probably get rid of the "Import common functions" comment.
Sure, will change that when I merge it.
Quoted 3 lines
This looks good!
Reviewed-by Darrick J. Wong <[email protected]>
Thanks,
Zorro
Quoted 25 lines
--D
Quoted 21 lines
tests/xfs/499 +2
-3# real QA test starts here _supported_fs xfs +_require_ftrace _require_command "$CC_PROG" "cc" cprog=$tmp.ftrace.c oprog=$tmp.ftrace sedprog=$tmp.ftrace.sed -ftrace_dir=$DEBUGFS_MNT/tracing/events/xfs - -test -d $ftrace_dir || _notrun "ftrace not enabled" +ftrace_dir=$FTRACE_ROOT/events/xfs # The second argument to __print_symbolic is stringified in the tracepoint's # fmt file, so we look for "{ NUM, STRING }" and try to separate each of themSignature · 1 line
2.44.0
Quoted 36 lines · Zorro Lang
Quoted 23 lines · Darrick J. Wong
Quoted 22 lines · Zorro Lang
To avoid the dependence of debugfs, tracefs is mounted on another place --
/sys/kernel/tracingnow. But for the compatibility, the/sys/kernel/debug/tracingis still there. So change_require_ftracehelper, try to use the new/sys/kernel/tracingpath at first, or fallback to the old one if it's not supported.xfs/499 uses ftrace, so call
_require_ftracein it.Signed-off-by Zorro Lang <[email protected]>--- common/tracing | 13 +++++++++---- tests/xfs/499 | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-)common/tracing +0
-0@@ -4,11 +4,16 @@ # # Routines for dealing with ftrace (or any other tracing).Quoted 11 lines
common/tracing line 10
Quoted 8 lines
common/tracing +3
-4-FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances/" - _require_ftrace() { - test -d "$FTRACE_INSTANCES_DIR" || \ - _notrun "kernel does not support ftrace" + if [ -d /sys/kernel/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/tracing/instances"To answer my own question, this new path has been in Debian since at least 2021.
Quoted 4 lines
Oh, I thought the
/sys/kernel/tracingwas created in linux v4.1 :
cc31004a4aa7("tracefs: Add directory/sys/kernel/tracing")But might be used in different distro widely later.
That creates an empty /sys/kernel/tracing directory, but userspace still has to mount something to it, hence /lib/systemd/system/sys-kernel-tracing.mount.
--D
Quoted 57 lines
Quoted 17 lines
Quoted 17 lines
common/tracing +6
-0+ elif [ -d /sys/kernel/debug/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/debug/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances" + else + _notrun "The ftrace is not supported, or tracefs is not mounted" + fi } _ftrace_cleanup() {tests/xfs/499 +0
-0@@ -14,18 +14,18 @@ _begin_fstest auto quick _register_cleanup "_cleanup" BUSQuoted 4 lines
tests/xfs/499 _begin_fstest auto quick · line 17
Quoted 2 lines
tests/xfs/499 +1
-0# Import common functions. +. ./common/tracingYou could probably get rid of the "Import common functions" comment.
Sure, will change that when I merge it.
Quoted 3 lines
This looks good!
Reviewed-by Darrick J. Wong <[email protected]>Thanks,
ZorroQuoted 25 lines
--D
Quoted 21 lines
tests/xfs/499 +2
-3# real QA test starts here _supported_fs xfs +_require_ftrace _require_command "$CC_PROG" "cc" cprog=$tmp.ftrace.c oprog=$tmp.ftrace sedprog=$tmp.ftrace.sed -ftrace_dir=$DEBUGFS_MNT/tracing/events/xfs - -test -d $ftrace_dir || _notrun "ftrace not enabled" +ftrace_dir=$FTRACE_ROOT/events/xfs # The second argument to __print_symbolic is stringified in the tracepoint's # fmt file, so we look for "{ NUM, STRING }" and try to separate each of themSignature · 1 line
2.44.0
Quoted 36 lines · Zorro Lang
Quoted 23 lines · Darrick J. Wong
Quoted 22 lines · Zorro Lang
To avoid the dependence of debugfs, tracefs is mounted on another place --
/sys/kernel/tracingnow. But for the compatibility, the/sys/kernel/debug/tracingis still there. So change_require_ftracehelper, try to use the new/sys/kernel/tracingpath at first, or fallback to the old one if it's not supported.xfs/499 uses ftrace, so call
_require_ftracein it.Signed-off-by Zorro Lang <[email protected]>--- common/tracing | 13 +++++++++---- tests/xfs/499 | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-)common/tracing +0
-0@@ -4,11 +4,16 @@ # # Routines for dealing with ftrace (or any other tracing).Quoted 11 lines
common/tracing line 10
Quoted 8 lines
common/tracing +3
-4-FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances/" - _require_ftrace() { - test -d "$FTRACE_INSTANCES_DIR" || \ - _notrun "kernel does not support ftrace" + if [ -d /sys/kernel/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/tracing/instances"To answer my own question, this new path has been in Debian since at least 2021.
Quoted 4 lines
Oh, I thought the
/sys/kernel/tracingwas created in linux v4.1 :
cc31004a4aa7("tracefs: Add directory/sys/kernel/tracing")But might be used in different distro widely later.
Yeah, it showed up in kernel v4.1, but systemd only added a .mount file for it a few years ago.
--D
Quoted 58 lines
Quoted 17 lines
Quoted 17 lines
common/tracing +6
-0+ elif [ -d /sys/kernel/debug/tracing/instances/ ];then + FTRACE_ROOT="/sys/kernel/debug/tracing" + FTRACE_INSTANCES_DIR="/sys/kernel/debug/tracing/instances" + else + _notrun "The ftrace is not supported, or tracefs is not mounted" + fi } _ftrace_cleanup() {tests/xfs/499 +0
-0@@ -14,18 +14,18 @@ _begin_fstest auto quick _register_cleanup "_cleanup" BUSQuoted 4 lines
tests/xfs/499 _begin_fstest auto quick · line 17
Quoted 2 lines
tests/xfs/499 +1
-0# Import common functions. +. ./common/tracingYou could probably get rid of the "Import common functions" comment.
Sure, will change that when I merge it.
Quoted 3 lines
This looks good!
Reviewed-by Darrick J. Wong <[email protected]>Thanks,
ZorroQuoted 25 lines
--D
Quoted 21 lines
tests/xfs/499 +2
-3# real QA test starts here _supported_fs xfs +_require_ftrace _require_command "$CC_PROG" "cc" cprog=$tmp.ftrace.c oprog=$tmp.ftrace sedprog=$tmp.ftrace.sed -ftrace_dir=$DEBUGFS_MNT/tracing/events/xfs - -test -d $ftrace_dir || _notrun "ftrace not enabled" +ftrace_dir=$FTRACE_ROOT/events/xfs # The second argument to __print_symbolic is stringified in the tracepoint's # fmt file, so we look for "{ NUM, STRING }" and try to separate each of themSignature · 1 line
2.44.0