sparclinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/5] sysctl: Move sysctls from kern_table into their respective subsystems
@ 2025-03-13 16:22 Joel Granados
  2025-03-13 16:22 ` [PATCH v3 1/5] panic: Move panic ctl tables into panic.c Joel Granados
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Joel Granados @ 2025-03-13 16:22 UTC (permalink / raw)
  To: Kees Cook, Joel Granados, Steven Rostedt, Masami Hiramatsu,
	Mark Rutland, Mathieu Desnoyers, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, sparclinux

This series relocates sysctl tables from kern_table to their respective
subsystems. To keep the scope manageable, this patchset focuses on
architecture-specific and core kernel sysctl tables. Further relocations
will follow once this series progresses.

By decentralizing sysctl registrations, subsystem maintainers regain
control over their sysctl interfaces, improving maintainability and
reducing the likelihood of merge conflicts. All this is made possible by
the work done to reduce the ctl_table memory footprint in commit
d7a76ec87195 ("sysctl: Remove check for sentinel element in ctl_table
arrays").

* Birds eye view of what has changed:
    - Archs: sparc
        arch/sparc/kernel/{Makefile,setup.c}
    - Kernel core:
        kernel/{panic.c,signal.c,trace/trace.c}
        kernel/events/{core.c,callchain.c}

* Testing was done by running sysctl selftests on x86_64 and 0-day.

Comments are greatly appreciated

Changes in v3:
- Removed s390 from the series as it is being upstreamed through s390
  tree. Adjusted the Cc and To to reflect this.
- made stack_tracer_enabled static
- Link to v2: https://lore.kernel.org/r/20250306-jag-mv_ctltables-v2-0-71b243c8d3f8@kernel.org

Changes in v2:
- Dropped the perf and x86 patches as they are making their way
  upstream. Removed relevant ppl from To: and Cc: mail header.
- "ftrace:..." -> "tracing:..." for patch 3
- Moved stac_tracer_enabled to trace_stack.c instead of trace.c
- s390: fixed typo and removed the CONFIG_SMP ifdefs
- Updated trailers
- Link to v1: https://lore.kernel.org/r/20250218-jag-mv_ctltables-v1-0-cd3698ab8d29@kernel.org

---
Signed-off-by: Joel Granados <joel.granados@kernel.org>

---
Joel Granados (5):
      panic: Move panic ctl tables into panic.c
      signal: Move signal ctl tables into signal.c
      tracing: Move trace sysctls into trace.c
      stack_tracer: move sysctl registration to kernel/trace/trace_stack.c
      sparc: mv sparc sysctls into their own file under arch/sparc/kernel

 arch/sparc/kernel/Makefile |   1 +
 arch/sparc/kernel/setup.c  |  46 +++++++++++++++++++
 include/linux/ftrace.h     |   9 ----
 kernel/panic.c             |  30 +++++++++++++
 kernel/signal.c            |  11 +++++
 kernel/sysctl.c            | 108 ---------------------------------------------
 kernel/trace/trace.c       |  36 ++++++++++++++-
 kernel/trace/trace_stack.c |  22 ++++++++-
 8 files changed, 144 insertions(+), 119 deletions(-)
---
base-commit: 0ad2507d5d93f39619fc42372c347d6006b64319
change-id: 20250217-jag-mv_ctltables-cf75e470e085

Best regards,
-- 
Joel Granados <joel.granados@kernel.org>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/5] panic: Move panic ctl tables into panic.c
  2025-03-13 16:22 [PATCH v3 0/5] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
@ 2025-03-13 16:22 ` Joel Granados
  2025-03-13 16:22 ` [PATCH v3 2/5] signal: Move signal ctl tables into signal.c Joel Granados
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Joel Granados @ 2025-03-13 16:22 UTC (permalink / raw)
  To: Kees Cook, Joel Granados, Steven Rostedt, Masami Hiramatsu,
	Mark Rutland, Mathieu Desnoyers, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, sparclinux

Move panic, panic_on_oops, panic_print, panic_on_warn into
kerne/panic.c. This is part of a greater effort to move ctl tables into
their respective subsystems which will reduce the merge conflicts in
kerenel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
 kernel/panic.c  | 30 ++++++++++++++++++++++++++++++
 kernel/sysctl.c | 31 -------------------------------
 2 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index d8635d5cecb2505da1c08a4f70814e9b87ac3b37..f9bf88f4c26216cd5a93754378a36ea1e841472a 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -96,6 +96,36 @@ static const struct ctl_table kern_panic_table[] = {
 		.extra2         = SYSCTL_ONE,
 	},
 #endif
+	{
+		.procname	= "panic",
+		.data		= &panic_timeout,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "panic_on_oops",
+		.data		= &panic_on_oops,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "panic_print",
+		.data		= &panic_print,
+		.maxlen		= sizeof(unsigned long),
+		.mode		= 0644,
+		.proc_handler	= proc_doulongvec_minmax,
+	},
+	{
+		.procname	= "panic_on_warn",
+		.data		= &panic_on_warn,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_ONE,
+	},
 	{
 		.procname       = "warn_limit",
 		.data           = &warn_limit,
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index cb57da499ebb1216cefb3705694ab62028fee03e..7759b1ed7221f588f49ec3d81b19aeb4d2fdf2f7 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -26,7 +26,6 @@
 #include <linux/sysctl.h>
 #include <linux/bitmap.h>
 #include <linux/signal.h>
-#include <linux/panic.h>
 #include <linux/printk.h>
 #include <linux/proc_fs.h>
 #include <linux/security.h>
@@ -1610,13 +1609,6 @@ int proc_do_static_key(const struct ctl_table *table, int write,
 }
 
 static const struct ctl_table kern_table[] = {
-	{
-		.procname	= "panic",
-		.data		= &panic_timeout,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
 #ifdef CONFIG_PROC_SYSCTL
 	{
 		.procname	= "tainted",
@@ -1803,20 +1795,6 @@ static const struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-	{
-		.procname	= "panic_on_oops",
-		.data		= &panic_on_oops,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "panic_print",
-		.data		= &panic_print,
-		.maxlen		= sizeof(unsigned long),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_minmax,
-	},
 	{
 		.procname	= "ngroups_max",
 		.data		= (void *)&ngroups_max,
@@ -1990,15 +1968,6 @@ static const struct ctl_table kern_table[] = {
 		.extra2		= SYSCTL_ONE_THOUSAND,
 	},
 #endif
-	{
-		.procname	= "panic_on_warn",
-		.data		= &panic_on_warn,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec_minmax,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_ONE,
-	},
 #ifdef CONFIG_TREE_RCU
 	{
 		.procname	= "panic_on_rcu_stall",

-- 
2.47.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/5] signal: Move signal ctl tables into signal.c
  2025-03-13 16:22 [PATCH v3 0/5] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
  2025-03-13 16:22 ` [PATCH v3 1/5] panic: Move panic ctl tables into panic.c Joel Granados
@ 2025-03-13 16:22 ` Joel Granados
  2025-03-13 16:22 ` [PATCH v3 3/5] tracing: Move trace sysctls into trace.c Joel Granados
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Joel Granados @ 2025-03-13 16:22 UTC (permalink / raw)
  To: Kees Cook, Joel Granados, Steven Rostedt, Masami Hiramatsu,
	Mark Rutland, Mathieu Desnoyers, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, sparclinux

Move print-fatal-signals into its own const ctl table array in
kernel/signal.c. This is part of a greater effort to move ctl tables
into their respective subsystems which will reduce the merge conflicts
in kerenel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
 kernel/signal.c | 11 +++++++++++
 kernel/sysctl.c |  8 --------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 875e97f6205a2c9daecf5bece5d53ed09667f747..347b74800f927f70a1912457f96e833cd03c642d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -4962,9 +4962,20 @@ static const struct ctl_table signal_debug_table[] = {
 #endif
 };
 
+static const struct ctl_table signal_table[] = {
+	{
+		.procname	= "print-fatal-signals",
+		.data		= &print_fatal_signals,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+};
+
 static int __init init_signal_sysctls(void)
 {
 	register_sysctl_init("debug", signal_debug_table);
+	register_sysctl_init("kernel", signal_table);
 	return 0;
 }
 early_initcall(init_signal_sysctls);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 7759b1ed7221f588f49ec3d81b19aeb4d2fdf2f7..6514c13800a453dd970ce60040ca8a791f831e17 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -25,7 +25,6 @@
 #include <linux/slab.h>
 #include <linux/sysctl.h>
 #include <linux/bitmap.h>
-#include <linux/signal.h>
 #include <linux/printk.h>
 #include <linux/proc_fs.h>
 #include <linux/security.h>
@@ -1626,13 +1625,6 @@ static const struct ctl_table kern_table[] = {
 		.extra2		= SYSCTL_ONE,
 	},
 #endif
-	{
-		.procname	= "print-fatal-signals",
-		.data		= &print_fatal_signals,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
 #ifdef CONFIG_SPARC
 	{
 		.procname	= "reboot-cmd",

-- 
2.47.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/5] tracing: Move trace sysctls into trace.c
  2025-03-13 16:22 [PATCH v3 0/5] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
  2025-03-13 16:22 ` [PATCH v3 1/5] panic: Move panic ctl tables into panic.c Joel Granados
  2025-03-13 16:22 ` [PATCH v3 2/5] signal: Move signal ctl tables into signal.c Joel Granados
@ 2025-03-13 16:22 ` Joel Granados
  2025-03-13 16:34   ` John Paul Adrian Glaubitz
  2025-03-13 16:22 ` [PATCH v3 4/5] stack_tracer: move sysctl registration to kernel/trace/trace_stack.c Joel Granados
  2025-03-13 16:22 ` [PATCH v3 5/5] sparc: mv sparc sysctls into their own file under arch/sparc/kernel Joel Granados
  4 siblings, 1 reply; 9+ messages in thread
From: Joel Granados @ 2025-03-13 16:22 UTC (permalink / raw)
  To: Kees Cook, Joel Granados, Steven Rostedt, Masami Hiramatsu,
	Mark Rutland, Mathieu Desnoyers, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, sparclinux

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
kerenel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/linux/ftrace.h |  7 -------
 kernel/sysctl.c        | 24 ------------------------
 kernel/trace/trace.c   | 36 +++++++++++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index fbabc3d848b375a114936b635bc695d59ab018a6..59774513ae456a5cc7c3bfe7f93a2189c0e3706e 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -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) { }
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 6514c13800a453dd970ce60040ca8a791f831e17..baa250e223a26bafc39cb7a7d7635b4f7f5dcf56 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -51,7 +51,6 @@
 #include <linux/nfs_fs.h>
 #include <linux/acpi.h>
 #include <linux/reboot.h>
-#include <linux/ftrace.h>
 #include <linux/perf_event.h>
 #include <linux/oom.h>
 #include <linux/kmod.h>
@@ -1684,29 +1683,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",
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 0e6d517e74e0fd19bfb31fcbcb977d57f894c78b..abfc0e56173b9da98236f83c715b155e5e952295 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -117,6 +117,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
  *
@@ -139,7 +140,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 */

-- 
2.47.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 4/5] stack_tracer: move sysctl registration to kernel/trace/trace_stack.c
  2025-03-13 16:22 [PATCH v3 0/5] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
                   ` (2 preceding siblings ...)
  2025-03-13 16:22 ` [PATCH v3 3/5] tracing: Move trace sysctls into trace.c Joel Granados
@ 2025-03-13 16:22 ` Joel Granados
  2025-03-22  9:12   ` Steven Rostedt
  2025-03-13 16:22 ` [PATCH v3 5/5] sparc: mv sparc sysctls into their own file under arch/sparc/kernel Joel Granados
  4 siblings, 1 reply; 9+ messages in thread
From: Joel Granados @ 2025-03-13 16:22 UTC (permalink / raw)
  To: Kees Cook, Joel Granados, Steven Rostedt, Masami Hiramatsu,
	Mark Rutland, Mathieu Desnoyers, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, sparclinux

Move stack_tracer_enabled into trace_stack_sysctl_table. This is part of
a greater effort to move ctl tables into their respective subsystems
which will reduce the merge conflicts in kerenel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
 include/linux/ftrace.h     |  2 --
 kernel/sysctl.c            | 10 ----------
 kernel/trace/trace_stack.c | 22 +++++++++++++++++++++-
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 59774513ae456a5cc7c3bfe7f93a2189c0e3706e..95851a6fb9429346e279739be0045827f486cbad 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -569,8 +569,6 @@ static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs,
 
 #ifdef CONFIG_STACK_TRACER
 
-extern int stack_tracer_enabled;
-
 int stack_trace_sysctl(const struct ctl_table *table, int write, void *buffer,
 		       size_t *lenp, loff_t *ppos);
 
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index baa250e223a26bafc39cb7a7d7635b4f7f5dcf56..dc3747cc72d470662879e4f2b7f2651505b7ca90 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -68,7 +68,6 @@
 
 #ifdef CONFIG_X86
 #include <asm/nmi.h>
-#include <asm/stacktrace.h>
 #include <asm/io.h>
 #endif
 #ifdef CONFIG_SPARC
@@ -1674,15 +1673,6 @@ static const struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-#ifdef CONFIG_STACK_TRACER
-	{
-		.procname	= "stack_tracer_enabled",
-		.data		= &stack_tracer_enabled,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= stack_trace_sysctl,
-	},
-#endif
 #ifdef CONFIG_MODULES
 	{
 		.procname	= "modprobe",
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 14c6f272c4d8a382070d45e1cf0ee97db38831c9..e34223c8065de544e603440827bcaa76e1894df2 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -32,7 +32,7 @@ static arch_spinlock_t stack_trace_max_lock =
 DEFINE_PER_CPU(int, disable_stack_tracer);
 static DEFINE_MUTEX(stack_sysctl_mutex);
 
-int stack_tracer_enabled;
+static int stack_tracer_enabled;
 
 static void print_max_stack(void)
 {
@@ -578,3 +578,23 @@ static __init int stack_trace_init(void)
 }
 
 device_initcall(stack_trace_init);
+
+
+static const struct ctl_table trace_stack_sysctl_table[] = {
+	{
+		.procname	= "stack_tracer_enabled",
+		.data		= &stack_tracer_enabled,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= stack_trace_sysctl,
+	},
+};
+
+static int __init init_trace_stack_sysctls(void)
+{
+	register_sysctl_init("kernel", trace_stack_sysctl_table);
+	return 0;
+}
+subsys_initcall(init_trace_stack_sysctls);
+
+

-- 
2.47.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 5/5] sparc: mv sparc sysctls into their own file under arch/sparc/kernel
  2025-03-13 16:22 [PATCH v3 0/5] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
                   ` (3 preceding siblings ...)
  2025-03-13 16:22 ` [PATCH v3 4/5] stack_tracer: move sysctl registration to kernel/trace/trace_stack.c Joel Granados
@ 2025-03-13 16:22 ` Joel Granados
  4 siblings, 0 replies; 9+ messages in thread
From: Joel Granados @ 2025-03-13 16:22 UTC (permalink / raw)
  To: Kees Cook, Joel Granados, Steven Rostedt, Masami Hiramatsu,
	Mark Rutland, Mathieu Desnoyers, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, sparclinux

Move sparc sysctls (reboot-cmd, stop-a, scons-poweroff and tsb-ratio)
into a new file (arch/sparc/kernel/setup.c). This file will be included
for both 32 and 64 bit sparc. Leave "tsb-ratio" under SPARC64 ifdef as
it was in kernel/sysctl.c. The sysctl table register is called with
arch_initcall placing it 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
kerenel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
 arch/sparc/kernel/Makefile |  1 +
 arch/sparc/kernel/setup.c  | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 kernel/sysctl.c            | 35 -----------------------------------
 3 files changed, 47 insertions(+), 35 deletions(-)

diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 58ea4ef9b622bd18f2160b34762c69b48f3de8c6..3453f330e363cffe430806cd00a32b06202088b3 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -35,6 +35,7 @@ obj-y                   += process.o
 obj-y                   += signal_$(BITS).o
 obj-y                   += sigutil_$(BITS).o
 obj-$(CONFIG_SPARC32)   += ioport.o
+obj-y                   += setup.o
 obj-y                   += setup_$(BITS).o
 obj-y                   += idprom.o
 obj-y                   += sys_sparc_$(BITS).o
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
new file mode 100644
index 0000000000000000000000000000000000000000..4975867d9001b63b25770334116f2038a561c28c
--- /dev/null
+++ b/arch/sparc/kernel/setup.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <asm/setup.h>
+#include <linux/sysctl.h>
+
+static const struct ctl_table sparc_sysctl_table[] = {
+	{
+		.procname	= "reboot-cmd",
+		.data		= reboot_command,
+		.maxlen		= 256,
+		.mode		= 0644,
+		.proc_handler	= proc_dostring,
+	},
+	{
+		.procname	= "stop-a",
+		.data		= &stop_a_enabled,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "scons-poweroff",
+		.data		= &scons_pwroff,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+#ifdef CONFIG_SPARC64
+	{
+		.procname	= "tsb-ratio",
+		.data		= &sysctl_tsb_ratio,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+#endif
+};
+
+
+static int __init init_sparc_sysctls(void)
+{
+	register_sysctl_init("kernel", sparc_sysctl_table);
+	return 0;
+}
+
+arch_initcall(init_sparc_sysctls);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index dc3747cc72d470662879e4f2b7f2651505b7ca90..0dc41eea1dbd34396c323118cfd0e3133c6993a1 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -70,9 +70,6 @@
 #include <asm/nmi.h>
 #include <asm/io.h>
 #endif
-#ifdef CONFIG_SPARC
-#include <asm/setup.h>
-#endif
 #ifdef CONFIG_RT_MUTEXES
 #include <linux/rtmutex.h>
 #endif
@@ -1623,38 +1620,6 @@ static const struct ctl_table kern_table[] = {
 		.extra2		= SYSCTL_ONE,
 	},
 #endif
-#ifdef CONFIG_SPARC
-	{
-		.procname	= "reboot-cmd",
-		.data		= reboot_command,
-		.maxlen		= 256,
-		.mode		= 0644,
-		.proc_handler	= proc_dostring,
-	},
-	{
-		.procname	= "stop-a",
-		.data		= &stop_a_enabled,
-		.maxlen		= sizeof (int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "scons-poweroff",
-		.data		= &scons_pwroff,
-		.maxlen		= sizeof (int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
-#ifdef CONFIG_SPARC64
-	{
-		.procname	= "tsb-ratio",
-		.data		= &sysctl_tsb_ratio,
-		.maxlen		= sizeof (int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
 #ifdef CONFIG_PARISC
 	{
 		.procname	= "soft-power",

-- 
2.47.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/5] tracing: Move trace sysctls into trace.c
  2025-03-13 16:22 ` [PATCH v3 3/5] tracing: Move trace sysctls into trace.c Joel Granados
@ 2025-03-13 16:34   ` John Paul Adrian Glaubitz
  2025-03-17 19:52     ` Joel Granados
  0 siblings, 1 reply; 9+ messages in thread
From: John Paul Adrian Glaubitz @ 2025-03-13 16:34 UTC (permalink / raw)
  To: Joel Granados, Kees Cook, Steven Rostedt, Masami Hiramatsu,
	Mark Rutland, Mathieu Desnoyers, David S. Miller, Andreas Larsson
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, sparclinux

Hi Joel,

On Thu, 2025-03-13 at 17:22 +0100, Joel Granados wrote:
> 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
> kerenel/sysctl.c.
  ^^^^^^^

Typo, exists in patches 4 and 5 of this series.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/5] tracing: Move trace sysctls into trace.c
  2025-03-13 16:34   ` John Paul Adrian Glaubitz
@ 2025-03-17 19:52     ` Joel Granados
  0 siblings, 0 replies; 9+ messages in thread
From: Joel Granados @ 2025-03-17 19:52 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, David S. Miller, Andreas Larsson, linux-kernel,
	linux-fsdevel, linux-trace-kernel, sparclinux

On Thu, Mar 13, 2025 at 05:34:38PM +0100, John Paul Adrian Glaubitz wrote:
> Hi Joel,
> 
> On Thu, 2025-03-13 at 17:22 +0100, Joel Granados wrote:
> > 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
> > kerenel/sysctl.c.
>   ^^^^^^^
fixed. thx. Will not send a V4 unless there is a bigger change to
review.

Best

-- 

Joel Granados

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 4/5] stack_tracer: move sysctl registration to kernel/trace/trace_stack.c
  2025-03-13 16:22 ` [PATCH v3 4/5] stack_tracer: move sysctl registration to kernel/trace/trace_stack.c Joel Granados
@ 2025-03-22  9:12   ` Steven Rostedt
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Rostedt @ 2025-03-22  9:12 UTC (permalink / raw)
  To: Joel Granados
  Cc: Kees Cook, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers,
	David S. Miller, Andreas Larsson, linux-kernel, linux-fsdevel,
	linux-trace-kernel, sparclinux

On Thu, 13 Mar 2025 17:22:26 +0100
Joel Granados <joel.granados@kernel.org> wrote:

> Move stack_tracer_enabled into trace_stack_sysctl_table. This is part of
> a greater effort to move ctl tables into their respective subsystems
> which will reduce the merge conflicts in kerenel/sysctl.c.
> 
> Signed-off-by: Joel Granados <joel.granados@kernel.org>
> ---
>  include/linux/ftrace.h     |  2 --
>  kernel/sysctl.c            | 10 ----------
>  kernel/trace/trace_stack.c | 22 +++++++++++++++++++++-
>  3 files changed, 21 insertions(+), 13 deletions(-)

Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-03-22  9:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13 16:22 [PATCH v3 0/5] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
2025-03-13 16:22 ` [PATCH v3 1/5] panic: Move panic ctl tables into panic.c Joel Granados
2025-03-13 16:22 ` [PATCH v3 2/5] signal: Move signal ctl tables into signal.c Joel Granados
2025-03-13 16:22 ` [PATCH v3 3/5] tracing: Move trace sysctls into trace.c Joel Granados
2025-03-13 16:34   ` John Paul Adrian Glaubitz
2025-03-17 19:52     ` Joel Granados
2025-03-13 16:22 ` [PATCH v3 4/5] stack_tracer: move sysctl registration to kernel/trace/trace_stack.c Joel Granados
2025-03-22  9:12   ` Steven Rostedt
2025-03-13 16:22 ` [PATCH v3 5/5] sparc: mv sparc sysctls into their own file under arch/sparc/kernel Joel Granados

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).