2023-01-30 18:20:00

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 0/9] use canonical ftrace path whenever possible

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

There are many places where this older debugfs path is still used in
code comments, selftests, examples and tools, so let's update them to
avoid confusion.

I've broken up the series as best I could by maintainer or directory,
and I've only sent people the patches that I think they care about to
avoid spamming everyone.

Ross Zwisler (9):
tracing: always use canonical ftrace path
bpf: use canonical ftrace path
selftests/bpf: use canonical ftrace path
perf docs: use canonical ftrace path
tools/power: use canonical ftrace path
selftests: use canonical ftrace path
tools/virtio: use canonical ftrace path
leaking_addresses: also skip canonical ftrace path
tools/kvm_stat: use canonical ftrace path

include/linux/kernel.h | 2 +-
include/linux/tracepoint.h | 4 ++--
include/uapi/linux/bpf.h | 8 ++++----
kernel/trace/Kconfig | 20 +++++++++----------
kernel/trace/kprobe_event_gen_test.c | 2 +-
kernel/trace/ring_buffer.c | 2 +-
kernel/trace/synth_event_gen_test.c | 2 +-
kernel/trace/trace.c | 2 +-
samples/bpf/cpustat_kern.c | 4 ++--
samples/bpf/hbm.c | 4 ++--
samples/bpf/ibumad_kern.c | 4 ++--
samples/bpf/lwt_len_hist.sh | 2 +-
samples/bpf/offwaketime_kern.c | 2 +-
samples/bpf/task_fd_query_user.c | 4 ++--
samples/bpf/test_lwt_bpf.sh | 2 +-
samples/bpf/test_overhead_tp_kern.c | 4 ++--
samples/user_events/example.c | 4 ++--
scripts/leaking_addresses.pl | 1 +
scripts/tracing/draw_functrace.py | 6 +++---
scripts/tracing/ftrace-bisect.sh | 4 ++--
tools/include/uapi/linux/bpf.h | 8 ++++----
tools/kvm/kvm_stat/kvm_stat | 2 +-
tools/lib/api/fs/tracing_path.c | 4 ++--
tools/lib/traceevent/event-parse.c | 8 ++++----
tools/perf/Documentation/perf-list.txt | 2 +-
tools/perf/Documentation/perf-script-perl.txt | 2 +-
.../perf/Documentation/perf-script-python.txt | 4 ++--
tools/power/pm-graph/sleepgraph.py | 4 ++--
.../x86/amd_pstate_tracer/amd_pstate_trace.py | 4 ++--
.../intel_pstate_tracer.py | 10 +++++-----
.../selftests/bpf/get_cgroup_id_user.c | 2 +-
.../bpf/prog_tests/kprobe_multi_test.c | 2 +-
.../bpf/prog_tests/task_fd_query_tp.c | 2 +-
.../bpf/prog_tests/tp_attach_query.c | 2 +-
.../selftests/bpf/prog_tests/trace_printk.c | 2 +-
.../selftests/bpf/prog_tests/trace_vprintk.c | 2 +-
.../selftests/bpf/progs/test_stacktrace_map.c | 2 +-
.../selftests/bpf/progs/test_tracepoint.c | 2 +-
tools/testing/selftests/bpf/test_ftrace.sh | 2 +-
tools/testing/selftests/bpf/test_tunnel.sh | 8 ++++----
tools/testing/selftests/bpf/trace_helpers.c | 4 ++--
.../testing/selftests/user_events/dyn_test.c | 2 +-
.../selftests/user_events/ftrace_test.c | 10 +++++-----
.../testing/selftests/user_events/perf_test.c | 8 ++++----
tools/testing/selftests/vm/protection_keys.c | 4 ++--
tools/tracing/latency/latency-collector.c | 2 +-
tools/virtio/virtio-trace/README | 2 +-
tools/virtio/virtio-trace/trace-agent.c | 2 +-
48 files changed, 96 insertions(+), 95 deletions(-)

--
2.39.1.456.gfc5497dd1b-goog



2023-01-30 18:20:06

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 1/9] tracing: always use canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

Many comments and Kconfig help messages in the tracing code still refer
to this older debugfs path, so let's update them to avoid confusion.

Signed-off-by: Ross Zwisler <[email protected]>
---
include/linux/kernel.h | 2 +-
include/linux/tracepoint.h | 4 ++--
kernel/trace/Kconfig | 20 ++++++++++----------
kernel/trace/kprobe_event_gen_test.c | 2 +-
kernel/trace/ring_buffer.c | 2 +-
kernel/trace/synth_event_gen_test.c | 2 +-
kernel/trace/trace.c | 2 +-
samples/user_events/example.c | 4 ++--
scripts/tracing/draw_functrace.py | 6 +++---
scripts/tracing/ftrace-bisect.sh | 4 ++--
tools/lib/api/fs/tracing_path.c | 4 ++--
tools/lib/traceevent/event-parse.c | 8 ++++----
tools/tracing/latency/latency-collector.c | 2 +-
13 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fe6efb24d151..40bce7495af8 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -297,7 +297,7 @@ bool mac_pton(const char *s, u8 *mac);
*
* Use tracing_on/tracing_off when you want to quickly turn on or off
* tracing. It simply enables or disables the recording of the trace events.
- * This also corresponds to the user space /sys/kernel/debug/tracing/tracing_on
+ * This also corresponds to the user space /sys/kernel/tracing/tracing_on
* file, which gives a means for the kernel and userspace to interact.
* Place a tracing_off() in the kernel where you want tracing to end.
* From user space, examine the trace, and then echo 1 > tracing_on
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 4b33b95eb8be..fa1004fcf810 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -471,7 +471,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
* * This is how the trace record is structured and will
* * be saved into the ring buffer. These are the fields
* * that will be exposed to user-space in
- * * /sys/kernel/debug/tracing/events/<*>/format.
+ * * /sys/kernel/tracing/events/<*>/format.
* *
* * The declared 'local variable' is called '__entry'
* *
@@ -531,7 +531,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
* tracepoint callback (this is used by programmatic plugins and
* can also by used by generic instrumentation like SystemTap), and
* it is also used to expose a structured trace record in
- * /sys/kernel/debug/tracing/events/.
+ * /sys/kernel/tracing/events/.
*
* A set of (un)registration functions can be passed to the variant
* TRACE_EVENT_FN to perform any (un)registration work.
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index e9e95c790b8e..4b85674935d7 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -232,7 +232,7 @@ config DYNAMIC_FTRACE
enabled, and the functions not enabled will not affect
performance of the system.

- See the files in /sys/kernel/debug/tracing:
+ See the files in /sys/kernel/tracing:
available_filter_functions
set_ftrace_filter
set_ftrace_notrace
@@ -292,7 +292,7 @@ config STACK_TRACER
select KALLSYMS
help
This special tracer records the maximum stack footprint of the
- kernel and displays it in /sys/kernel/debug/tracing/stack_trace.
+ kernel and displays it in /sys/kernel/tracing/stack_trace.

This tracer works by hooking into every function call that the
kernel executes, and keeping a maximum stack depth value and
@@ -332,7 +332,7 @@ config IRQSOFF_TRACER
disabled by default and can be runtime (re-)started
via:

- echo 0 > /sys/kernel/debug/tracing/tracing_max_latency
+ echo 0 > /sys/kernel/tracing/tracing_max_latency

(Note that kernel size and overhead increase with this option
enabled. This option and the preempt-off timing option can be
@@ -356,7 +356,7 @@ config PREEMPT_TRACER
disabled by default and can be runtime (re-)started
via:

- echo 0 > /sys/kernel/debug/tracing/tracing_max_latency
+ echo 0 > /sys/kernel/tracing/tracing_max_latency

(Note that kernel size and overhead increase with this option
enabled. This option and the irqs-off timing option can be
@@ -506,7 +506,7 @@ config TRACER_SNAPSHOT
Allow tracing users to take snapshot of the current buffer using the
ftrace interface, e.g.:

- echo 1 > /sys/kernel/debug/tracing/snapshot
+ echo 1 > /sys/kernel/tracing/snapshot
cat snapshot

config TRACER_SNAPSHOT_PER_CPU_SWAP
@@ -518,7 +518,7 @@ config TRACER_SNAPSHOT_PER_CPU_SWAP
full swap (all buffers). If this is set, then the following is
allowed:

- echo 1 > /sys/kernel/debug/tracing/per_cpu/cpu2/snapshot
+ echo 1 > /sys/kernel/tracing/per_cpu/cpu2/snapshot

After which, only the tracing buffer for CPU 2 was swapped with
the main tracing buffer, and the other CPU buffers remain the same.
@@ -565,7 +565,7 @@ config PROFILE_ANNOTATED_BRANCHES
This tracer profiles all likely and unlikely macros
in the kernel. It will display the results in:

- /sys/kernel/debug/tracing/trace_stat/branch_annotated
+ /sys/kernel/tracing/trace_stat/branch_annotated

Note: this will add a significant overhead; only turn this
on if you need to profile the system's use of these macros.
@@ -578,7 +578,7 @@ config PROFILE_ALL_BRANCHES
taken in the kernel is recorded whether it hit or miss.
The results will be displayed in:

- /sys/kernel/debug/tracing/trace_stat/branch_all
+ /sys/kernel/tracing/trace_stat/branch_all

This option also enables the likely/unlikely profiler.

@@ -629,8 +629,8 @@ config BLK_DEV_IO_TRACE
Tracing also is possible using the ftrace interface, e.g.:

echo 1 > /sys/block/sda/sda1/trace/enable
- echo blk > /sys/kernel/debug/tracing/current_tracer
- cat /sys/kernel/debug/tracing/trace_pipe
+ echo blk > /sys/kernel/tracing/current_tracer
+ cat /sys/kernel/tracing/trace_pipe

If unsure, say N.

diff --git a/kernel/trace/kprobe_event_gen_test.c b/kernel/trace/kprobe_event_gen_test.c
index c736487fc0e4..4850fdfe27f1 100644
--- a/kernel/trace/kprobe_event_gen_test.c
+++ b/kernel/trace/kprobe_event_gen_test.c
@@ -21,7 +21,7 @@
* Then:
*
* # insmod kernel/trace/kprobe_event_gen_test.ko
- * # cat /sys/kernel/debug/tracing/trace
+ * # cat /sys/kernel/tracing/trace
*
* You should see many instances of the "gen_kprobe_test" and
* "gen_kretprobe_test" events in the trace buffer.
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index b21bf14bae9b..c4ad4939d149 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2868,7 +2868,7 @@ rb_check_timestamp(struct ring_buffer_per_cpu *cpu_buffer,
sched_clock_stable() ? "" :
"If you just came from a suspend/resume,\n"
"please switch to the trace global clock:\n"
- " echo global > /sys/kernel/debug/tracing/trace_clock\n"
+ " echo global > /sys/kernel/tracing/trace_clock\n"
"or add trace_clock=global to the kernel command line\n");
}

diff --git a/kernel/trace/synth_event_gen_test.c b/kernel/trace/synth_event_gen_test.c
index 8d77526892f4..8dfe85499d4a 100644
--- a/kernel/trace/synth_event_gen_test.c
+++ b/kernel/trace/synth_event_gen_test.c
@@ -22,7 +22,7 @@
* Then:
*
* # insmod kernel/trace/synth_event_gen_test.ko
- * # cat /sys/kernel/debug/tracing/trace
+ * # cat /sys/kernel/tracing/trace
*
* You should see several events in the trace buffer -
* "create_synth_test", "empty_synth_test", and several instances of
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a7fe0e115272..4a034b9c429d 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1143,7 +1143,7 @@ void tracing_snapshot_instance(struct trace_array *tr)
*
* Note, make sure to allocate the snapshot with either
* a tracing_snapshot_alloc(), or by doing it manually
- * with: echo 1 > /sys/kernel/debug/tracing/snapshot
+ * with: echo 1 > /sys/kernel/tracing/snapshot
*
* If the snapshot buffer is not allocated, it will stop tracing.
* Basically making a permanent snapshot.
diff --git a/samples/user_events/example.c b/samples/user_events/example.c
index d06dc24156ec..18e34c9d708e 100644
--- a/samples/user_events/example.c
+++ b/samples/user_events/example.c
@@ -23,8 +23,8 @@
#endif

/* Assumes debugfs is mounted */
-const char *data_file = "/sys/kernel/debug/tracing/user_events_data";
-const char *status_file = "/sys/kernel/debug/tracing/user_events_status";
+const char *data_file = "/sys/kernel/tracing/user_events_data";
+const char *status_file = "/sys/kernel/tracing/user_events_status";

static int event_status(long **status)
{
diff --git a/scripts/tracing/draw_functrace.py b/scripts/tracing/draw_functrace.py
index 438516bdfb3c..42fa87300941 100755
--- a/scripts/tracing/draw_functrace.py
+++ b/scripts/tracing/draw_functrace.py
@@ -12,9 +12,9 @@ calls. Only the functions's names and the call time are provided.

Usage:
Be sure that you have CONFIG_FUNCTION_TRACER
- # mount -t debugfs nodev /sys/kernel/debug
- # echo function > /sys/kernel/debug/tracing/current_tracer
- $ cat /sys/kernel/debug/tracing/trace_pipe > ~/raw_trace_func
+ # mount -t tracefs nodev /sys/kernel/tracing
+ # echo function > /sys/kernel/tracing/current_tracer
+ $ cat /sys/kernel/tracing/trace_pipe > ~/raw_trace_func
Wait some times but not too much, the script is a bit slow.
Break the pipe (Ctrl + Z)
$ scripts/tracing/draw_functrace.py < ~/raw_trace_func > draw_functrace
diff --git a/scripts/tracing/ftrace-bisect.sh b/scripts/tracing/ftrace-bisect.sh
index 926701162bc8..53244096489e 100755
--- a/scripts/tracing/ftrace-bisect.sh
+++ b/scripts/tracing/ftrace-bisect.sh
@@ -12,7 +12,7 @@
# (note, if this is a problem with function_graph tracing, then simply
# replace "function" with "function_graph" in the following steps).
#
-# # cd /sys/kernel/debug/tracing
+# # cd /sys/kernel/tracing
# # echo schedule > set_ftrace_filter
# # echo function > current_tracer
#
@@ -35,7 +35,7 @@
#
# Reboot back to test kernel.
#
-# # cd /sys/kernel/debug/tracing
+# # cd /sys/kernel/tracing
# # mv ~/test-file ~/full-file
#
# If it didn't crash.
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 5afb11b30fca..ca95310f7d8e 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -14,8 +14,8 @@
#include "tracing_path.h"

static char tracing_mnt[PATH_MAX] = "/sys/kernel/debug";
-static char tracing_path[PATH_MAX] = "/sys/kernel/debug/tracing";
-static char tracing_events_path[PATH_MAX] = "/sys/kernel/debug/tracing/events";
+static char tracing_path[PATH_MAX] = "/sys/kernel/tracing";
+static char tracing_events_path[PATH_MAX] = "/sys/kernel/tracing/events";

static void __tracing_path_set(const char *tracing, const char *mountpoint)
{
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 8e24c4c78c7f..9532bcf4138d 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -6664,7 +6664,7 @@ static void parse_header_field(const char *field,
* This parses the header page format for information on the
* ring buffer used. The @buf should be copied from
*
- * /sys/kernel/debug/tracing/events/header_page
+ * /sys/kernel/tracing/events/header_page
*/
int tep_parse_header_page(struct tep_handle *tep, char *buf, unsigned long size,
int long_size)
@@ -6758,7 +6758,7 @@ static int find_event_handle(struct tep_handle *tep, struct tep_event *event)
*
* These files currently come from:
*
- * /sys/kernel/debug/tracing/events/.../.../format
+ * /sys/kernel/tracing/events/.../.../format
*/
static enum tep_errno parse_format(struct tep_event **eventp,
struct tep_handle *tep, const char *buf,
@@ -6912,7 +6912,7 @@ __parse_event(struct tep_handle *tep,
*
* These files currently come from:
*
- * /sys/kernel/debug/tracing/events/.../.../format
+ * /sys/kernel/tracing/events/.../.../format
*/
enum tep_errno tep_parse_format(struct tep_handle *tep,
struct tep_event **eventp,
@@ -6934,7 +6934,7 @@ enum tep_errno tep_parse_format(struct tep_handle *tep,
*
* These files currently come from:
*
- * /sys/kernel/debug/tracing/events/.../.../format
+ * /sys/kernel/tracing/events/.../.../format
*/
enum tep_errno tep_parse_event(struct tep_handle *tep, const char *buf,
unsigned long size, const char *sys)
diff --git a/tools/tracing/latency/latency-collector.c b/tools/tracing/latency/latency-collector.c
index 59a7f2346eab..0fd9c747d396 100644
--- a/tools/tracing/latency/latency-collector.c
+++ b/tools/tracing/latency/latency-collector.c
@@ -1584,7 +1584,7 @@ static void *do_printloop(void *arg)
/*
* Toss a coin to decide if we want to sleep before printing
* out the backtrace. The reason for this is that opening
- * /sys/kernel/debug/tracing/trace will cause a blackout of
+ * /sys/kernel/tracing/trace will cause a blackout of
* hundreds of ms, where no latencies will be noted by the
* latency tracer. Thus by randomly sleeping we try to avoid
* missing traces systematically due to this. With this option
--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 18:20:09

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 3/9] selftests/bpf: use canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

Many tests in the bpf selftest code still refer to this older debugfs
path, so let's update them to avoid confusion.

Signed-off-by: Ross Zwisler <[email protected]>
---
tools/testing/selftests/bpf/get_cgroup_id_user.c | 2 +-
.../testing/selftests/bpf/prog_tests/kprobe_multi_test.c | 2 +-
tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c | 2 +-
tools/testing/selftests/bpf/prog_tests/tp_attach_query.c | 2 +-
tools/testing/selftests/bpf/prog_tests/trace_printk.c | 2 +-
tools/testing/selftests/bpf/prog_tests/trace_vprintk.c | 2 +-
tools/testing/selftests/bpf/progs/test_stacktrace_map.c | 2 +-
tools/testing/selftests/bpf/progs/test_tracepoint.c | 2 +-
tools/testing/selftests/bpf/test_ftrace.sh | 2 +-
tools/testing/selftests/bpf/test_tunnel.sh | 8 ++++----
tools/testing/selftests/bpf/trace_helpers.c | 4 ++--
11 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/tools/testing/selftests/bpf/get_cgroup_id_user.c b/tools/testing/selftests/bpf/get_cgroup_id_user.c
index 156743cf5870..478e080128be 100644
--- a/tools/testing/selftests/bpf/get_cgroup_id_user.c
+++ b/tools/testing/selftests/bpf/get_cgroup_id_user.c
@@ -87,7 +87,7 @@ int main(int argc, char **argv)
bpf_map_update_elem(pidmap_fd, &key, &pid, 0);

snprintf(buf, sizeof(buf),
- "/sys/kernel/debug/tracing/events/%s/id", probe_name);
+ "/sys/kernel/tracing/events/%s/id", probe_name);
efd = open(buf, O_RDONLY, 0);
if (CHECK(efd < 0, "open", "err %d errno %d\n", efd, errno))
goto close_prog;
diff --git a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
index d457a55ff408..9eaf16e9ff6e 100644
--- a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
+++ b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
@@ -338,7 +338,7 @@ static int get_syms(char ***symsp, size_t *cntp)
* Filtering out duplicates by using hashmap__add, which won't
* add existing entry.
*/
- f = fopen("/sys/kernel/debug/tracing/available_filter_functions", "r");
+ f = fopen("/sys/kernel/tracing/available_filter_functions", "r");
if (!f)
return -EINVAL;

diff --git a/tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c b/tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c
index c717741bf8b6..6d70559fc19b 100644
--- a/tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c
+++ b/tools/testing/selftests/bpf/prog_tests/task_fd_query_tp.c
@@ -18,7 +18,7 @@ static void test_task_fd_query_tp_core(const char *probe_name,
goto close_prog;

snprintf(buf, sizeof(buf),
- "/sys/kernel/debug/tracing/events/%s/id", probe_name);
+ "/sys/kernel/tracing/events/%s/id", probe_name);
efd = open(buf, O_RDONLY, 0);
if (CHECK(efd < 0, "open", "err %d errno %d\n", efd, errno))
goto close_prog;
diff --git a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
index a479080533db..4308e3a828d8 100644
--- a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
+++ b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c
@@ -17,7 +17,7 @@ void serial_test_tp_attach_query(void)
obj[i] = NULL;

snprintf(buf, sizeof(buf),
- "/sys/kernel/debug/tracing/events/sched/sched_switch/id");
+ "/sys/kernel/tracing/events/sched/sched_switch/id");
efd = open(buf, O_RDONLY, 0);
if (CHECK(efd < 0, "open", "err %d errno %d\n", efd, errno))
return;
diff --git a/tools/testing/selftests/bpf/prog_tests/trace_printk.c b/tools/testing/selftests/bpf/prog_tests/trace_printk.c
index cade7f12315f..ff50a928cb98 100644
--- a/tools/testing/selftests/bpf/prog_tests/trace_printk.c
+++ b/tools/testing/selftests/bpf/prog_tests/trace_printk.c
@@ -5,7 +5,7 @@

#include "trace_printk.lskel.h"

-#define TRACEBUF "/sys/kernel/debug/tracing/trace_pipe"
+#define TRACEBUF "/sys/kernel/tracing/trace_pipe"
#define SEARCHMSG "testing,testing"

void serial_test_trace_printk(void)
diff --git a/tools/testing/selftests/bpf/prog_tests/trace_vprintk.c b/tools/testing/selftests/bpf/prog_tests/trace_vprintk.c
index 7a4e313e8558..e568d7f247ec 100644
--- a/tools/testing/selftests/bpf/prog_tests/trace_vprintk.c
+++ b/tools/testing/selftests/bpf/prog_tests/trace_vprintk.c
@@ -5,7 +5,7 @@

#include "trace_vprintk.lskel.h"

-#define TRACEBUF "/sys/kernel/debug/tracing/trace_pipe"
+#define TRACEBUF "/sys/kernel/tracing/trace_pipe"
#define SEARCHMSG "1,2,3,4,5,6,7,8,9,10"

void serial_test_trace_vprintk(void)
diff --git a/tools/testing/selftests/bpf/progs/test_stacktrace_map.c b/tools/testing/selftests/bpf/progs/test_stacktrace_map.c
index 728dbd39eff0..47568007b668 100644
--- a/tools/testing/selftests/bpf/progs/test_stacktrace_map.c
+++ b/tools/testing/selftests/bpf/progs/test_stacktrace_map.c
@@ -38,7 +38,7 @@ struct {
__type(value, stack_trace_t);
} stack_amap SEC(".maps");

-/* taken from /sys/kernel/debug/tracing/events/sched/sched_switch/format */
+/* taken from /sys/kernel/tracing/events/sched/sched_switch/format */
struct sched_switch_args {
unsigned long long pad;
char prev_comm[TASK_COMM_LEN];
diff --git a/tools/testing/selftests/bpf/progs/test_tracepoint.c b/tools/testing/selftests/bpf/progs/test_tracepoint.c
index 43bd7a20cc50..4cb8bbb6a320 100644
--- a/tools/testing/selftests/bpf/progs/test_tracepoint.c
+++ b/tools/testing/selftests/bpf/progs/test_tracepoint.c
@@ -4,7 +4,7 @@
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>

-/* taken from /sys/kernel/debug/tracing/events/sched/sched_switch/format */
+/* taken from /sys/kernel/tracing/events/sched/sched_switch/format */
struct sched_switch_args {
unsigned long long pad;
char prev_comm[TASK_COMM_LEN];
diff --git a/tools/testing/selftests/bpf/test_ftrace.sh b/tools/testing/selftests/bpf/test_ftrace.sh
index 20de7bb873bc..e3e2328a1b65 100755
--- a/tools/testing/selftests/bpf/test_ftrace.sh
+++ b/tools/testing/selftests/bpf/test_ftrace.sh
@@ -1,6 +1,6 @@
#!/bin/bash

-TR=/sys/kernel/debug/tracing/
+TR=/sys/kernel/tracing/
clear_trace() { # reset trace output
echo > $TR/trace
}
diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh
index e9ebc67d73f7..6927e586a3a2 100755
--- a/tools/testing/selftests/bpf/test_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tunnel.sh
@@ -542,7 +542,7 @@ setup_xfrm_tunnel()
test_xfrm_tunnel()
{
config_device
- > /sys/kernel/debug/tracing/trace
+ > /sys/kernel/tracing/trace
setup_xfrm_tunnel
mkdir -p ${BPF_PIN_TUNNEL_DIR}
bpftool prog loadall ./test_tunnel_kern.o ${BPF_PIN_TUNNEL_DIR}
@@ -551,11 +551,11 @@ test_xfrm_tunnel()
${BPF_PIN_TUNNEL_DIR}/xfrm_get_state
ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
sleep 1
- grep "reqid 1" /sys/kernel/debug/tracing/trace
+ grep "reqid 1" /sys/kernel/tracing/trace
check_err $?
- grep "spi 0x1" /sys/kernel/debug/tracing/trace
+ grep "spi 0x1" /sys/kernel/tracing/trace
check_err $?
- grep "remote ip 0xac100164" /sys/kernel/debug/tracing/trace
+ grep "remote ip 0xac100164" /sys/kernel/tracing/trace
check_err $?
cleanup

diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c
index 9c4be2cdb21a..65895f5fb562 100644
--- a/tools/testing/selftests/bpf/trace_helpers.c
+++ b/tools/testing/selftests/bpf/trace_helpers.c
@@ -12,7 +12,7 @@
#include <sys/mman.h>
#include "trace_helpers.h"

-#define DEBUGFS "/sys/kernel/debug/tracing/"
+#define TRACEFS "/sys/kernel/tracing/"

#define MAX_SYMS 300000
static struct ksym syms[MAX_SYMS];
@@ -130,7 +130,7 @@ void read_trace_pipe(void)
{
int trace_fd;

- trace_fd = open(DEBUGFS "trace_pipe", O_RDONLY, 0);
+ trace_fd = open(TRACEFS "trace_pipe", O_RDONLY, 0);
if (trace_fd < 0)
return;

--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 18:20:12

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 7/9] tools/virtio: use canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

A few spots in tools/virtio still refer to this older debugfs
path, so let's update them to avoid confusion.

Signed-off-by: Ross Zwisler <[email protected]>
---
tools/virtio/virtio-trace/README | 2 +-
tools/virtio/virtio-trace/trace-agent.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virtio/virtio-trace/README b/tools/virtio/virtio-trace/README
index b64845b823ab..cea29a2a4c0a 100644
--- a/tools/virtio/virtio-trace/README
+++ b/tools/virtio/virtio-trace/README
@@ -95,7 +95,7 @@ Run

1) Enable ftrace in the guest
<Example>
- # echo 1 > /sys/kernel/debug/tracing/events/sched/enable
+ # echo 1 > /sys/kernel/tracing/events/sched/enable

2) Run trace agent in the guest
This agent must be operated as root.
diff --git a/tools/virtio/virtio-trace/trace-agent.c b/tools/virtio/virtio-trace/trace-agent.c
index cdfe77c2b4c8..805942d02e9f 100644
--- a/tools/virtio/virtio-trace/trace-agent.c
+++ b/tools/virtio/virtio-trace/trace-agent.c
@@ -19,7 +19,7 @@
#define PIPE_MIN_SIZE (PAGE_SIZE*PIPE_DEF_BUFS)
#define PIPE_MAX_SIZE (1024*1024)
#define READ_PATH_FMT \
- "/sys/kernel/debug/tracing/per_cpu/cpu%d/trace_pipe_raw"
+ "/sys/kernel/tracing/per_cpu/cpu%d/trace_pipe_raw"
#define WRITE_PATH_FMT "/dev/virtio-ports/trace-path-cpu%d"
#define CTL_PATH "/dev/virtio-ports/agent-ctl-path"

--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 18:20:15

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 6/9] selftests: use canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

A few spots in tools/testing/selftests still refer to this older debugfs
path, so let's update them to avoid confusion.

Signed-off-by: Ross Zwisler <[email protected]>
---
tools/testing/selftests/user_events/dyn_test.c | 2 +-
tools/testing/selftests/user_events/ftrace_test.c | 10 +++++-----
tools/testing/selftests/user_events/perf_test.c | 8 ++++----
tools/testing/selftests/vm/protection_keys.c | 4 ++--
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/user_events/dyn_test.c b/tools/testing/selftests/user_events/dyn_test.c
index d6265d14cd51..8879a7b04c6a 100644
--- a/tools/testing/selftests/user_events/dyn_test.c
+++ b/tools/testing/selftests/user_events/dyn_test.c
@@ -16,7 +16,7 @@

#include "../kselftest_harness.h"

-const char *dyn_file = "/sys/kernel/debug/tracing/dynamic_events";
+const char *dyn_file = "/sys/kernel/tracing/dynamic_events";
const char *clear = "!u:__test_event";

static int Append(const char *value)
diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c
index 404a2713dcae..a0b2c96eb252 100644
--- a/tools/testing/selftests/user_events/ftrace_test.c
+++ b/tools/testing/selftests/user_events/ftrace_test.c
@@ -16,11 +16,11 @@

#include "../kselftest_harness.h"

-const char *data_file = "/sys/kernel/debug/tracing/user_events_data";
-const char *status_file = "/sys/kernel/debug/tracing/user_events_status";
-const char *enable_file = "/sys/kernel/debug/tracing/events/user_events/__test_event/enable";
-const char *trace_file = "/sys/kernel/debug/tracing/trace";
-const char *fmt_file = "/sys/kernel/debug/tracing/events/user_events/__test_event/format";
+const char *data_file = "/sys/kernel/tracing/user_events_data";
+const char *status_file = "/sys/kernel/tracing/user_events_status";
+const char *enable_file = "/sys/kernel/tracing/events/user_events/__test_event/enable";
+const char *trace_file = "/sys/kernel/tracing/trace";
+const char *fmt_file = "/sys/kernel/tracing/events/user_events/__test_event/format";

static inline int status_check(char *status_page, int status_bit)
{
diff --git a/tools/testing/selftests/user_events/perf_test.c b/tools/testing/selftests/user_events/perf_test.c
index 8b4c7879d5a7..31505642aa9b 100644
--- a/tools/testing/selftests/user_events/perf_test.c
+++ b/tools/testing/selftests/user_events/perf_test.c
@@ -18,10 +18,10 @@

#include "../kselftest_harness.h"

-const char *data_file = "/sys/kernel/debug/tracing/user_events_data";
-const char *status_file = "/sys/kernel/debug/tracing/user_events_status";
-const char *id_file = "/sys/kernel/debug/tracing/events/user_events/__test_event/id";
-const char *fmt_file = "/sys/kernel/debug/tracing/events/user_events/__test_event/format";
+const char *data_file = "/sys/kernel/tracing/user_events_data";
+const char *status_file = "/sys/kernel/tracing/user_events_status";
+const char *id_file = "/sys/kernel/tracing/events/user_events/__test_event/id";
+const char *fmt_file = "/sys/kernel/tracing/events/user_events/__test_event/format";

struct event {
__u32 index;
diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c
index 291bc1e07842..0d421015fbc1 100644
--- a/tools/testing/selftests/vm/protection_keys.c
+++ b/tools/testing/selftests/vm/protection_keys.c
@@ -97,7 +97,7 @@ int tracing_root_ok(void)
void tracing_on(void)
{
#if CONTROL_TRACING > 0
-#define TRACEDIR "/sys/kernel/debug/tracing"
+#define TRACEDIR "/sys/kernel/tracing"
char pidstr[32];

if (!tracing_root_ok())
@@ -123,7 +123,7 @@ void tracing_off(void)
#if CONTROL_TRACING > 0
if (!tracing_root_ok())
return;
- cat_into_file("0", "/sys/kernel/debug/tracing/tracing_on");
+ cat_into_file("0", "/sys/kernel/tracing/tracing_on");
#endif
}

--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 18:20:17

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 8/9] leaking_addresses: also skip canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

scripts/leaking_addresses.pl only skipped this older debugfs path, so
let's add the canonical path as well.

Signed-off-by: Ross Zwisler <[email protected]>
---
scripts/leaking_addresses.pl | 1 +
1 file changed, 1 insertion(+)

diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
index 8f636a23bc3f..e695634d153d 100755
--- a/scripts/leaking_addresses.pl
+++ b/scripts/leaking_addresses.pl
@@ -61,6 +61,7 @@ my @skip_abs = (
'/proc/device-tree',
'/proc/1/syscall',
'/sys/firmware/devicetree',
+ '/sys/kernel/tracing/trace_pipe',
'/sys/kernel/debug/tracing/trace_pipe',
'/sys/kernel/security/apparmor/revision');

--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 18:20:20

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 5/9] tools/power: use canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

A few scripts in tools/power still refer to this older debugfs path, so
let's update them to avoid confusion.

Signed-off-by: Ross Zwisler <[email protected]>
---
tools/power/pm-graph/sleepgraph.py | 4 ++--
tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py | 4 ++--
.../x86/intel_pstate_tracer/intel_pstate_tracer.py | 10 +++++-----
3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/power/pm-graph/sleepgraph.py b/tools/power/pm-graph/sleepgraph.py
index cfe343306e08..eddf8101ddf6 100755
--- a/tools/power/pm-graph/sleepgraph.py
+++ b/tools/power/pm-graph/sleepgraph.py
@@ -120,9 +120,9 @@ class SystemValues:
cgexp = False
testdir = ''
outdir = ''
- tpath = '/sys/kernel/debug/tracing/'
+ tpath = '/sys/kernel/tracing/'
fpdtpath = '/sys/firmware/acpi/tables/FPDT'
- epath = '/sys/kernel/debug/tracing/events/power/'
+ epath = '/sys/kernel/tracing/events/power/'
pmdpath = '/sys/power/pm_debug_messages'
s0ixpath = '/sys/module/intel_pmc_core/parameters/warn_on_s0ix_failures'
s0ixres = '/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us'
diff --git a/tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py b/tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
index 2dea4032ac56..904df0ea0a1e 100755
--- a/tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
+++ b/tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
@@ -248,7 +248,7 @@ def signal_handler(signal, frame):
ipt.free_trace_buffer()
sys.exit(0)

-trace_file = "/sys/kernel/debug/tracing/events/amd_cpu/enable"
+trace_file = "/sys/kernel/tracing/events/amd_cpu/enable"
signal.signal(signal.SIGINT, signal_handler)

interval = ""
@@ -319,7 +319,7 @@ print(cur_version)
cleanup_data_files()

if interval:
- file_name = "/sys/kernel/debug/tracing/trace"
+ file_name = "/sys/kernel/tracing/trace"
ipt.clear_trace_file()
ipt.set_trace_buffer_size(memory)
ipt.enable_trace(trace_file)
diff --git a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
index b46e9eb8f5aa..ec3323100e1a 100755
--- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
+++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
@@ -373,7 +373,7 @@ def clear_trace_file():
""" Clear trace file """

try:
- f_handle = open('/sys/kernel/debug/tracing/trace', 'w')
+ f_handle = open('/sys/kernel/tracing/trace', 'w')
f_handle.close()
except:
print('IO error clearing trace file ')
@@ -401,7 +401,7 @@ def set_trace_buffer_size(memory):
""" Set trace buffer size """

try:
- with open('/sys/kernel/debug/tracing/buffer_size_kb', 'w') as fp:
+ with open('/sys/kernel/tracing/buffer_size_kb', 'w') as fp:
fp.write(memory)
except:
print('IO error setting trace buffer size ')
@@ -411,7 +411,7 @@ def free_trace_buffer():
""" Free the trace buffer memory """

try:
- open('/sys/kernel/debug/tracing/buffer_size_kb'
+ open('/sys/kernel/tracing/buffer_size_kb'
, 'w').write("1")
except:
print('IO error freeing trace buffer ')
@@ -495,7 +495,7 @@ def signal_handler(signal, frame):
sys.exit(0)

if __name__ == "__main__":
- trace_file = "/sys/kernel/debug/tracing/events/power/pstate_sample/enable"
+ trace_file = "/sys/kernel/tracing/events/power/pstate_sample/enable"
signal.signal(signal.SIGINT, signal_handler)

interval = ""
@@ -569,7 +569,7 @@ if __name__ == "__main__":
cleanup_data_files()

if interval:
- filename = "/sys/kernel/debug/tracing/trace"
+ filename = "/sys/kernel/tracing/trace"
clear_trace_file()
set_trace_buffer_size(memory)
enable_trace(trace_file)
--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 18:20:22

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 4/9] perf docs: use canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

A few spots in the perf docs still refer to this older debugfs path, so
let's update them to avoid confusion.

Signed-off-by: Ross Zwisler <[email protected]>
---
tools/perf/Documentation/perf-list.txt | 2 +-
tools/perf/Documentation/perf-script-perl.txt | 2 +-
tools/perf/Documentation/perf-script-python.txt | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
index 57384a97c04f..6c83459d3192 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -228,7 +228,7 @@ This can be overridden by setting the kernel.perf_event_paranoid
sysctl to -1, which allows non root to use these events.

For accessing trace point events perf needs to have read access to
-/sys/kernel/debug/tracing, even when perf_event_paranoid is in a relaxed
+/sys/kernel/tracing, even when perf_event_paranoid is in a relaxed
setting.

TRACING
diff --git a/tools/perf/Documentation/perf-script-perl.txt b/tools/perf/Documentation/perf-script-perl.txt
index fa4f39d305a7..5b479f5e62ff 100644
--- a/tools/perf/Documentation/perf-script-perl.txt
+++ b/tools/perf/Documentation/perf-script-perl.txt
@@ -55,7 +55,7 @@ Traces meant to be processed using a script should be recorded with
the above option: -a to enable system-wide collection.

The format file for the sched_wakeup event defines the following fields
-(see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format):
+(see /sys/kernel/tracing/events/sched/sched_wakeup/format):

----
format:
diff --git a/tools/perf/Documentation/perf-script-python.txt b/tools/perf/Documentation/perf-script-python.txt
index cf4b7f4b625a..6a8581012e16 100644
--- a/tools/perf/Documentation/perf-script-python.txt
+++ b/tools/perf/Documentation/perf-script-python.txt
@@ -319,7 +319,7 @@ So those are the essential steps in writing and running a script. The
process can be generalized to any tracepoint or set of tracepoints
you're interested in - basically find the tracepoint(s) you're
interested in by looking at the list of available events shown by
-'perf list' and/or look in /sys/kernel/debug/tracing/events/ for
+'perf list' and/or look in /sys/kernel/tracing/events/ for
detailed event and field info, record the corresponding trace data
using 'perf record', passing it the list of interesting events,
generate a skeleton script using 'perf script -g python' and modify the
@@ -449,7 +449,7 @@ Traces meant to be processed using a script should be recorded with
the above option: -a to enable system-wide collection.

The format file for the sched_wakeup event defines the following fields
-(see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format):
+(see /sys/kernel/tracing/events/sched/sched_wakeup/format):

----
format:
--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 18:20:25

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 2/9] bpf: use canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

Many comments and samples in the bpf code still refer to this older
debugfs path, so let's update them to avoid confusion. There are a few
spots where the bpf code explicitly checks both tracefs and debugfs
(tools/bpf/bpftool/tracelog.c and tools/lib/api/fs/fs.c) and I've left
those alone so that the tools can continue to work with both paths.

Signed-off-by: Ross Zwisler <[email protected]>
---
include/uapi/linux/bpf.h | 8 ++++----
samples/bpf/cpustat_kern.c | 4 ++--
samples/bpf/hbm.c | 4 ++--
samples/bpf/ibumad_kern.c | 4 ++--
samples/bpf/lwt_len_hist.sh | 2 +-
samples/bpf/offwaketime_kern.c | 2 +-
samples/bpf/task_fd_query_user.c | 4 ++--
samples/bpf/test_lwt_bpf.sh | 2 +-
samples/bpf/test_overhead_tp_kern.c | 4 ++--
tools/include/uapi/linux/bpf.h | 8 ++++----
10 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 51b9aa640ad2..9110163dfd70 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -1634,17 +1634,17 @@ union bpf_attr {
* Description
* This helper is a "printk()-like" facility for debugging. It
* prints a message defined by format *fmt* (of size *fmt_size*)
- * to file *\/sys/kernel/debug/tracing/trace* from DebugFS, if
+ * to file *\/sys/kernel/tracing/trace* from TraceFS, if
* available. It can take up to three additional **u64**
* arguments (as an eBPF helpers, the total number of arguments is
* limited to five).
*
* Each time the helper is called, it appends a line to the trace.
- * Lines are discarded while *\/sys/kernel/debug/tracing/trace* is
- * open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this.
+ * Lines are discarded while *\/sys/kernel/tracing/trace* is
+ * open, use *\/sys/kernel/tracing/trace_pipe* to avoid this.
* The format of the trace is customizable, and the exact output
* one will get depends on the options set in
- * *\/sys/kernel/debug/tracing/trace_options* (see also the
+ * *\/sys/kernel/tracing/trace_options* (see also the
* *README* file under the same directory). However, it usually
* defaults to something like:
*
diff --git a/samples/bpf/cpustat_kern.c b/samples/bpf/cpustat_kern.c
index 5aefd19cdfa1..944f13fe164a 100644
--- a/samples/bpf/cpustat_kern.c
+++ b/samples/bpf/cpustat_kern.c
@@ -76,8 +76,8 @@ struct {

/*
* The trace events for cpu_idle and cpu_frequency are taken from:
- * /sys/kernel/debug/tracing/events/power/cpu_idle/format
- * /sys/kernel/debug/tracing/events/power/cpu_frequency/format
+ * /sys/kernel/tracing/events/power/cpu_idle/format
+ * /sys/kernel/tracing/events/power/cpu_frequency/format
*
* These two events have same format, so define one common structure.
*/
diff --git a/samples/bpf/hbm.c b/samples/bpf/hbm.c
index 516fbac28b71..ff58ec43f56a 100644
--- a/samples/bpf/hbm.c
+++ b/samples/bpf/hbm.c
@@ -65,7 +65,7 @@ static void Usage(void);
static void read_trace_pipe2(void);
static void do_error(char *msg, bool errno_flag);

-#define DEBUGFS "/sys/kernel/debug/tracing/"
+#define TRACEFS "/sys/kernel/tracing/"

static struct bpf_program *bpf_prog;
static struct bpf_object *obj;
@@ -77,7 +77,7 @@ static void read_trace_pipe2(void)
FILE *outf;
char *outFname = "hbm_out.log";

- trace_fd = open(DEBUGFS "trace_pipe", O_RDONLY, 0);
+ trace_fd = open(TRACEFS "trace_pipe", O_RDONLY, 0);
if (trace_fd < 0) {
printf("Error opening trace_pipe\n");
return;
diff --git a/samples/bpf/ibumad_kern.c b/samples/bpf/ibumad_kern.c
index 9b193231024a..f07474c72525 100644
--- a/samples/bpf/ibumad_kern.c
+++ b/samples/bpf/ibumad_kern.c
@@ -39,8 +39,8 @@ struct {
/* Taken from the current format defined in
* include/trace/events/ib_umad.h
* and
- * /sys/kernel/debug/tracing/events/ib_umad/ib_umad_read/format
- * /sys/kernel/debug/tracing/events/ib_umad/ib_umad_write/format
+ * /sys/kernel/tracing/events/ib_umad/ib_umad_read/format
+ * /sys/kernel/tracing/events/ib_umad/ib_umad_write/format
*/
struct ib_umad_rw_args {
u64 pad;
diff --git a/samples/bpf/lwt_len_hist.sh b/samples/bpf/lwt_len_hist.sh
index 0eda9754f50b..11fa0a087db6 100755
--- a/samples/bpf/lwt_len_hist.sh
+++ b/samples/bpf/lwt_len_hist.sh
@@ -5,7 +5,7 @@ NS1=lwt_ns1
VETH0=tst_lwt1a
VETH1=tst_lwt1b

-TRACE_ROOT=/sys/kernel/debug/tracing
+TRACE_ROOT=/sys/kernel/tracing

function cleanup {
# To reset saved histogram, remove pinned map
diff --git a/samples/bpf/offwaketime_kern.c b/samples/bpf/offwaketime_kern.c
index eb4d94742e6b..23f12b47e9e5 100644
--- a/samples/bpf/offwaketime_kern.c
+++ b/samples/bpf/offwaketime_kern.c
@@ -110,7 +110,7 @@ static inline int update_counts(void *ctx, u32 pid, u64 delta)
}

#if 1
-/* taken from /sys/kernel/debug/tracing/events/sched/sched_switch/format */
+/* taken from /sys/kernel/tracing/events/sched/sched_switch/format */
struct sched_switch_args {
unsigned long long pad;
char prev_comm[TASK_COMM_LEN];
diff --git a/samples/bpf/task_fd_query_user.c b/samples/bpf/task_fd_query_user.c
index a33d74bd3a4b..1e61f2180470 100644
--- a/samples/bpf/task_fd_query_user.c
+++ b/samples/bpf/task_fd_query_user.c
@@ -235,7 +235,7 @@ static int test_debug_fs_uprobe(char *binary_path, long offset, bool is_return)
struct bpf_link *link;
ssize_t bytes;

- snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events",
+ snprintf(buf, sizeof(buf), "/sys/kernel/tracing/%s_events",
event_type);
kfd = open(buf, O_WRONLY | O_TRUNC, 0);
CHECK_PERROR_RET(kfd < 0);
@@ -252,7 +252,7 @@ static int test_debug_fs_uprobe(char *binary_path, long offset, bool is_return)
close(kfd);
kfd = -1;

- snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/events/%ss/%s/id",
+ snprintf(buf, sizeof(buf), "/sys/kernel/tracing/events/%ss/%s/id",
event_type, event_alias);
efd = open(buf, O_RDONLY, 0);
CHECK_PERROR_RET(efd < 0);
diff --git a/samples/bpf/test_lwt_bpf.sh b/samples/bpf/test_lwt_bpf.sh
index 65a976058dd3..db5691e6637f 100755
--- a/samples/bpf/test_lwt_bpf.sh
+++ b/samples/bpf/test_lwt_bpf.sh
@@ -19,7 +19,7 @@ IPVETH3="192.168.111.2"

IP_LOCAL="192.168.99.1"

-TRACE_ROOT=/sys/kernel/debug/tracing
+TRACE_ROOT=/sys/kernel/tracing

function lookup_mac()
{
diff --git a/samples/bpf/test_overhead_tp_kern.c b/samples/bpf/test_overhead_tp_kern.c
index 80edadacb692..a1d53b0d8476 100644
--- a/samples/bpf/test_overhead_tp_kern.c
+++ b/samples/bpf/test_overhead_tp_kern.c
@@ -8,7 +8,7 @@
#include <uapi/linux/bpf.h>
#include <bpf/bpf_helpers.h>

-/* from /sys/kernel/debug/tracing/events/task/task_rename/format */
+/* from /sys/kernel/tracing/events/task/task_rename/format */
struct task_rename {
__u64 pad;
__u32 pid;
@@ -22,7 +22,7 @@ int prog(struct task_rename *ctx)
return 0;
}

-/* from /sys/kernel/debug/tracing/events/random/urandom_read/format */
+/* from /sys/kernel/tracing/events/random/urandom_read/format */
struct urandom_read {
__u64 pad;
int got_bits;
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 51b9aa640ad2..9110163dfd70 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -1634,17 +1634,17 @@ union bpf_attr {
* Description
* This helper is a "printk()-like" facility for debugging. It
* prints a message defined by format *fmt* (of size *fmt_size*)
- * to file *\/sys/kernel/debug/tracing/trace* from DebugFS, if
+ * to file *\/sys/kernel/tracing/trace* from TraceFS, if
* available. It can take up to three additional **u64**
* arguments (as an eBPF helpers, the total number of arguments is
* limited to five).
*
* Each time the helper is called, it appends a line to the trace.
- * Lines are discarded while *\/sys/kernel/debug/tracing/trace* is
- * open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this.
+ * Lines are discarded while *\/sys/kernel/tracing/trace* is
+ * open, use *\/sys/kernel/tracing/trace_pipe* to avoid this.
* The format of the trace is customizable, and the exact output
* one will get depends on the options set in
- * *\/sys/kernel/debug/tracing/trace_options* (see also the
+ * *\/sys/kernel/tracing/trace_options* (see also the
* *README* file under the same directory). However, it usually
* defaults to something like:
*
--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 18:20:30

by Ross Zwisler

[permalink] [raw]
Subject: [PATCH 9/9] tools/kvm_stat: use canonical ftrace path

The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

Before 4.1, all ftrace tracing control files were within the debugfs
file system, which is typically located at /sys/kernel/debug/tracing.
For backward compatibility, when mounting the debugfs file system,
the tracefs file system will be automatically mounted at:

/sys/kernel/debug/tracing

A comment in kvm_stat still refers to this older debugfs path, so let's
update it to avoid confusion.

Signed-off-by: Ross Zwisler <[email protected]>
---
tools/kvm/kvm_stat/kvm_stat | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 6f28180ffeea..15bf00e79e3f 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -627,7 +627,7 @@ class TracepointProvider(Provider):
name)'.

All available events have directories under
- /sys/kernel/debug/tracing/events/ which export information
+ /sys/kernel/tracing/events/ which export information
about the specific event. Therefore, listing the dirs gives us
a list of all available events.

--
2.39.1.456.gfc5497dd1b-goog


2023-01-30 19:27:46

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH 7/9] tools/virtio: use canonical ftrace path

On Mon, Jan 30, 2023 at 11:19:13AM -0700, Ross Zwisler wrote:
> The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
>
> But, from Documentation/trace/ftrace.rst:
>
> Before 4.1, all ftrace tracing control files were within the debugfs
> file system, which is typically located at /sys/kernel/debug/tracing.
> For backward compatibility, when mounting the debugfs file system,
> the tracefs file system will be automatically mounted at:
>
> /sys/kernel/debug/tracing
>
> A few spots in tools/virtio still refer to this older debugfs
> path, so let's update them to avoid confusion.
>
> Signed-off-by: Ross Zwisler <[email protected]>
> ---
> tools/virtio/virtio-trace/README | 2 +-
> tools/virtio/virtio-trace/trace-agent.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/virtio/virtio-trace/README b/tools/virtio/virtio-trace/README
> index b64845b823ab..cea29a2a4c0a 100644
> --- a/tools/virtio/virtio-trace/README
> +++ b/tools/virtio/virtio-trace/README
> @@ -95,7 +95,7 @@ Run
>
> 1) Enable ftrace in the guest
> <Example>
> - # echo 1 > /sys/kernel/debug/tracing/events/sched/enable
> + # echo 1 > /sys/kernel/tracing/events/sched/enable
>
> 2) Run trace agent in the guest
> This agent must be operated as root.
> diff --git a/tools/virtio/virtio-trace/trace-agent.c b/tools/virtio/virtio-trace/trace-agent.c
> index cdfe77c2b4c8..805942d02e9f 100644
> --- a/tools/virtio/virtio-trace/trace-agent.c
> +++ b/tools/virtio/virtio-trace/trace-agent.c
> @@ -19,7 +19,7 @@
> #define PIPE_MIN_SIZE (PAGE_SIZE*PIPE_DEF_BUFS)
> #define PIPE_MAX_SIZE (1024*1024)
> #define READ_PATH_FMT \
> - "/sys/kernel/debug/tracing/per_cpu/cpu%d/trace_pipe_raw"
> + "/sys/kernel/tracing/per_cpu/cpu%d/trace_pipe_raw"

Should we try both old and new path then?

> #define WRITE_PATH_FMT "/dev/virtio-ports/trace-path-cpu%d"
> #define CTL_PATH "/dev/virtio-ports/agent-ctl-path"
>
> --
> 2.39.1.456.gfc5497dd1b-goog


2023-01-30 19:27:49

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH 0/9] use canonical ftrace path whenever possible

On Mon, Jan 30, 2023 at 11:19:06AM -0700, Ross Zwisler wrote:
> The canonical location for the tracefs filesystem is at /sys/kernel/tracing.


Acked-by: Michael S. Tsirkin <[email protected]>

> But, from Documentation/trace/ftrace.rst:
>
> Before 4.1, all ftrace tracing control files were within the debugfs
> file system, which is typically located at /sys/kernel/debug/tracing.
> For backward compatibility, when mounting the debugfs file system,
> the tracefs file system will be automatically mounted at:
>
> /sys/kernel/debug/tracing
>
> There are many places where this older debugfs path is still used in
> code comments, selftests, examples and tools, so let's update them to
> avoid confusion.
>
> I've broken up the series as best I could by maintainer or directory,
> and I've only sent people the patches that I think they care about to
> avoid spamming everyone.
>
> Ross Zwisler (9):
> tracing: always use canonical ftrace path
> bpf: use canonical ftrace path
> selftests/bpf: use canonical ftrace path
> perf docs: use canonical ftrace path
> tools/power: use canonical ftrace path
> selftests: use canonical ftrace path
> tools/virtio: use canonical ftrace path
> leaking_addresses: also skip canonical ftrace path
> tools/kvm_stat: use canonical ftrace path
>
> include/linux/kernel.h | 2 +-
> include/linux/tracepoint.h | 4 ++--
> include/uapi/linux/bpf.h | 8 ++++----
> kernel/trace/Kconfig | 20 +++++++++----------
> kernel/trace/kprobe_event_gen_test.c | 2 +-
> kernel/trace/ring_buffer.c | 2 +-
> kernel/trace/synth_event_gen_test.c | 2 +-
> kernel/trace/trace.c | 2 +-
> samples/bpf/cpustat_kern.c | 4 ++--
> samples/bpf/hbm.c | 4 ++--
> samples/bpf/ibumad_kern.c | 4 ++--
> samples/bpf/lwt_len_hist.sh | 2 +-
> samples/bpf/offwaketime_kern.c | 2 +-
> samples/bpf/task_fd_query_user.c | 4 ++--
> samples/bpf/test_lwt_bpf.sh | 2 +-
> samples/bpf/test_overhead_tp_kern.c | 4 ++--
> samples/user_events/example.c | 4 ++--
> scripts/leaking_addresses.pl | 1 +
> scripts/tracing/draw_functrace.py | 6 +++---
> scripts/tracing/ftrace-bisect.sh | 4 ++--
> tools/include/uapi/linux/bpf.h | 8 ++++----
> tools/kvm/kvm_stat/kvm_stat | 2 +-
> tools/lib/api/fs/tracing_path.c | 4 ++--
> tools/lib/traceevent/event-parse.c | 8 ++++----
> tools/perf/Documentation/perf-list.txt | 2 +-
> tools/perf/Documentation/perf-script-perl.txt | 2 +-
> .../perf/Documentation/perf-script-python.txt | 4 ++--
> tools/power/pm-graph/sleepgraph.py | 4 ++--
> .../x86/amd_pstate_tracer/amd_pstate_trace.py | 4 ++--
> .../intel_pstate_tracer.py | 10 +++++-----
> .../selftests/bpf/get_cgroup_id_user.c | 2 +-
> .../bpf/prog_tests/kprobe_multi_test.c | 2 +-
> .../bpf/prog_tests/task_fd_query_tp.c | 2 +-
> .../bpf/prog_tests/tp_attach_query.c | 2 +-
> .../selftests/bpf/prog_tests/trace_printk.c | 2 +-
> .../selftests/bpf/prog_tests/trace_vprintk.c | 2 +-
> .../selftests/bpf/progs/test_stacktrace_map.c | 2 +-
> .../selftests/bpf/progs/test_tracepoint.c | 2 +-
> tools/testing/selftests/bpf/test_ftrace.sh | 2 +-
> tools/testing/selftests/bpf/test_tunnel.sh | 8 ++++----
> tools/testing/selftests/bpf/trace_helpers.c | 4 ++--
> .../testing/selftests/user_events/dyn_test.c | 2 +-
> .../selftests/user_events/ftrace_test.c | 10 +++++-----
> .../testing/selftests/user_events/perf_test.c | 8 ++++----
> tools/testing/selftests/vm/protection_keys.c | 4 ++--
> tools/tracing/latency/latency-collector.c | 2 +-
> tools/virtio/virtio-trace/README | 2 +-
> tools/virtio/virtio-trace/trace-agent.c | 2 +-
> 48 files changed, 96 insertions(+), 95 deletions(-)
>
> --
> 2.39.1.456.gfc5497dd1b-goog


2023-01-30 19:34:27

by Tycho Andersen

[permalink] [raw]
Subject: Re: [PATCH 8/9] leaking_addresses: also skip canonical ftrace path

On Mon, Jan 30, 2023 at 11:19:14AM -0700, Ross Zwisler wrote:
> The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
>
> But, from Documentation/trace/ftrace.rst:
>
> Before 4.1, all ftrace tracing control files were within the debugfs
> file system, which is typically located at /sys/kernel/debug/tracing.
> For backward compatibility, when mounting the debugfs file system,
> the tracefs file system will be automatically mounted at:
>
> /sys/kernel/debug/tracing
>
> scripts/leaking_addresses.pl only skipped this older debugfs path, so
> let's add the canonical path as well.
>
> Signed-off-by: Ross Zwisler <[email protected]>
> ---
> scripts/leaking_addresses.pl | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl
> index 8f636a23bc3f..e695634d153d 100755
> --- a/scripts/leaking_addresses.pl
> +++ b/scripts/leaking_addresses.pl
> @@ -61,6 +61,7 @@ my @skip_abs = (
> '/proc/device-tree',
> '/proc/1/syscall',
> '/sys/firmware/devicetree',
> + '/sys/kernel/tracing/trace_pipe',
> '/sys/kernel/debug/tracing/trace_pipe',
> '/sys/kernel/security/apparmor/revision');

Thanks.

Acked-by: Tycho Andersen <[email protected]>

2023-01-30 19:52:21

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH 3/9] selftests/bpf: use canonical ftrace path

On Mon, Jan 30, 2023 at 10:19 AM Ross Zwisler <[email protected]> wrote:
>
> The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
>
> But, from Documentation/trace/ftrace.rst:
>
> Before 4.1, all ftrace tracing control files were within the debugfs
> file system, which is typically located at /sys/kernel/debug/tracing.
> For backward compatibility, when mounting the debugfs file system,
> the tracefs file system will be automatically mounted at:
>
> /sys/kernel/debug/tracing
>
> Many tests in the bpf selftest code still refer to this older debugfs
> path, so let's update them to avoid confusion.

I wish that was the case, but in reality there are still systems
out there where tracefs is only mounted in that old location.
For example in one my VMs:

$ cat /proc/mounts |grep tracefs
tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0
$ ls /sys/kernel/tracing/
$ uname -r
6.2.0-rc5-01030-gc1a3daf7363b

So this change will break the tests. We cannot do it.

2023-01-30 20:00:04

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 3/9] selftests/bpf: use canonical ftrace path

On Mon, 30 Jan 2023 11:52:03 -0800
Alexei Starovoitov <[email protected]> wrote:

> On Mon, Jan 30, 2023 at 10:19 AM Ross Zwisler <[email protected]> wrote:
> >
> > The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
> >
> > But, from Documentation/trace/ftrace.rst:
> >
> > Before 4.1, all ftrace tracing control files were within the debugfs
> > file system, which is typically located at /sys/kernel/debug/tracing.
> > For backward compatibility, when mounting the debugfs file system,
> > the tracefs file system will be automatically mounted at:
> >
> > /sys/kernel/debug/tracing
> >
> > Many tests in the bpf selftest code still refer to this older debugfs
> > path, so let's update them to avoid confusion.
>
> I wish that was the case, but in reality there are still systems
> out there where tracefs is only mounted in that old location.
> For example in one my VMs:
>
> $ cat /proc/mounts |grep tracefs
> tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0
> $ ls /sys/kernel/tracing/
> $ uname -r
> 6.2.0-rc5-01030-gc1a3daf7363b
>
> So this change will break the tests. We cannot do it.

Could we add a way to try to mount it?

If anything, the tests should not have the path hard coded. It should then
look to see if it is mounted and use the path that is found. Otherwise it
should try mounting it at the correct location.

Feel free to take the code from libtracefs (and modify it):

https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/tree/src/tracefs-utils.c#n89

It will make the test code much more robust.

-- Steve

2023-01-30 20:04:13

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH 3/9] selftests/bpf: use canonical ftrace path

On Mon, Jan 30, 2023 at 11:59 AM Steven Rostedt <[email protected]> wrote:
>
> On Mon, 30 Jan 2023 11:52:03 -0800
> Alexei Starovoitov <[email protected]> wrote:
>
> > On Mon, Jan 30, 2023 at 10:19 AM Ross Zwisler <[email protected]> wrote:
> > >
> > > The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
> > >
> > > But, from Documentation/trace/ftrace.rst:
> > >
> > > Before 4.1, all ftrace tracing control files were within the debugfs
> > > file system, which is typically located at /sys/kernel/debug/tracing.
> > > For backward compatibility, when mounting the debugfs file system,
> > > the tracefs file system will be automatically mounted at:
> > >
> > > /sys/kernel/debug/tracing
> > >
> > > Many tests in the bpf selftest code still refer to this older debugfs
> > > path, so let's update them to avoid confusion.
> >
> > I wish that was the case, but in reality there are still systems
> > out there where tracefs is only mounted in that old location.
> > For example in one my VMs:
> >
> > $ cat /proc/mounts |grep tracefs
> > tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0
> > $ ls /sys/kernel/tracing/
> > $ uname -r
> > 6.2.0-rc5-01030-gc1a3daf7363b
> >
> > So this change will break the tests. We cannot do it.
>
> Could we add a way to try to mount it?
>
> If anything, the tests should not have the path hard coded. It should then
> look to see if it is mounted and use the path that is found. Otherwise it
> should try mounting it at the correct location.
>
> Feel free to take the code from libtracefs (and modify it):
>
> https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/tree/src/tracefs-utils.c#n89
>
> It will make the test code much more robust.

The point is not about tests. The point is that this change might break
some users that are working today with /sys/kernel/debug/tracing.
It also might be mounted differently.
For example from another system:
cat /proc/mounts|grep trace
tracefs /sys/kernel/tracing tracefs rw,nosuid,nodev,noexec,relatime 0 0
tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0

So I suggest leaving the code as-is.

2023-01-30 23:34:32

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 3/9] selftests/bpf: use canonical ftrace path

On Mon, 30 Jan 2023 12:03:52 -0800
Alexei Starovoitov <[email protected]> wrote:
> > >
> > > So this change will break the tests. We cannot do it.
> >
> > Could we add a way to try to mount it?
> >
> > If anything, the tests should not have the path hard coded. It should then
> > look to see if it is mounted and use the path that is found. Otherwise it
> > should try mounting it at the correct location.
> >
> > Feel free to take the code from libtracefs (and modify it):
> >
> > https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/tree/src/tracefs-utils.c#n89
> >
> > It will make the test code much more robust.
>
> The point is not about tests. The point is that this change might break
> some users that are working today with /sys/kernel/debug/tracing.

> It also might be mounted differently.
> For example from another system:
> cat /proc/mounts|grep trace
> tracefs /sys/kernel/tracing tracefs rw,nosuid,nodev,noexec,relatime 0 0
> tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0

Yes, and the code works when it's mounted multiple times.

>
> So I suggest leaving the code as-is.

Why? I want to make /sys/kernel/debug/tracing deprecated. It's a hack to
not break old code. I've had complaints about that hack, and there's even
systems that disable the auto mounting (that is, /sys/kernel/debug/tracing
would not exist in such configs) This was never expected to be a permanent
solution.

If anything, leaving hardcoded calls like that forces the user to mount
debugfs when they may not want to. The entire point of tracefs was to allow
users to have access to the trace events without having to expose debugfs
and all the crud it brings with it. This was requested several times before
it was added.

What is your technical reason for not modifying the code to look for
tracefs in /sys/kernel/tracing and if it's not there try
/sys/kernel/debug/tracing, and if both are not found, try mounting it.

That change is not hard and makes the code much more robust and does not
break anything.

-- Steve



2023-01-31 00:53:25

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH 3/9] selftests/bpf: use canonical ftrace path

On Mon, Jan 30, 2023 at 06:34:19PM -0500, Steven Rostedt wrote:
> On Mon, 30 Jan 2023 12:03:52 -0800
> Alexei Starovoitov <[email protected]> wrote:
> > > >
> > > > So this change will break the tests. We cannot do it.
> > >
> > > Could we add a way to try to mount it?
> > >
> > > If anything, the tests should not have the path hard coded. It should then
> > > look to see if it is mounted and use the path that is found. Otherwise it
> > > should try mounting it at the correct location.
> > >
> > > Feel free to take the code from libtracefs (and modify it):
> > >
> > > https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/tree/src/tracefs-utils.c#n89
> > >
> > > It will make the test code much more robust.
> >
> > The point is not about tests. The point is that this change might break
> > some users that are working today with /sys/kernel/debug/tracing.
>
> > It also might be mounted differently.
> > For example from another system:
> > cat /proc/mounts|grep trace
> > tracefs /sys/kernel/tracing tracefs rw,nosuid,nodev,noexec,relatime 0 0
> > tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0
>
> Yes, and the code works when it's mounted multiple times.
>
> >
> > So I suggest leaving the code as-is.
>
> Why? I want to make /sys/kernel/debug/tracing deprecated. It's a hack to
> not break old code. I've had complaints about that hack, and there's even
> systems that disable the auto mounting (that is, /sys/kernel/debug/tracing
> would not exist in such configs) This was never expected to be a permanent
> solution.

I don't think /sys/kernel/debug/tracing can ever be deprecated.
There are plenty of user space applications (not bpf related at all) that
expect it to be in that location.

Quick search shows:

android profiler:
https://android.googlesource.com/platform/external/perfetto/+/refs/heads/master/src/tools/dump_ftrace_stats/main.cc#60

java profiler:
https://github.com/jvm-profiling-tools/async-profiler/blob/master/src/perfEvents_linux.cpp#L85

> If anything, leaving hardcoded calls like that forces the user to mount
> debugfs when they may not want to. The entire point of tracefs was to allow
> users to have access to the trace events without having to expose debugfs
> and all the crud it brings with it. This was requested several times before
> it was added.

All makes sense.

> What is your technical reason for not modifying the code to look for
> tracefs in /sys/kernel/tracing and if it's not there try
> /sys/kernel/debug/tracing, and if both are not found, try mounting it.

libbpf already has code to probe both locations.
The point that full deprecation of /sys/kernel/debug/tracing is not possible,
hence no point doing the diff:
48 files changed, 96 insertions(+), 95 deletions(-)
It doesn't move the needle. Just a code churn.

2023-01-31 19:50:57

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 3/9] selftests/bpf: use canonical ftrace path

On Mon, 30 Jan 2023 16:53:15 -0800
Alexei Starovoitov <[email protected]> wrote:

> I don't think /sys/kernel/debug/tracing can ever be deprecated.
> There are plenty of user space applications (not bpf related at all) that
> expect it to be in that location.
>
> Quick search shows:
>
> android profiler:
> https://android.googlesource.com/platform/external/perfetto/+/refs/heads/master/src/tools/dump_ftrace_stats/main.cc#60
>
> java profiler:
> https://github.com/jvm-profiling-tools/async-profiler/blob/master/src/perfEvents_linux.cpp#L85

These can easily be changed. We have deprecated stuff in the past, by
making sure all the affected code is updated properly.

One way is to start adding printks when used. Then update to WARN() to get
people to complain. Yes, the burden is on us (me and others) to go out and
fix the issues. But it is possible to do, as I've done it before.

>
> > If anything, leaving hardcoded calls like that forces the user to mount
> > debugfs when they may not want to. The entire point of tracefs was to allow
> > users to have access to the trace events without having to expose debugfs
> > and all the crud it brings with it. This was requested several times before
> > it was added.
>
> All makes sense.
>
> > What is your technical reason for not modifying the code to look for
> > tracefs in /sys/kernel/tracing and if it's not there try
> > /sys/kernel/debug/tracing, and if both are not found, try mounting it.
>
> libbpf already has code to probe both locations.
> The point that full deprecation of /sys/kernel/debug/tracing is not possible,
> hence no point doing the diff:
> 48 files changed, 96 insertions(+), 95 deletions(-)
> It doesn't move the needle. Just a code churn.

As code in the Linux kernel is used as examples for future work, it should
not be using an interface that is obsolete. That's enough rational for code
churn. This "we can never deprecated so we won't even try" BS is not an
answer.

-- Steve

2023-01-31 23:26:44

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH 3/9] selftests/bpf: use canonical ftrace path

On Tue, Jan 31, 2023 at 11:50 AM Steven Rostedt <[email protected]> wrote:
>
> As code in the Linux kernel is used as examples for future work, it should
> not be using an interface that is obsolete. That's enough rational for code
> churn.

Fair enough. Please resubmit these two patches towards bpf-next
with [PATCH bpf-next] subj, so that BPF CI can chew on it.

2023-02-01 00:05:32

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH 3/9] selftests/bpf: use canonical ftrace path

On Tue, Jan 31, 2023 at 4:26 PM Alexei Starovoitov
<[email protected]> wrote:
> Fair enough. Please resubmit these two patches towards bpf-next
> with [PATCH bpf-next] subj, so that BPF CI can chew on it.

Will do, thanks.

2023-02-01 22:07:42

by Ross Zwisler

[permalink] [raw]
Subject: Re: [PATCH 7/9] tools/virtio: use canonical ftrace path

On Mon, Jan 30, 2023 at 02:26:43PM -0500, Michael S. Tsirkin wrote:
> On Mon, Jan 30, 2023 at 11:19:13AM -0700, Ross Zwisler wrote:
> > The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
> >
> > But, from Documentation/trace/ftrace.rst:
> >
> > Before 4.1, all ftrace tracing control files were within the debugfs
> > file system, which is typically located at /sys/kernel/debug/tracing.
> > For backward compatibility, when mounting the debugfs file system,
> > the tracefs file system will be automatically mounted at:
> >
> > /sys/kernel/debug/tracing
> >
> > A few spots in tools/virtio still refer to this older debugfs
> > path, so let's update them to avoid confusion.
> >
> > Signed-off-by: Ross Zwisler <[email protected]>
> > ---
> > tools/virtio/virtio-trace/README | 2 +-
> > tools/virtio/virtio-trace/trace-agent.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/virtio/virtio-trace/README b/tools/virtio/virtio-trace/README
> > index b64845b823ab..cea29a2a4c0a 100644
> > --- a/tools/virtio/virtio-trace/README
> > +++ b/tools/virtio/virtio-trace/README
> > @@ -95,7 +95,7 @@ Run
> >
> > 1) Enable ftrace in the guest
> > <Example>
> > - # echo 1 > /sys/kernel/debug/tracing/events/sched/enable
> > + # echo 1 > /sys/kernel/tracing/events/sched/enable
> >
> > 2) Run trace agent in the guest
> > This agent must be operated as root.
> > diff --git a/tools/virtio/virtio-trace/trace-agent.c b/tools/virtio/virtio-trace/trace-agent.c
> > index cdfe77c2b4c8..805942d02e9f 100644
> > --- a/tools/virtio/virtio-trace/trace-agent.c
> > +++ b/tools/virtio/virtio-trace/trace-agent.c
> > @@ -19,7 +19,7 @@
> > #define PIPE_MIN_SIZE (PAGE_SIZE*PIPE_DEF_BUFS)
> > #define PIPE_MAX_SIZE (1024*1024)
> > #define READ_PATH_FMT \
> > - "/sys/kernel/debug/tracing/per_cpu/cpu%d/trace_pipe_raw"
> > + "/sys/kernel/tracing/per_cpu/cpu%d/trace_pipe_raw"
>
> Should we try both old and new path then?

Sure, I think it makes sense to have all the comments & documentation point
only to the preferred location, but I think for tools it makes sense to check
both places so that we don't see field regressions. This is what the BPF code
does:

https://elixir.bootlin.com/linux/latest/source/tools/bpf/bpftool/tracelog.c#L98

I'll add a check and fallback to this tool & send out v2. Thanks for the
review.

> > #define WRITE_PATH_FMT "/dev/virtio-ports/trace-path-cpu%d"
> > #define CTL_PATH "/dev/virtio-ports/agent-ctl-path"
> >
> > --
> > 2.39.1.456.gfc5497dd1b-goog
>

2023-02-02 01:24:31

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 4/9] perf docs: use canonical ftrace path

Em Mon, Jan 30, 2023 at 11:19:10AM -0700, Ross Zwisler escreveu:
> The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
>
> But, from Documentation/trace/ftrace.rst:
>
> Before 4.1, all ftrace tracing control files were within the debugfs
> file system, which is typically located at /sys/kernel/debug/tracing.
> For backward compatibility, when mounting the debugfs file system,
> the tracefs file system will be automatically mounted at:
>
> /sys/kernel/debug/tracing
>
> A few spots in the perf docs still refer to this older debugfs path, so
> let's update them to avoid confusion.

Thanks, applied.

- Arnaldo


> Signed-off-by: Ross Zwisler <[email protected]>
> ---
> tools/perf/Documentation/perf-list.txt | 2 +-
> tools/perf/Documentation/perf-script-perl.txt | 2 +-
> tools/perf/Documentation/perf-script-python.txt | 4 ++--
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt
> index 57384a97c04f..6c83459d3192 100644
> --- a/tools/perf/Documentation/perf-list.txt
> +++ b/tools/perf/Documentation/perf-list.txt
> @@ -228,7 +228,7 @@ This can be overridden by setting the kernel.perf_event_paranoid
> sysctl to -1, which allows non root to use these events.
>
> For accessing trace point events perf needs to have read access to
> -/sys/kernel/debug/tracing, even when perf_event_paranoid is in a relaxed
> +/sys/kernel/tracing, even when perf_event_paranoid is in a relaxed
> setting.
>
> TRACING
> diff --git a/tools/perf/Documentation/perf-script-perl.txt b/tools/perf/Documentation/perf-script-perl.txt
> index fa4f39d305a7..5b479f5e62ff 100644
> --- a/tools/perf/Documentation/perf-script-perl.txt
> +++ b/tools/perf/Documentation/perf-script-perl.txt
> @@ -55,7 +55,7 @@ Traces meant to be processed using a script should be recorded with
> the above option: -a to enable system-wide collection.
>
> The format file for the sched_wakeup event defines the following fields
> -(see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format):
> +(see /sys/kernel/tracing/events/sched/sched_wakeup/format):
>
> ----
> format:
> diff --git a/tools/perf/Documentation/perf-script-python.txt b/tools/perf/Documentation/perf-script-python.txt
> index cf4b7f4b625a..6a8581012e16 100644
> --- a/tools/perf/Documentation/perf-script-python.txt
> +++ b/tools/perf/Documentation/perf-script-python.txt
> @@ -319,7 +319,7 @@ So those are the essential steps in writing and running a script. The
> process can be generalized to any tracepoint or set of tracepoints
> you're interested in - basically find the tracepoint(s) you're
> interested in by looking at the list of available events shown by
> -'perf list' and/or look in /sys/kernel/debug/tracing/events/ for
> +'perf list' and/or look in /sys/kernel/tracing/events/ for
> detailed event and field info, record the corresponding trace data
> using 'perf record', passing it the list of interesting events,
> generate a skeleton script using 'perf script -g python' and modify the
> @@ -449,7 +449,7 @@ Traces meant to be processed using a script should be recorded with
> the above option: -a to enable system-wide collection.
>
> The format file for the sched_wakeup event defines the following fields
> -(see /sys/kernel/debug/tracing/events/sched/sched_wakeup/format):
> +(see /sys/kernel/tracing/events/sched/sched_wakeup/format):
>
> ----
> format:
> --
> 2.39.1.456.gfc5497dd1b-goog
>

--

- Arnaldo

2023-02-02 14:47:43

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH 5/9] tools/power: use canonical ftrace path

On Mon, Jan 30, 2023 at 7:20 PM Ross Zwisler <[email protected]> wrote:
>
> The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
>
> But, from Documentation/trace/ftrace.rst:
>
> Before 4.1, all ftrace tracing control files were within the debugfs
> file system, which is typically located at /sys/kernel/debug/tracing.
> For backward compatibility, when mounting the debugfs file system,
> the tracefs file system will be automatically mounted at:
>
> /sys/kernel/debug/tracing
>
> A few scripts in tools/power still refer to this older debugfs path, so
> let's update them to avoid confusion.
>
> Signed-off-by: Ross Zwisler <[email protected]>
> ---
> tools/power/pm-graph/sleepgraph.py | 4 ++--
> tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py | 4 ++--
> .../x86/intel_pstate_tracer/intel_pstate_tracer.py | 10 +++++-----
> 3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/tools/power/pm-graph/sleepgraph.py b/tools/power/pm-graph/sleepgraph.py
> index cfe343306e08..eddf8101ddf6 100755
> --- a/tools/power/pm-graph/sleepgraph.py
> +++ b/tools/power/pm-graph/sleepgraph.py
> @@ -120,9 +120,9 @@ class SystemValues:
> cgexp = False
> testdir = ''
> outdir = ''
> - tpath = '/sys/kernel/debug/tracing/'
> + tpath = '/sys/kernel/tracing/'
> fpdtpath = '/sys/firmware/acpi/tables/FPDT'
> - epath = '/sys/kernel/debug/tracing/events/power/'
> + epath = '/sys/kernel/tracing/events/power/'
> pmdpath = '/sys/power/pm_debug_messages'
> s0ixpath = '/sys/module/intel_pmc_core/parameters/warn_on_s0ix_failures'
> s0ixres = '/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us'
> diff --git a/tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py b/tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
> index 2dea4032ac56..904df0ea0a1e 100755
> --- a/tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
> +++ b/tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
> @@ -248,7 +248,7 @@ def signal_handler(signal, frame):
> ipt.free_trace_buffer()
> sys.exit(0)
>
> -trace_file = "/sys/kernel/debug/tracing/events/amd_cpu/enable"
> +trace_file = "/sys/kernel/tracing/events/amd_cpu/enable"
> signal.signal(signal.SIGINT, signal_handler)
>
> interval = ""
> @@ -319,7 +319,7 @@ print(cur_version)
> cleanup_data_files()
>
> if interval:
> - file_name = "/sys/kernel/debug/tracing/trace"
> + file_name = "/sys/kernel/tracing/trace"
> ipt.clear_trace_file()
> ipt.set_trace_buffer_size(memory)
> ipt.enable_trace(trace_file)
> diff --git a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> index b46e9eb8f5aa..ec3323100e1a 100755
> --- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> +++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> @@ -373,7 +373,7 @@ def clear_trace_file():
> """ Clear trace file """
>
> try:
> - f_handle = open('/sys/kernel/debug/tracing/trace', 'w')
> + f_handle = open('/sys/kernel/tracing/trace', 'w')
> f_handle.close()
> except:
> print('IO error clearing trace file ')
> @@ -401,7 +401,7 @@ def set_trace_buffer_size(memory):
> """ Set trace buffer size """
>
> try:
> - with open('/sys/kernel/debug/tracing/buffer_size_kb', 'w') as fp:
> + with open('/sys/kernel/tracing/buffer_size_kb', 'w') as fp:
> fp.write(memory)
> except:
> print('IO error setting trace buffer size ')
> @@ -411,7 +411,7 @@ def free_trace_buffer():
> """ Free the trace buffer memory """
>
> try:
> - open('/sys/kernel/debug/tracing/buffer_size_kb'
> + open('/sys/kernel/tracing/buffer_size_kb'
> , 'w').write("1")
> except:
> print('IO error freeing trace buffer ')
> @@ -495,7 +495,7 @@ def signal_handler(signal, frame):
> sys.exit(0)
>
> if __name__ == "__main__":
> - trace_file = "/sys/kernel/debug/tracing/events/power/pstate_sample/enable"
> + trace_file = "/sys/kernel/tracing/events/power/pstate_sample/enable"
> signal.signal(signal.SIGINT, signal_handler)
>
> interval = ""
> @@ -569,7 +569,7 @@ if __name__ == "__main__":
> cleanup_data_files()
>
> if interval:
> - filename = "/sys/kernel/debug/tracing/trace"
> + filename = "/sys/kernel/tracing/trace"
> clear_trace_file()
> set_trace_buffer_size(memory)
> enable_trace(trace_file)
> --

Applied as 6.3 material, thanks!