History

tracing: Move trace sysctls into trace.c

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.

Joel Granados committed 1 year ago

Commit dd293df1 parent 256db5c3 files · +35 −32Browse files

Unified · Split

3 files
  1. include/linux/ftrace.h +0 −7
  2. kernel/sysctl.c +0 −24
  3. kernel/trace/trace.c +35 −1
include/linux/ftrace.h+0−7
@@ -1298,16 +1298,9 @@ static inline void unpause_graph_tracing(void) { } · 1297 unmodified lines
12981298 #ifdef CONFIG_TRACING
12991299 enum ftrace_dump_mode;
13001300
1301−#define MAX_TRACER_SIZE 100
1302−extern char ftrace_dump_on_oops[];
13031301 extern int ftrace_dump_on_oops_enabled(void);
1304−extern int tracepoint_printk;
13051302
13061303 extern void disable_trace_on_warning(void);
1307−extern int __disable_trace_on_warning;
1308−
1309−int tracepoint_printk_sysctl(const struct ctl_table *table, int write,
1310− void *buffer, size_t *lenp, loff_t *ppos);
13111304
13121305 #else /* CONFIG_TRACING */
13131306 static inline void disable_trace_on_warning(void) { }
kernel/sysctl.c+0−24
@@ -44,7 +44,6 @@ · 43 unmodified lines
4444 #include <linux/nfs_fs.h>
4545 #include <linux/acpi.h>
4646 #include <linux/reboot.h>
47−#include <linux/ftrace.h>
4847 #include <linux/kmod.h>
4948 #include <linux/capability.h>
5049 #include <linux/binfmts.h>
@@ -1662,29 +1661,6 @@ static const struct ctl_table kern_table[] = { · 1611 unmodified lines
16621661 .proc_handler = stack_trace_sysctl,
16631662 },
16641663 #endif
1665−#ifdef CONFIG_TRACING
1666− {
1667− .procname = "ftrace_dump_on_oops",
1668− .data = &ftrace_dump_on_oops,
1669− .maxlen = MAX_TRACER_SIZE,
1670− .mode = 0644,
1671− .proc_handler = proc_dostring,
1672− },
1673− {
1674− .procname = "traceoff_on_warning",
1675− .data = &__disable_trace_on_warning,
1676− .maxlen = sizeof(__disable_trace_on_warning),
1677− .mode = 0644,
1678− .proc_handler = proc_dointvec,
1679− },
1680− {
1681− .procname = "tracepoint_printk",
1682− .data = &tracepoint_printk,
1683− .maxlen = sizeof(tracepoint_printk),
1684− .mode = 0644,
1685− .proc_handler = tracepoint_printk_sysctl,
1686− },
1687−#endif
16881664 #ifdef CONFIG_MODULES
16891665 {
16901666 .procname = "modprobe",
kernel/trace/trace.c+35−1
@@ -120,6 +120,7 @@ static int tracing_disabled = 1; · 119 unmodified lines
120120
121121 cpumask_var_t __read_mostly tracing_buffer_mask;
122122
123+#define MAX_TRACER_SIZE 100
123124 /*
124125 * ftrace_dump_on_oops - variable to dump ftrace buffer on oops
125126 *
@@ -142,7 +143,40 @@ cpumask_var_t __read_mostly tracing_buffer_mask; · 16 unmodified lines
142143 char ftrace_dump_on_oops[MAX_TRACER_SIZE] = "0";
143144
144145 /* When set, tracing will stop when a WARN*() is hit */
145−int __disable_trace_on_warning;
146+static int __disable_trace_on_warning;
147+
148+int tracepoint_printk_sysctl(const struct ctl_table *table, int write,
149+ void *buffer, size_t *lenp, loff_t *ppos);
150+static const struct ctl_table trace_sysctl_table[] = {
151+ {
152+ .procname = "ftrace_dump_on_oops",
153+ .data = &ftrace_dump_on_oops,
154+ .maxlen = MAX_TRACER_SIZE,
155+ .mode = 0644,
156+ .proc_handler = proc_dostring,
157+ },
158+ {
159+ .procname = "traceoff_on_warning",
160+ .data = &__disable_trace_on_warning,
161+ .maxlen = sizeof(__disable_trace_on_warning),
162+ .mode = 0644,
163+ .proc_handler = proc_dointvec,
164+ },
165+ {
166+ .procname = "tracepoint_printk",
167+ .data = &tracepoint_printk,
168+ .maxlen = sizeof(tracepoint_printk),
169+ .mode = 0644,
170+ .proc_handler = tracepoint_printk_sysctl,
171+ },
172+};
173+
174+static int __init init_trace_sysctls(void)
175+{
176+ register_sysctl_init("kernel", trace_sysctl_table);
177+ return 0;
178+}
179+subsys_initcall(init_trace_sysctls);
146180
147181 #ifdef CONFIG_TRACE_EVAL_MAP_FILE
148182 /* Map of enums to their values, for "eval_map" file */