Skip to content

Commit 9ba817f

Browse files
committed
tracing: Deprecate auto-mounting tracefs in debugfs
In January 2015, tracefs was created to allow access to the tracing infrastructure without needing to compile in debugfs. When tracefs is configured, the directory /sys/kernel/tracing will exist and tooling is expected to use that path to access the tracing infrastructure. To allow backward compatibility, when debugfs is mounted, it would automount tracefs in its "tracing" directory so that tooling that had hard coded /sys/kernel/debug/tracing would still work. It has been over 10 years since the new interface was introduced, and all tooling should now be using it. Start the process of deprecating the old path so that it doesn't need to be maintained anymore. A new config is added to allow distributions to disable automounting of tracefs on debugfs. If /sys/kernel/debug/tracing is accessed, a pr_warn() will trigger stating: "NOTICE: Automounting of tracing to debugfs is deprecated and will be removed in 2030" Expect to remove this feature in 5 years (2030). Cc: <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Al Viro <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Jan Kara <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Ian Rogers <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 502ffa4 commit 9ba817f

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
What: /sys/kernel/debug/tracing
2+
Date: May 2008
3+
KernelVersion: 2.6.27
4+
5+
Description:
6+
7+
The ftrace was first added to the kernel, its interface was placed
8+
into the debugfs file system under the "tracing" directory. Access
9+
to the files were in /sys/kernel/debug/tracing. As systems wanted
10+
access to the tracing interface without having to enable debugfs, a
11+
new interface was created called "tracefs". This was a stand alone
12+
file system and was usually mounted in /sys/kernel/tracing.
13+
14+
To allow older tooling to continue to operate, when mounting
15+
debugfs, the tracefs file system would automatically get mounted in
16+
the "tracing" directory of debugfs. The tracefs interface was added
17+
in January 2015 in the v4.1 kernel.
18+
19+
All tooling should now be using tracefs directly and the "tracing"
20+
directory in debugfs should be removed by January 2030.

kernel/trace/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,19 @@ menuconfig FTRACE
199199

200200
if FTRACE
201201

202+
config TRACEFS_AUTOMOUNT_DEPRECATED
203+
bool "Automount tracefs on debugfs [DEPRECATED]"
204+
depends on TRACING
205+
default y
206+
help
207+
The tracing interface was moved from /sys/kernel/debug/tracing
208+
to /sys/kernel/tracing in 2015, but the tracing file system
209+
was still automounted in /sys/kernel/debug for backward
210+
compatibility with tooling.
211+
212+
The new interface has been around for more than 10 years and
213+
the old debug mount will soon be removed.
214+
202215
config BOOTTIME_TRACING
203216
bool "Boot-time Tracing support"
204217
depends on TRACING

kernel/trace/trace.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6296,7 +6296,7 @@ static bool tracer_options_updated;
62966296
static void add_tracer_options(struct trace_array *tr, struct tracer *t)
62976297
{
62986298
/* Only enable if the directory has been created already. */
6299-
if (!tr->dir)
6299+
if (!tr->dir && !(tr->flags & TRACE_ARRAY_FL_GLOBAL))
63006300
return;
63016301

63026302
/* Only create trace option files after update_tracer_options finish */
@@ -8977,13 +8977,13 @@ static inline __init int register_snapshot_cmd(void) { return 0; }
89778977

89788978
static struct dentry *tracing_get_dentry(struct trace_array *tr)
89798979
{
8980-
if (WARN_ON(!tr->dir))
8981-
return ERR_PTR(-ENODEV);
8982-
89838980
/* Top directory uses NULL as the parent */
89848981
if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
89858982
return NULL;
89868983

8984+
if (WARN_ON(!tr->dir))
8985+
return ERR_PTR(-ENODEV);
8986+
89878987
/* All sub buffers have a descriptor */
89888988
return tr->dir;
89898989
}
@@ -10249,6 +10249,7 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
1024910249
ftrace_init_tracefs(tr, d_tracer);
1025010250
}
1025110251

10252+
#ifdef CONFIG_TRACEFS_AUTOMOUNT_DEPRECATED
1025210253
static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
1025310254
{
1025410255
struct vfsmount *mnt;
@@ -10270,6 +10271,8 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
1027010271
if (IS_ERR(fc))
1027110272
return ERR_CAST(fc);
1027210273

10274+
pr_warn("NOTICE: Automounting of tracing to debugfs is deprecated and will be removed in 2030\n");
10275+
1027310276
ret = vfs_parse_fs_string(fc, "source",
1027410277
"tracefs", strlen("tracefs"));
1027510278
if (!ret)
@@ -10280,6 +10283,7 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
1028010283
put_fs_context(fc);
1028110284
return mnt;
1028210285
}
10286+
#endif
1028310287

1028410288
/**
1028510289
* tracing_init_dentry - initialize top level trace array
@@ -10304,6 +10308,7 @@ int tracing_init_dentry(void)
1030410308
if (WARN_ON(!tracefs_initialized()))
1030510309
return -ENODEV;
1030610310

10311+
#ifdef CONFIG_TRACEFS_AUTOMOUNT_DEPRECATED
1030710312
/*
1030810313
* As there may still be users that expect the tracing
1030910314
* files to exist in debugfs/tracing, we must automount
@@ -10312,6 +10317,7 @@ int tracing_init_dentry(void)
1031210317
*/
1031310318
tr->dir = debugfs_create_automount("tracing", NULL,
1031410319
trace_automount, NULL);
10320+
#endif
1031510321

1031610322
return 0;
1031710323
}

0 commit comments

Comments
 (0)