diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst index 87cf5c010d5d..34a3b8401864 100644 --- a/Documentation/trace/ftrace.rst +++ b/Documentation/trace/ftrace.rst @@ -76,6 +76,9 @@ it:: All files located in the tracefs file system will be located in that debugfs file system directory as well. + In order to not automount tracefs in the debugfs filesystem, enable the + defconfig option CONFIG_TRACEFS_DISABLE_AUTOMOUNT. + .. attention:: Any selected ftrace option will also create the tracefs file system. diff --git a/arch/arm64/configs/gki_defconfig b/arch/arm64/configs/gki_defconfig index 3f3e4f255f98..4adc0b2ef8f7 100644 --- a/arch/arm64/configs/gki_defconfig +++ b/arch/arm64/configs/gki_defconfig @@ -648,6 +648,7 @@ CONFIG_SCHEDSTATS=y # CONFIG_DEBUG_PREEMPT is not set CONFIG_BUG_ON_DATA_CORRUPTION=y CONFIG_TRACE_MMIO_ACCESS=y +CONFIG_TRACEFS_DISABLE_AUTOMOUNT=y CONFIG_KUNIT=y CONFIG_KUNIT_DEBUGFS=y # CONFIG_RUNTIME_TESTING_MENU is not set diff --git a/arch/x86/configs/gki_defconfig b/arch/x86/configs/gki_defconfig index 79f33bf2c8a5..32f802569113 100644 --- a/arch/x86/configs/gki_defconfig +++ b/arch/x86/configs/gki_defconfig @@ -586,6 +586,7 @@ CONFIG_DETECT_HUNG_TASK=y CONFIG_WQ_WATCHDOG=y CONFIG_SCHEDSTATS=y CONFIG_BUG_ON_DATA_CORRUPTION=y +CONFIG_TRACEFS_DISABLE_AUTOMOUNT=y CONFIG_UNWINDER_FRAME_POINTER=y CONFIG_KUNIT=y CONFIG_KUNIT_DEBUGFS=y diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index d41d865eb7cb..3c0e969fc7c3 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -103,6 +103,11 @@ config PREEMPTIRQ_TRACEPOINTS Create preempt/irq toggle tracepoints if needed, so that other parts of the kernel can use them to generate or add hooks to them. +menuconfig TRACEFS_DISABLE_AUTOMOUNT + bool "Do not autmount tracefs in the debugfs filesystem" + help + Provides an option to not automount tracefs in /sys/kernel/debug/tracing. + # All tracer options should select GENERIC_TRACER. For those options that are # enabled by all tracers (context switch and event tracer) they select TRACING. # This allows those options to appear when no other tracer is selected. But the diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 6a4a754a6dfc..af1b1d4b3db9 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -9010,6 +9010,7 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer) ftrace_init_tracefs(tr, d_tracer); } +#ifndef CONFIG_TRACEFS_DISABLE_AUTOMOUNT static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore) { struct vfsmount *mnt; @@ -9031,6 +9032,7 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore) return mnt; } +#endif /** * tracing_init_dentry - initialize top level trace array @@ -9055,6 +9057,7 @@ int tracing_init_dentry(void) if (WARN_ON(!tracefs_initialized())) return -ENODEV; +#ifndef CONFIG_TRACEFS_DISABLE_AUTOMOUNT /* * As there may still be users that expect the tracing * files to exist in debugfs/tracing, we must automount @@ -9063,6 +9066,9 @@ int tracing_init_dentry(void) */ tr->dir = debugfs_create_automount("tracing", NULL, trace_automount, NULL); +#else + tr->dir = ERR_PTR(-ENODEV); +#endif return 0; }