Commit 27d7fdf0 authored by Ross Zwisler's avatar Ross Zwisler Committed by Alexei Starovoitov

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: default avatarRoss Zwisler <zwisler@google.com>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20230313205628.1058720-2-zwisler@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 9e36a204
...@@ -1647,17 +1647,17 @@ union bpf_attr { ...@@ -1647,17 +1647,17 @@ union bpf_attr {
* Description * Description
* This helper is a "printk()-like" facility for debugging. It * This helper is a "printk()-like" facility for debugging. It
* prints a message defined by format *fmt* (of size *fmt_size*) * 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** * available. It can take up to three additional **u64**
* arguments (as an eBPF helpers, the total number of arguments is * arguments (as an eBPF helpers, the total number of arguments is
* limited to five). * limited to five).
* *
* Each time the helper is called, it appends a line to the trace. * Each time the helper is called, it appends a line to the trace.
* Lines are discarded while *\/sys/kernel/debug/tracing/trace* is * Lines are discarded while *\/sys/kernel/tracing/trace* is
* open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this. * open, use *\/sys/kernel/tracing/trace_pipe* to avoid this.
* The format of the trace is customizable, and the exact output * The format of the trace is customizable, and the exact output
* one will get depends on the options set in * 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 * *README* file under the same directory). However, it usually
* defaults to something like: * defaults to something like:
* *
......
...@@ -76,8 +76,8 @@ struct { ...@@ -76,8 +76,8 @@ struct {
/* /*
* The trace events for cpu_idle and cpu_frequency are taken from: * The trace events for cpu_idle and cpu_frequency are taken from:
* /sys/kernel/debug/tracing/events/power/cpu_idle/format * /sys/kernel/tracing/events/power/cpu_idle/format
* /sys/kernel/debug/tracing/events/power/cpu_frequency/format * /sys/kernel/tracing/events/power/cpu_frequency/format
* *
* These two events have same format, so define one common structure. * These two events have same format, so define one common structure.
*/ */
......
...@@ -65,7 +65,7 @@ static void Usage(void); ...@@ -65,7 +65,7 @@ static void Usage(void);
static void read_trace_pipe2(void); static void read_trace_pipe2(void);
static void do_error(char *msg, bool errno_flag); 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_program *bpf_prog;
static struct bpf_object *obj; static struct bpf_object *obj;
...@@ -77,7 +77,7 @@ static void read_trace_pipe2(void) ...@@ -77,7 +77,7 @@ static void read_trace_pipe2(void)
FILE *outf; FILE *outf;
char *outFname = "hbm_out.log"; 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) { if (trace_fd < 0) {
printf("Error opening trace_pipe\n"); printf("Error opening trace_pipe\n");
return; return;
......
...@@ -39,8 +39,8 @@ struct { ...@@ -39,8 +39,8 @@ struct {
/* Taken from the current format defined in /* Taken from the current format defined in
* include/trace/events/ib_umad.h * include/trace/events/ib_umad.h
* and * and
* /sys/kernel/debug/tracing/events/ib_umad/ib_umad_read/format * /sys/kernel/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_write/format
*/ */
struct ib_umad_rw_args { struct ib_umad_rw_args {
u64 pad; u64 pad;
......
...@@ -5,7 +5,7 @@ NS1=lwt_ns1 ...@@ -5,7 +5,7 @@ NS1=lwt_ns1
VETH0=tst_lwt1a VETH0=tst_lwt1a
VETH1=tst_lwt1b VETH1=tst_lwt1b
BPF_PROG=lwt_len_hist.bpf.o BPF_PROG=lwt_len_hist.bpf.o
TRACE_ROOT=/sys/kernel/debug/tracing TRACE_ROOT=/sys/kernel/tracing
function cleanup { function cleanup {
# To reset saved histogram, remove pinned map # To reset saved histogram, remove pinned map
......
...@@ -110,7 +110,7 @@ static inline int update_counts(void *ctx, u32 pid, u64 delta) ...@@ -110,7 +110,7 @@ static inline int update_counts(void *ctx, u32 pid, u64 delta)
} }
#if 1 #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 { struct sched_switch_args {
unsigned long long pad; unsigned long long pad;
char prev_comm[TASK_COMM_LEN]; char prev_comm[TASK_COMM_LEN];
......
...@@ -235,7 +235,7 @@ static int test_debug_fs_uprobe(char *binary_path, long offset, bool is_return) ...@@ -235,7 +235,7 @@ static int test_debug_fs_uprobe(char *binary_path, long offset, bool is_return)
struct bpf_link *link; struct bpf_link *link;
ssize_t bytes; ssize_t bytes;
snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events", snprintf(buf, sizeof(buf), "/sys/kernel/tracing/%s_events",
event_type); event_type);
kfd = open(buf, O_WRONLY | O_TRUNC, 0); kfd = open(buf, O_WRONLY | O_TRUNC, 0);
CHECK_PERROR_RET(kfd < 0); CHECK_PERROR_RET(kfd < 0);
...@@ -252,7 +252,7 @@ static int test_debug_fs_uprobe(char *binary_path, long offset, bool is_return) ...@@ -252,7 +252,7 @@ static int test_debug_fs_uprobe(char *binary_path, long offset, bool is_return)
close(kfd); close(kfd);
kfd = -1; 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); event_type, event_alias);
efd = open(buf, O_RDONLY, 0); efd = open(buf, O_RDONLY, 0);
CHECK_PERROR_RET(efd < 0); CHECK_PERROR_RET(efd < 0);
......
...@@ -21,7 +21,7 @@ IP_LOCAL="192.168.99.1" ...@@ -21,7 +21,7 @@ IP_LOCAL="192.168.99.1"
PROG_SRC="test_lwt_bpf.c" PROG_SRC="test_lwt_bpf.c"
BPF_PROG="test_lwt_bpf.o" BPF_PROG="test_lwt_bpf.o"
TRACE_ROOT=/sys/kernel/debug/tracing TRACE_ROOT=/sys/kernel/tracing
CONTEXT_INFO=$(cat ${TRACE_ROOT}/trace_options | grep context) CONTEXT_INFO=$(cat ${TRACE_ROOT}/trace_options | grep context)
function lookup_mac() function lookup_mac()
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "vmlinux.h" #include "vmlinux.h"
#include <bpf/bpf_helpers.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 { struct task_rename {
__u64 pad; __u64 pad;
__u32 pid; __u32 pid;
...@@ -21,7 +21,7 @@ int prog(struct task_rename *ctx) ...@@ -21,7 +21,7 @@ int prog(struct task_rename *ctx)
return 0; return 0;
} }
/* from /sys/kernel/debug/tracing/events/fib/fib_table_lookup/format */ /* from /sys/kernel/tracing/events/fib/fib_table_lookup/format */
struct fib_table_lookup { struct fib_table_lookup {
__u64 pad; __u64 pad;
__u32 tb_id; __u32 tb_id;
......
...@@ -1647,17 +1647,17 @@ union bpf_attr { ...@@ -1647,17 +1647,17 @@ union bpf_attr {
* Description * Description
* This helper is a "printk()-like" facility for debugging. It * This helper is a "printk()-like" facility for debugging. It
* prints a message defined by format *fmt* (of size *fmt_size*) * 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** * available. It can take up to three additional **u64**
* arguments (as an eBPF helpers, the total number of arguments is * arguments (as an eBPF helpers, the total number of arguments is
* limited to five). * limited to five).
* *
* Each time the helper is called, it appends a line to the trace. * Each time the helper is called, it appends a line to the trace.
* Lines are discarded while *\/sys/kernel/debug/tracing/trace* is * Lines are discarded while *\/sys/kernel/tracing/trace* is
* open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this. * open, use *\/sys/kernel/tracing/trace_pipe* to avoid this.
* The format of the trace is customizable, and the exact output * The format of the trace is customizable, and the exact output
* one will get depends on the options set in * 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 * *README* file under the same directory). However, it usually
* defaults to something like: * defaults to something like:
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment