]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tracing: Move trace sysctls into trace.c
authorJoel Granados <joel.granados@kernel.org>
Sun, 29 Dec 2024 15:11:25 +0000 (16:11 +0100)
committerJoel Granados <joel.granados@kernel.org>
Wed, 9 Apr 2025 11:32:16 +0000 (13:32 +0200)
Move trace ctl tables into their own const array in
kernel/trace/trace.c. The sysctl table register is called with
subsys_initcall placing if after its original place in proc_root_init.
This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kernel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
include/linux/ftrace.h
kernel/sysctl.c
kernel/trace/trace.c

index fbabc3d848b375a114936b635bc695d59ab018a6..59774513ae456a5cc7c3bfe7f93a2189c0e3706e 100644 (file)
@@ -1298,16 +1298,9 @@ static inline void unpause_graph_tracing(void) { }
 #ifdef CONFIG_TRACING
 enum ftrace_dump_mode;
 
-#define MAX_TRACER_SIZE                100
-extern char ftrace_dump_on_oops[];
 extern int ftrace_dump_on_oops_enabled(void);
-extern int tracepoint_printk;
 
 extern void disable_trace_on_warning(void);
-extern int __disable_trace_on_warning;
-
-int tracepoint_printk_sysctl(const struct ctl_table *table, int write,
-                            void *buffer, size_t *lenp, loff_t *ppos);
 
 #else /* CONFIG_TRACING */
 static inline void  disable_trace_on_warning(void) { }
index 811c50072e03c9479a3e246573942469850a81d4..324ae43a3d50bb29bc1ab7b145339279c4db26b9 100644 (file)
@@ -44,7 +44,6 @@
 #include <linux/nfs_fs.h>
 #include <linux/acpi.h>
 #include <linux/reboot.h>
-#include <linux/ftrace.h>
 #include <linux/kmod.h>
 #include <linux/capability.h>
 #include <linux/binfmts.h>
@@ -1662,29 +1661,6 @@ static const struct ctl_table kern_table[] = {
                .proc_handler   = stack_trace_sysctl,
        },
 #endif
-#ifdef CONFIG_TRACING
-       {
-               .procname       = "ftrace_dump_on_oops",
-               .data           = &ftrace_dump_on_oops,
-               .maxlen         = MAX_TRACER_SIZE,
-               .mode           = 0644,
-               .proc_handler   = proc_dostring,
-       },
-       {
-               .procname       = "traceoff_on_warning",
-               .data           = &__disable_trace_on_warning,
-               .maxlen         = sizeof(__disable_trace_on_warning),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec,
-       },
-       {
-               .procname       = "tracepoint_printk",
-               .data           = &tracepoint_printk,
-               .maxlen         = sizeof(tracepoint_printk),
-               .mode           = 0644,
-               .proc_handler   = tracepoint_printk_sysctl,
-       },
-#endif
 #ifdef CONFIG_MODULES
        {
                .procname       = "modprobe",
index b581e388a9d9f71ffedc6522d426ebc85caa800a..bd9c30dd118350e5da087c01fd4ee3f9f93ebdfb 100644 (file)
@@ -120,6 +120,7 @@ static int tracing_disabled = 1;
 
 cpumask_var_t __read_mostly    tracing_buffer_mask;
 
+#define MAX_TRACER_SIZE                100
 /*
  * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
  *
@@ -142,7 +143,40 @@ cpumask_var_t __read_mostly        tracing_buffer_mask;
 char ftrace_dump_on_oops[MAX_TRACER_SIZE] = "0";
 
 /* When set, tracing will stop when a WARN*() is hit */
-int __disable_trace_on_warning;
+static int __disable_trace_on_warning;
+
+int tracepoint_printk_sysctl(const struct ctl_table *table, int write,
+                            void *buffer, size_t *lenp, loff_t *ppos);
+static const struct ctl_table trace_sysctl_table[] = {
+       {
+               .procname       = "ftrace_dump_on_oops",
+               .data           = &ftrace_dump_on_oops,
+               .maxlen         = MAX_TRACER_SIZE,
+               .mode           = 0644,
+               .proc_handler   = proc_dostring,
+       },
+       {
+               .procname       = "traceoff_on_warning",
+               .data           = &__disable_trace_on_warning,
+               .maxlen         = sizeof(__disable_trace_on_warning),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
+       {
+               .procname       = "tracepoint_printk",
+               .data           = &tracepoint_printk,
+               .maxlen         = sizeof(tracepoint_printk),
+               .mode           = 0644,
+               .proc_handler   = tracepoint_printk_sysctl,
+       },
+};
+
+static int __init init_trace_sysctls(void)
+{
+       register_sysctl_init("kernel", trace_sysctl_table);
+       return 0;
+}
+subsys_initcall(init_trace_sysctls);
 
 #ifdef CONFIG_TRACE_EVAL_MAP_FILE
 /* Map of enums to their values, for "eval_map" file */