Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <zwisler@google.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20230313205628.1058720-2-zwisler@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Ross Zwisler and committed by
Alexei Starovoitov
27d7fdf0 9e36a204

+21 -21
+4 -4
include/uapi/linux/bpf.h
··· 1647 1647 * Description 1648 1648 * This helper is a "printk()-like" facility for debugging. It 1649 1649 * prints a message defined by format *fmt* (of size *fmt_size*) 1650 - * to file *\/sys/kernel/debug/tracing/trace* from DebugFS, if 1650 + * to file *\/sys/kernel/tracing/trace* from TraceFS, if 1651 1651 * available. It can take up to three additional **u64** 1652 1652 * arguments (as an eBPF helpers, the total number of arguments is 1653 1653 * limited to five). 1654 1654 * 1655 1655 * Each time the helper is called, it appends a line to the trace. 1656 - * Lines are discarded while *\/sys/kernel/debug/tracing/trace* is 1657 - * open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this. 1656 + * Lines are discarded while *\/sys/kernel/tracing/trace* is 1657 + * open, use *\/sys/kernel/tracing/trace_pipe* to avoid this. 1658 1658 * The format of the trace is customizable, and the exact output 1659 1659 * one will get depends on the options set in 1660 - * *\/sys/kernel/debug/tracing/trace_options* (see also the 1660 + * *\/sys/kernel/tracing/trace_options* (see also the 1661 1661 * *README* file under the same directory). However, it usually 1662 1662 * defaults to something like: 1663 1663 *
+2 -2
samples/bpf/cpustat_kern.c
··· 76 76 77 77 /* 78 78 * The trace events for cpu_idle and cpu_frequency are taken from: 79 - * /sys/kernel/debug/tracing/events/power/cpu_idle/format 80 - * /sys/kernel/debug/tracing/events/power/cpu_frequency/format 79 + * /sys/kernel/tracing/events/power/cpu_idle/format 80 + * /sys/kernel/tracing/events/power/cpu_frequency/format 81 81 * 82 82 * These two events have same format, so define one common structure. 83 83 */
+2 -2
samples/bpf/hbm.c
··· 65 65 static void read_trace_pipe2(void); 66 66 static void do_error(char *msg, bool errno_flag); 67 67 68 - #define DEBUGFS "/sys/kernel/debug/tracing/" 68 + #define TRACEFS "/sys/kernel/tracing/" 69 69 70 70 static struct bpf_program *bpf_prog; 71 71 static struct bpf_object *obj; ··· 77 77 FILE *outf; 78 78 char *outFname = "hbm_out.log"; 79 79 80 - trace_fd = open(DEBUGFS "trace_pipe", O_RDONLY, 0); 80 + trace_fd = open(TRACEFS "trace_pipe", O_RDONLY, 0); 81 81 if (trace_fd < 0) { 82 82 printf("Error opening trace_pipe\n"); 83 83 return;
+2 -2
samples/bpf/ibumad_kern.c
··· 39 39 /* Taken from the current format defined in 40 40 * include/trace/events/ib_umad.h 41 41 * and 42 - * /sys/kernel/debug/tracing/events/ib_umad/ib_umad_read/format 43 - * /sys/kernel/debug/tracing/events/ib_umad/ib_umad_write/format 42 + * /sys/kernel/tracing/events/ib_umad/ib_umad_read/format 43 + * /sys/kernel/tracing/events/ib_umad/ib_umad_write/format 44 44 */ 45 45 struct ib_umad_rw_args { 46 46 u64 pad;
+1 -1
samples/bpf/lwt_len_hist.sh
··· 5 5 VETH0=tst_lwt1a 6 6 VETH1=tst_lwt1b 7 7 BPF_PROG=lwt_len_hist.bpf.o 8 - TRACE_ROOT=/sys/kernel/debug/tracing 8 + TRACE_ROOT=/sys/kernel/tracing 9 9 10 10 function cleanup { 11 11 # To reset saved histogram, remove pinned map
+1 -1
samples/bpf/offwaketime_kern.c
··· 110 110 } 111 111 112 112 #if 1 113 - /* taken from /sys/kernel/debug/tracing/events/sched/sched_switch/format */ 113 + /* taken from /sys/kernel/tracing/events/sched/sched_switch/format */ 114 114 struct sched_switch_args { 115 115 unsigned long long pad; 116 116 char prev_comm[TASK_COMM_LEN];
+2 -2
samples/bpf/task_fd_query_user.c
··· 235 235 struct bpf_link *link; 236 236 ssize_t bytes; 237 237 238 - snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events", 238 + snprintf(buf, sizeof(buf), "/sys/kernel/tracing/%s_events", 239 239 event_type); 240 240 kfd = open(buf, O_WRONLY | O_TRUNC, 0); 241 241 CHECK_PERROR_RET(kfd < 0); ··· 252 252 close(kfd); 253 253 kfd = -1; 254 254 255 - snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/events/%ss/%s/id", 255 + snprintf(buf, sizeof(buf), "/sys/kernel/tracing/events/%ss/%s/id", 256 256 event_type, event_alias); 257 257 efd = open(buf, O_RDONLY, 0); 258 258 CHECK_PERROR_RET(efd < 0);
+1 -1
samples/bpf/test_lwt_bpf.sh
··· 21 21 22 22 PROG_SRC="test_lwt_bpf.c" 23 23 BPF_PROG="test_lwt_bpf.o" 24 - TRACE_ROOT=/sys/kernel/debug/tracing 24 + TRACE_ROOT=/sys/kernel/tracing 25 25 CONTEXT_INFO=$(cat ${TRACE_ROOT}/trace_options | grep context) 26 26 27 27 function lookup_mac()
+2 -2
samples/bpf/test_overhead_tp.bpf.c
··· 7 7 #include "vmlinux.h" 8 8 #include <bpf/bpf_helpers.h> 9 9 10 - /* from /sys/kernel/debug/tracing/events/task/task_rename/format */ 10 + /* from /sys/kernel/tracing/events/task/task_rename/format */ 11 11 struct task_rename { 12 12 __u64 pad; 13 13 __u32 pid; ··· 21 21 return 0; 22 22 } 23 23 24 - /* from /sys/kernel/debug/tracing/events/fib/fib_table_lookup/format */ 24 + /* from /sys/kernel/tracing/events/fib/fib_table_lookup/format */ 25 25 struct fib_table_lookup { 26 26 __u64 pad; 27 27 __u32 tb_id;
+4 -4
tools/include/uapi/linux/bpf.h
··· 1647 1647 * Description 1648 1648 * This helper is a "printk()-like" facility for debugging. It 1649 1649 * prints a message defined by format *fmt* (of size *fmt_size*) 1650 - * to file *\/sys/kernel/debug/tracing/trace* from DebugFS, if 1650 + * to file *\/sys/kernel/tracing/trace* from TraceFS, if 1651 1651 * available. It can take up to three additional **u64** 1652 1652 * arguments (as an eBPF helpers, the total number of arguments is 1653 1653 * limited to five). 1654 1654 * 1655 1655 * Each time the helper is called, it appends a line to the trace. 1656 - * Lines are discarded while *\/sys/kernel/debug/tracing/trace* is 1657 - * open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this. 1656 + * Lines are discarded while *\/sys/kernel/tracing/trace* is 1657 + * open, use *\/sys/kernel/tracing/trace_pipe* to avoid this. 1658 1658 * The format of the trace is customizable, and the exact output 1659 1659 * one will get depends on the options set in 1660 - * *\/sys/kernel/debug/tracing/trace_options* (see also the 1660 + * *\/sys/kernel/tracing/trace_options* (see also the 1661 1661 * *README* file under the same directory). However, it usually 1662 1662 * defaults to something like: 1663 1663 *