Skip to content

Commit 07496ee

Browse files
Ross Zwislermstsirkin
authored andcommitted
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 <zwisler@google.com> Message-Id: <20230215223350.2658616-6-zwisler@google.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Mukesh Ojha <quic_mojha@quicinc.com>
1 parent beee7fd commit 07496ee

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

tools/virtio/virtio-trace/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Run
9595

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

100100
2) Run trace agent in the guest
101101
This agent must be operated as root.

tools/virtio/virtio-trace/trace-agent.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
#define PIPE_DEF_BUFS 16
1919
#define PIPE_MIN_SIZE (PAGE_SIZE*PIPE_DEF_BUFS)
2020
#define PIPE_MAX_SIZE (1024*1024)
21-
#define READ_PATH_FMT \
22-
"/sys/kernel/debug/tracing/per_cpu/cpu%d/trace_pipe_raw"
21+
#define TRACEFS "/sys/kernel/tracing"
22+
#define DEBUGFS "/sys/kernel/debug/tracing"
23+
#define READ_PATH_FMT "%s/per_cpu/cpu%d/trace_pipe_raw"
2324
#define WRITE_PATH_FMT "/dev/virtio-ports/trace-path-cpu%d"
2425
#define CTL_PATH "/dev/virtio-ports/agent-ctl-path"
2526

@@ -120,9 +121,12 @@ static const char *make_path(int cpu_num, bool this_is_write_path)
120121
if (this_is_write_path)
121122
/* write(output) path */
122123
ret = snprintf(buf, PATH_MAX, WRITE_PATH_FMT, cpu_num);
123-
else
124+
else {
124125
/* read(input) path */
125-
ret = snprintf(buf, PATH_MAX, READ_PATH_FMT, cpu_num);
126+
ret = snprintf(buf, PATH_MAX, READ_PATH_FMT, TRACEFS, cpu_num);
127+
if (ret > 0 && access(buf, F_OK) != 0)
128+
ret = snprintf(buf, PATH_MAX, READ_PATH_FMT, DEBUGFS, cpu_num);
129+
}
126130

127131
if (ret <= 0) {
128132
pr_err("Failed to generate %s path(CPU#%d):%d\n",

0 commit comments

Comments
 (0)