sparclinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems
@ 2025-02-18  9:56 Joel Granados
  2025-02-18  9:56 ` [PATCH 1/8] panic: Move panic ctl tables into panic.c Joel Granados
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Joel Granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

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, s390 and x86
        arch/s390/{lib/spinlock.c,mm/fault.c}
        arch/sparc/kernel/{Makefile,setup.c}
        arch/x86/include/asm/{setup.h,traps.h}
    - 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

Signed-off-by: Joel Granados <joel.granados@kernel.org>
---
Joel Granados (7):
      panic: Move panic ctl tables into panic.c
      signal: Move signal ctl tables into signal.c
      ftrace: Move trace sysctls into trace.c
      stack_tracer: move sysctl registration to kernel/trace/trace.c
      events: Move perf_event sysctls into kernel/events
      sparc: mv sparc sysctls into their own file under arch/sparc/kernel
      x86: Move sysctls into arch/x86

joel granados (1):
      s390: mv s390 sysctls into their own file under arch/s390 dir

 arch/s390/lib/spinlock.c     |  23 ++++
 arch/s390/mm/fault.c         |  17 +++
 arch/sparc/kernel/Makefile   |   1 +
 arch/sparc/kernel/setup.c    |  46 ++++++++
 arch/x86/include/asm/setup.h |   1 +
 arch/x86/include/asm/traps.h |   2 -
 arch/x86/kernel/setup.c      |  66 ++++++++++++
 include/linux/acpi.h         |   1 -
 include/linux/ftrace.h       |   7 --
 include/linux/perf_event.h   |   9 --
 kernel/events/callchain.c    |  38 +++++--
 kernel/events/core.c         |  57 ++++++++--
 kernel/panic.c               |  30 ++++++
 kernel/signal.c              |  11 ++
 kernel/sysctl.c              | 250 -------------------------------------------
 kernel/trace/trace.c         |  45 +++++++-
 16 files changed, 322 insertions(+), 282 deletions(-)
---
base-commit: 0ad2507d5d93f39619fc42372c347d6006b64319
change-id: 20250217-jag-mv_ctltables-cf75e470e085

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



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

* [PATCH 1/8] panic: Move panic ctl tables into panic.c
  2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
@ 2025-02-18  9:56 ` Joel Granados
  2025-02-18  9:56 ` [PATCH 2/8] signal: Move signal ctl tables into signal.c Joel Granados
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Joel Granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

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 d8635d5cecb2..f9bf88f4c262 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 cb57da499ebb..7759b1ed7221 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.44.2



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

* [PATCH 2/8] signal: Move signal ctl tables into signal.c
  2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
  2025-02-18  9:56 ` [PATCH 1/8] panic: Move panic ctl tables into panic.c Joel Granados
@ 2025-02-18  9:56 ` Joel Granados
  2025-02-18  9:56 ` [PATCH 3/8] ftrace: Move trace sysctls into trace.c Joel Granados
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Joel Granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

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 875e97f6205a..347b74800f92 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 7759b1ed7221..6514c13800a4 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.44.2



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

* [PATCH 3/8] ftrace: Move trace sysctls into trace.c
  2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
  2025-02-18  9:56 ` [PATCH 1/8] panic: Move panic ctl tables into panic.c Joel Granados
  2025-02-18  9:56 ` [PATCH 2/8] signal: Move signal ctl tables into signal.c Joel Granados
@ 2025-02-18  9:56 ` Joel Granados
  2025-03-04  1:44   ` Steven Rostedt
  2025-02-18  9:56 ` [PATCH 4/8] stack_tracer: move sysctl registration to kernel/trace/trace.c Joel Granados
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Joel Granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

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>
---
 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 fbabc3d848b3..59774513ae45 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 6514c13800a4..baa250e223a2 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 0e6d517e74e0..abfc0e56173b 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.44.2



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

* [PATCH 4/8] stack_tracer: move sysctl registration to kernel/trace/trace.c
  2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
                   ` (2 preceding siblings ...)
  2025-02-18  9:56 ` [PATCH 3/8] ftrace: Move trace sysctls into trace.c Joel Granados
@ 2025-02-18  9:56 ` Joel Granados
  2025-03-04  1:47   ` Steven Rostedt
  2025-02-18  9:56 ` [PATCH 5/8] events: Move perf_event sysctls into kernel/events Joel Granados
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Joel Granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

Squash with ftrace:
Move stac_tracer_enabled into trace_sysctl_table while keeping the
CONFIG_STACK_TRACER ifdef. 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/sysctl.c      | 10 ----------
 kernel/trace/trace.c |  9 +++++++++
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index baa250e223a2..dc3747cc72d4 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.c b/kernel/trace/trace.c
index abfc0e56173b..17b449f9e330 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -166,6 +166,15 @@ static const struct ctl_table trace_sysctl_table[] = {
 		.mode		= 0644,
 		.proc_handler	= tracepoint_printk_sysctl,
 	},
+#ifdef CONFIG_STACK_TRACER
+	{
+		.procname	= "stack_tracer_enabled",
+		.data		= &stack_tracer_enabled,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= stack_trace_sysctl,
+	},
+#endif
 };
 
 static int __init init_trace_sysctls(void)

-- 
2.44.2



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

* [PATCH 5/8] events: Move perf_event sysctls into kernel/events
  2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
                   ` (3 preceding siblings ...)
  2025-02-18  9:56 ` [PATCH 4/8] stack_tracer: move sysctl registration to kernel/trace/trace.c Joel Granados
@ 2025-02-18  9:56 ` Joel Granados
  2025-02-18 10:35   ` Peter Zijlstra
  2025-02-18  9:56 ` [PATCH 6/8] sparc: mv sparc sysctls into their own file under arch/sparc/kernel Joel Granados
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Joel Granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

Move ctl tables to two files:
* perf_event_{paranoid,mlock_kb,max_sample_rate} and
  perf_cpu_time_max_percent into kernel/events/core.c
* perf_event_max_{stack,context_per_stack} into
  kernel/events/callchain.c

Make static variables and functions that are fully contained in core.c
and callchain.cand remove them from include/linux/perf_event.h.
Additionally six_hundred_forty_kb is moved to callchain.c.

Two new sysctl tables are added ({callchain,events_core}_sysctl_table)
with their respective sysctl registration functions.

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/perf_event.h |  9 -------
 kernel/events/callchain.c  | 38 ++++++++++++++++++++++-----
 kernel/events/core.c       | 57 ++++++++++++++++++++++++++++++++++++-----
 kernel/sysctl.c            | 64 ----------------------------------------------
 4 files changed, 83 insertions(+), 85 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 8333f132f4a9..a92ade5d62be 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1646,19 +1646,10 @@ static inline int perf_callchain_store(struct perf_callchain_entry_ctx *ctx, u64
 }
 
 extern int sysctl_perf_event_paranoid;
-extern int sysctl_perf_event_mlock;
 extern int sysctl_perf_event_sample_rate;
-extern int sysctl_perf_cpu_time_max_percent;
 
 extern void perf_sample_event_took(u64 sample_len_ns);
 
-int perf_event_max_sample_rate_handler(const struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos);
-int perf_cpu_time_max_percent_handler(const struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos);
-int perf_event_max_stack_handler(const struct ctl_table *table, int write,
-		void *buffer, size_t *lenp, loff_t *ppos);
-
 /* Access to perf_event_open(2) syscall. */
 #define PERF_SECURITY_OPEN		0
 
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 8a47e52a454f..6c83ad674d01 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -22,6 +22,7 @@ struct callchain_cpus_entries {
 
 int sysctl_perf_event_max_stack __read_mostly = PERF_MAX_STACK_DEPTH;
 int sysctl_perf_event_max_contexts_per_stack __read_mostly = PERF_MAX_CONTEXTS_PER_STACK;
+static const int six_hundred_forty_kb = 640 * 1024;
 
 static inline size_t perf_callchain_entry__sizeof(void)
 {
@@ -266,12 +267,8 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
 	return entry;
 }
 
-/*
- * Used for sysctl_perf_event_max_stack and
- * sysctl_perf_event_max_contexts_per_stack.
- */
-int perf_event_max_stack_handler(const struct ctl_table *table, int write,
-				 void *buffer, size_t *lenp, loff_t *ppos)
+static int perf_event_max_stack_handler(const struct ctl_table *table, int write,
+					void *buffer, size_t *lenp, loff_t *ppos)
 {
 	int *value = table->data;
 	int new_value = *value, ret;
@@ -292,3 +289,32 @@ int perf_event_max_stack_handler(const struct ctl_table *table, int write,
 
 	return ret;
 }
+
+static const struct ctl_table callchain_sysctl_table[] = {
+	{
+		.procname	= "perf_event_max_stack",
+		.data		= &sysctl_perf_event_max_stack,
+		.maxlen		= sizeof(sysctl_perf_event_max_stack),
+		.mode		= 0644,
+		.proc_handler	= perf_event_max_stack_handler,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= (void *)&six_hundred_forty_kb,
+	},
+	{
+		.procname	= "perf_event_max_contexts_per_stack",
+		.data		= &sysctl_perf_event_max_contexts_per_stack,
+		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
+		.mode		= 0644,
+		.proc_handler	= perf_event_max_stack_handler,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_ONE_THOUSAND,
+	},
+};
+
+static int __init init_callchain_sysctls(void)
+{
+	register_sysctl_init("kernel", callchain_sysctl_table);
+	return 0;
+}
+core_initcall(init_callchain_sysctls);
+
diff --git a/kernel/events/core.c b/kernel/events/core.c
index bcb09e011e9e..3c3d95312c28 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -452,8 +452,8 @@ static struct kmem_cache *perf_event_cache;
  */
 int sysctl_perf_event_paranoid __read_mostly = 2;
 
-/* Minimum for 512 kiB + 1 user control page */
-int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
+/* Minimum for 512 kiB + 1 user control page. 'free' kiB per user. */
+static int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024);
 
 /*
  * max perf event sample rate
@@ -463,6 +463,7 @@ int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free'
 #define DEFAULT_CPU_TIME_MAX_PERCENT	25
 
 int sysctl_perf_event_sample_rate __read_mostly	= DEFAULT_MAX_SAMPLE_RATE;
+static int sysctl_perf_cpu_time_max_percent __read_mostly = DEFAULT_CPU_TIME_MAX_PERCENT;
 
 static int max_samples_per_tick __read_mostly	= DIV_ROUND_UP(DEFAULT_MAX_SAMPLE_RATE, HZ);
 static int perf_sample_period_ns __read_mostly	= DEFAULT_SAMPLE_PERIOD_NS;
@@ -484,7 +485,7 @@ static void update_perf_cpu_limits(void)
 
 static bool perf_rotate_context(struct perf_cpu_pmu_context *cpc);
 
-int perf_event_max_sample_rate_handler(const struct ctl_table *table, int write,
+static int perf_event_max_sample_rate_handler(const struct ctl_table *table, int write,
 				       void *buffer, size_t *lenp, loff_t *ppos)
 {
 	int ret;
@@ -506,9 +507,7 @@ int perf_event_max_sample_rate_handler(const struct ctl_table *table, int write,
 	return 0;
 }
 
-int sysctl_perf_cpu_time_max_percent __read_mostly = DEFAULT_CPU_TIME_MAX_PERCENT;
-
-int perf_cpu_time_max_percent_handler(const struct ctl_table *table, int write,
+static int perf_cpu_time_max_percent_handler(const struct ctl_table *table, int write,
 		void *buffer, size_t *lenp, loff_t *ppos)
 {
 	int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
@@ -528,6 +527,52 @@ int perf_cpu_time_max_percent_handler(const struct ctl_table *table, int write,
 	return 0;
 }
 
+static const struct ctl_table events_core_sysctl_table[] = {
+	/*
+	 * User-space relies on this file as a feature check for
+	 * perf_events being enabled. It's an ABI, do not remove!
+	 */
+	{
+		.procname	= "perf_event_paranoid",
+		.data		= &sysctl_perf_event_paranoid,
+		.maxlen		= sizeof(sysctl_perf_event_paranoid),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "perf_event_mlock_kb",
+		.data		= &sysctl_perf_event_mlock,
+		.maxlen		= sizeof(sysctl_perf_event_mlock),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "perf_event_max_sample_rate",
+		.data		= &sysctl_perf_event_sample_rate,
+		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
+		.mode		= 0644,
+		.proc_handler	= perf_event_max_sample_rate_handler,
+		.extra1		= SYSCTL_ONE,
+	},
+	{
+		.procname	= "perf_cpu_time_max_percent",
+		.data		= &sysctl_perf_cpu_time_max_percent,
+		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
+		.mode		= 0644,
+		.proc_handler	= perf_cpu_time_max_percent_handler,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_ONE_HUNDRED,
+	},
+};
+
+static int __init init_events_core_sysctls(void)
+{
+	register_sysctl_init("kernel", events_core_sysctl_table);
+	return 0;
+}
+core_initcall(init_events_core_sysctls);
+
+
 /*
  * perf samples are done in some very critical code paths (NMIs).
  * If they take too much CPU time, the system can lock up and not
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index dc3747cc72d4..fdc92d80e841 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/perf_event.h>
 #include <linux/oom.h>
 #include <linux/kmod.h>
 #include <linux/capability.h>
@@ -87,12 +86,6 @@ EXPORT_SYMBOL_GPL(sysctl_long_vals);
 #if defined(CONFIG_SYSCTL)
 
 /* Constants used for minimum and maximum */
-
-#ifdef CONFIG_PERF_EVENTS
-static const int six_hundred_forty_kb = 640 * 1024;
-#endif
-
-
 static const int ngroups_max = NGROUPS_MAX;
 static const int cap_last_cap = CAP_LAST_CAP;
 
@@ -1869,63 +1862,6 @@ static const struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-#ifdef CONFIG_PERF_EVENTS
-	/*
-	 * User-space scripts rely on the existence of this file
-	 * as a feature check for perf_events being enabled.
-	 *
-	 * So it's an ABI, do not remove!
-	 */
-	{
-		.procname	= "perf_event_paranoid",
-		.data		= &sysctl_perf_event_paranoid,
-		.maxlen		= sizeof(sysctl_perf_event_paranoid),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "perf_event_mlock_kb",
-		.data		= &sysctl_perf_event_mlock,
-		.maxlen		= sizeof(sysctl_perf_event_mlock),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "perf_event_max_sample_rate",
-		.data		= &sysctl_perf_event_sample_rate,
-		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
-		.mode		= 0644,
-		.proc_handler	= perf_event_max_sample_rate_handler,
-		.extra1		= SYSCTL_ONE,
-	},
-	{
-		.procname	= "perf_cpu_time_max_percent",
-		.data		= &sysctl_perf_cpu_time_max_percent,
-		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
-		.mode		= 0644,
-		.proc_handler	= perf_cpu_time_max_percent_handler,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_ONE_HUNDRED,
-	},
-	{
-		.procname	= "perf_event_max_stack",
-		.data		= &sysctl_perf_event_max_stack,
-		.maxlen		= sizeof(sysctl_perf_event_max_stack),
-		.mode		= 0644,
-		.proc_handler	= perf_event_max_stack_handler,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= (void *)&six_hundred_forty_kb,
-	},
-	{
-		.procname	= "perf_event_max_contexts_per_stack",
-		.data		= &sysctl_perf_event_max_contexts_per_stack,
-		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
-		.mode		= 0644,
-		.proc_handler	= perf_event_max_stack_handler,
-		.extra1		= SYSCTL_ZERO,
-		.extra2		= SYSCTL_ONE_THOUSAND,
-	},
-#endif
 #ifdef CONFIG_TREE_RCU
 	{
 		.procname	= "panic_on_rcu_stall",

-- 
2.44.2



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

* [PATCH 6/8] sparc: mv sparc sysctls into their own file under arch/sparc/kernel
  2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
                   ` (4 preceding siblings ...)
  2025-02-18  9:56 ` [PATCH 5/8] events: Move perf_event sysctls into kernel/events Joel Granados
@ 2025-02-18  9:56 ` Joel Granados
  2025-02-18  9:56 ` [PATCH 7/8] s390: mv s390 sysctls into their own file under arch/s390 dir joel granados
  2025-02-18  9:56 ` [PATCH 8/8] x86: Move sysctls into arch/x86 Joel Granados
  7 siblings, 0 replies; 16+ messages in thread
From: Joel Granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

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 58ea4ef9b622..3453f330e363 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 000000000000..4975867d9001
--- /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 fdc92d80e841..b63d53e592d8 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -69,9 +69,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
@@ -1616,38 +1613,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.44.2



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

* [PATCH 7/8] s390: mv s390 sysctls into their own file under arch/s390 dir
  2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
                   ` (5 preceding siblings ...)
  2025-02-18  9:56 ` [PATCH 6/8] sparc: mv sparc sysctls into their own file under arch/sparc/kernel Joel Granados
@ 2025-02-18  9:56 ` joel granados
  2025-02-18 14:08   ` Heiko Carstens
  2025-02-18  9:56 ` [PATCH 8/8] x86: Move sysctls into arch/x86 Joel Granados
  7 siblings, 1 reply; 16+ messages in thread
From: joel granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

Move s390 sysctls (spin_retry and userprocess_debug) into their own
files under arch/s390. We create two new sysctl tables
(2390_{fault,spin}_sysctl_table) which will be initialized with
arch_initcall placing them after their 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/s390/lib/spinlock.c | 23 +++++++++++++++++++++++
 arch/s390/mm/fault.c     | 17 +++++++++++++++++
 kernel/sysctl.c          | 18 ------------------
 3 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c
index a81a01c44927..4483fdc9d472 100644
--- a/arch/s390/lib/spinlock.c
+++ b/arch/s390/lib/spinlock.c
@@ -17,6 +17,10 @@
 #include <asm/alternative.h>
 #include <asm/asm.h>
 
+#if defined(CONFIG_SMP)
+#include <linux/sysctl.h>
+#endif
+
 int spin_retry = -1;
 
 static int __init spin_retry_init(void)
@@ -37,6 +41,25 @@ static int __init spin_retry_setup(char *str)
 }
 __setup("spin_retry=", spin_retry_setup);
 
+#if defined(CONFIG_SMP)
+static const struct ctl_table s390_spin_sysctl_table[] = {
+	{
+		.procname	= "spin_retry",
+		.data		= &spin_retry,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+};
+
+static int __init init_s390_spin_sysctls(void)
+{
+	register_sysctl_init("kernel", s390_spin_sysctl_table);
+	return 0;
+}
+arch_initcall(init_s390_spin_sysctls);
+#endif
+
 struct spin_wait {
 	struct spin_wait *next, *prev;
 	int node_id;
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 9b681f74dccc..507da355bf68 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -175,6 +175,23 @@ static void dump_fault_info(struct pt_regs *regs)
 
 int show_unhandled_signals = 1;
 
+static const struct ctl_table s390_fault_sysctl_table[] = {
+	{
+		.procname	= "userprocess_debug",
+		.data		= &show_unhandled_signals,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+};
+
+static int __init init_s390_fault_sysctls(void)
+{
+	register_sysctl_init("kernel", s390_fault_sysctl_table);
+	return 0;
+}
+arch_initcall(init_s390_fault_sysctls);
+
 void report_user_fault(struct pt_regs *regs, long signr, int is_mm_fault)
 {
 	static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index b63d53e592d8..7f505f9ace87 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1702,15 +1702,6 @@ static const struct ctl_table kern_table[] = {
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_MAXOLDUID,
 	},
-#ifdef CONFIG_S390
-	{
-		.procname	= "userprocess_debug",
-		.data		= &show_unhandled_signals,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
 	{
 		.procname	= "ngroups_max",
 		.data		= (void *)&ngroups_max,
@@ -1791,15 +1782,6 @@ static const struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-#if defined(CONFIG_S390) && defined(CONFIG_SMP)
-	{
-		.procname	= "spin_retry",
-		.data		= &spin_retry,
-		.maxlen		= sizeof (int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
 #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
 	{
 		.procname	= "acpi_video_flags",

-- 
2.44.2



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

* [PATCH 8/8] x86: Move sysctls into arch/x86
  2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
                   ` (6 preceding siblings ...)
  2025-02-18  9:56 ` [PATCH 7/8] s390: mv s390 sysctls into their own file under arch/s390 dir joel granados
@ 2025-02-18  9:56 ` Joel Granados
  7 siblings, 0 replies; 16+ messages in thread
From: Joel Granados @ 2025-02-18  9:56 UTC (permalink / raw)
  To: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-fsdevel, linux-trace-kernel, linux-perf-users,
	sparclinux, linux-s390, linux-acpi, Joel Granados

Move the following sysctl tables into arch/x86/kernel/setup.c:
panic_on_{unrecoverable_nmi,io_nmi}, bootloader_{type,version},
io_delay_type, unknown_nmi_panic, acpi_realmode_flags.

Variables moved from include/linux to arch/x86/include/asm because there
is no longer need for them outside arch/x86/kernel: acpi_realmode_flags,
panic_on_{unrecoverable_nmi,io_nmi}.

Include asm/nmi.h in arch/s86/kernel/setup.h in order to bring in
panic_on_{io_nmi,unrecovered_nmi}

Remove the asm/{nmi.h,io.h} includes from sysctl.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>
---
 arch/x86/include/asm/setup.h |  1 +
 arch/x86/include/asm/traps.h |  2 --
 arch/x86/kernel/setup.c      | 66 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/acpi.h         |  1 -
 kernel/sysctl.c              | 60 ----------------------------------------
 5 files changed, 67 insertions(+), 63 deletions(-)

diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index 85f4fde3515c..a8d676bba5de 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -46,6 +46,7 @@ void setup_bios_corruption_check(void);
 void early_platform_quirks(void);
 
 extern unsigned long saved_video_mode;
+extern unsigned long acpi_realmode_flags;
 
 extern void reserve_standard_io_resources(void);
 extern void i386_reserve_resources(void);
diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
index 1f1deaecd364..869b88061801 100644
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -35,8 +35,6 @@ static inline int get_si_code(unsigned long condition)
 		return TRAP_BRKPT;
 }
 
-extern int panic_on_unrecovered_nmi;
-
 void math_emulate(struct math_emu_info *);
 
 bool fault_in_kernel_space(unsigned long address);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index cebee310e200..9f8ff3aad4f4 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -56,6 +56,9 @@
 #include <asm/unwind.h>
 #include <asm/vsyscall.h>
 #include <linux/vmalloc.h>
+#if defined(CONFIG_X86_LOCAL_APIC)
+#include <asm/nmi.h>
+#endif
 
 /*
  * max_low_pfn_mapped: highest directly mapped pfn < 4 GB
@@ -146,6 +149,69 @@ static size_t ima_kexec_buffer_size;
 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
 int bootloader_type, bootloader_version;
 
+static const struct ctl_table x86_sysctl_table[] = {
+	{
+		.procname	= "panic_on_unrecovered_nmi",
+		.data		= &panic_on_unrecovered_nmi,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "panic_on_io_nmi",
+		.data		= &panic_on_io_nmi,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "bootloader_type",
+		.data		= &bootloader_type,
+		.maxlen		= sizeof(int),
+		.mode		= 0444,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "bootloader_version",
+		.data		= &bootloader_version,
+		.maxlen		= sizeof(int),
+		.mode		= 0444,
+		.proc_handler	= proc_dointvec,
+	},
+	{
+		.procname	= "io_delay_type",
+		.data		= &io_delay_type,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+#if defined(CONFIG_X86_LOCAL_APIC)
+	{
+		.procname       = "unknown_nmi_panic",
+		.data           = &unknown_nmi_panic,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = proc_dointvec,
+	},
+#endif
+#if defined(CONFIG_ACPI_SLEEP)
+	{
+		.procname	= "acpi_video_flags",
+		.data		= &acpi_realmode_flags,
+		.maxlen		= sizeof(unsigned long),
+		.mode		= 0644,
+		.proc_handler	= proc_doulongvec_minmax,
+	},
+#endif
+};
+
+static int __init init_x86_sysctl(void)
+{
+	register_sysctl_init("kernel", x86_sysctl_table);
+	return 0;
+}
+arch_initcall(init_x86_sysctl);
+
 /*
  * Setup options
  */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 4e495b29c640..a70e62d69dc7 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -330,7 +330,6 @@ static inline bool acpi_sci_irq_valid(void)
 }
 
 extern int sbf_port;
-extern unsigned long acpi_realmode_flags;
 
 int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity);
 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 7f505f9ace87..bf098028ba68 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -65,10 +65,6 @@
 #include <linux/uaccess.h>
 #include <asm/processor.h>
 
-#ifdef CONFIG_X86
-#include <asm/nmi.h>
-#include <asm/io.h>
-#endif
 #ifdef CONFIG_RT_MUTEXES
 #include <linux/rtmutex.h>
 #endif
@@ -1716,16 +1712,6 @@ static const struct ctl_table kern_table[] = {
 		.mode		= 0444,
 		.proc_handler	= proc_dointvec,
 	},
-#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
-	{
-		.procname       = "unknown_nmi_panic",
-		.data           = &unknown_nmi_panic,
-		.maxlen         = sizeof (int),
-		.mode           = 0644,
-		.proc_handler   = proc_dointvec,
-	},
-#endif
-
 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
 	defined(CONFIG_DEBUG_STACKOVERFLOW)
 	{
@@ -1736,43 +1722,6 @@ static const struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-#if defined(CONFIG_X86)
-	{
-		.procname	= "panic_on_unrecovered_nmi",
-		.data		= &panic_on_unrecovered_nmi,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "panic_on_io_nmi",
-		.data		= &panic_on_io_nmi,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "bootloader_type",
-		.data		= &bootloader_type,
-		.maxlen		= sizeof (int),
-		.mode		= 0444,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "bootloader_version",
-		.data		= &bootloader_version,
-		.maxlen		= sizeof (int),
-		.mode		= 0444,
-		.proc_handler	= proc_dointvec,
-	},
-	{
-		.procname	= "io_delay_type",
-		.data		= &io_delay_type,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-#endif
 #if defined(CONFIG_MMU)
 	{
 		.procname	= "randomize_va_space",
@@ -1782,15 +1731,6 @@ static const struct ctl_table kern_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-#if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
-	{
-		.procname	= "acpi_video_flags",
-		.data		= &acpi_realmode_flags,
-		.maxlen		= sizeof (unsigned long),
-		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_minmax,
-	},
-#endif
 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
 	{
 		.procname	= "ignore-unaligned-usertrap",

-- 
2.44.2



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

* Re: [PATCH 5/8] events: Move perf_event sysctls into kernel/events
  2025-02-18  9:56 ` [PATCH 5/8] events: Move perf_event sysctls into kernel/events Joel Granados
@ 2025-02-18 10:35   ` Peter Zijlstra
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Zijlstra @ 2025-02-18 10:35 UTC (permalink / raw)
  To: Joel Granados
  Cc: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Liang, Kan, David S. Miller, Andreas Larsson,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, linux-kernel,
	linux-fsdevel, linux-trace-kernel, linux-perf-users, sparclinux,
	linux-s390, linux-acpi

On Tue, Feb 18, 2025 at 10:56:21AM +0100, Joel Granados wrote:
> Move ctl tables to two files:
> * perf_event_{paranoid,mlock_kb,max_sample_rate} and
>   perf_cpu_time_max_percent into kernel/events/core.c
> * perf_event_max_{stack,context_per_stack} into
>   kernel/events/callchain.c
> 
> Make static variables and functions that are fully contained in core.c
> and callchain.cand remove them from include/linux/perf_event.h.
> Additionally six_hundred_forty_kb is moved to callchain.c.
> 
> Two new sysctl tables are added ({callchain,events_core}_sysctl_table)
> with their respective sysctl registration functions.
> 
> 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: Peter Zijlstra (Intel) <peterz@infradead.org>

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

* Re: [PATCH 7/8] s390: mv s390 sysctls into their own file under arch/s390 dir
  2025-02-18  9:56 ` [PATCH 7/8] s390: mv s390 sysctls into their own file under arch/s390 dir joel granados
@ 2025-02-18 14:08   ` Heiko Carstens
  2025-02-21  7:59     ` Joel Granados
  0 siblings, 1 reply; 16+ messages in thread
From: Heiko Carstens @ 2025-02-18 14:08 UTC (permalink / raw)
  To: joel granados
  Cc: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, linux-kernel,
	linux-fsdevel, linux-trace-kernel, linux-perf-users, sparclinux,
	linux-s390, linux-acpi

On Tue, Feb 18, 2025 at 10:56:23AM +0100, joel granados wrote:
> Move s390 sysctls (spin_retry and userprocess_debug) into their own
> files under arch/s390. We create two new sysctl tables
> (2390_{fault,spin}_sysctl_table) which will be initialized with
> arch_initcall placing them after their 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

> diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c
> index a81a01c44927..4483fdc9d472 100644
> --- a/arch/s390/lib/spinlock.c
> +++ b/arch/s390/lib/spinlock.c
> @@ -17,6 +17,10 @@
>  #include <asm/alternative.h>
>  #include <asm/asm.h>
>  
> +#if defined(CONFIG_SMP)
> +#include <linux/sysctl.h>
> +#endif
> +
...
> +#if defined(CONFIG_SMP)
> +static const struct ctl_table s390_spin_sysctl_table[] = {
> +	{
> +		.procname	= "spin_retry",
> +		.data		= &spin_retry,
> +		.maxlen		= sizeof(int),
> +		.mode		= 0644,
> +		.proc_handler	= proc_dointvec,
> +	},
> +};
> +
> +static int __init init_s390_spin_sysctls(void)
> +{
> +	register_sysctl_init("kernel", s390_spin_sysctl_table);
> +	return 0;
> +}
> +arch_initcall(init_s390_spin_sysctls);
> +#endif

I see that you want to keep the existing CONFIG_SMP behaviour, but since a
long time s390 enforces CONFIG_SMP=y (this was obviously never reflected in
kernel/sysctl.c).
Therefore the above ifdefs should be removed, and in addition the include
statement should be added to the other linux includes at the top of the file.

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

* Re: [PATCH 7/8] s390: mv s390 sysctls into their own file under arch/s390 dir
  2025-02-18 14:08   ` Heiko Carstens
@ 2025-02-21  7:59     ` Joel Granados
  0 siblings, 0 replies; 16+ messages in thread
From: Joel Granados @ 2025-02-21  7:59 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Kees Cook, Steven Rostedt, Masami Hiramatsu, Mark Rutland,
	Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Alexander Shishkin,
	Jiri Olsa, Ian Rogers, Adrian Hunter, Liang, Kan, David S. Miller,
	Andreas Larsson, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, linux-kernel,
	linux-fsdevel, linux-trace-kernel, linux-perf-users, sparclinux,
	linux-s390, linux-acpi

On Tue, Feb 18, 2025 at 03:08:21PM +0100, Heiko Carstens wrote:
> On Tue, Feb 18, 2025 at 10:56:23AM +0100, joel granados wrote:
> > Move s390 sysctls (spin_retry and userprocess_debug) into their own
> > files under arch/s390. We create two new sysctl tables
> > (2390_{fault,spin}_sysctl_table) which will be initialized with
> > arch_initcall placing them after their 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
Fixed

> 
> > diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c
> > index a81a01c44927..4483fdc9d472 100644
> > --- a/arch/s390/lib/spinlock.c
> > +++ b/arch/s390/lib/spinlock.c
> > @@ -17,6 +17,10 @@
> >  #include <asm/alternative.h>
> >  #include <asm/asm.h>
> >  
> > +#if defined(CONFIG_SMP)
> > +#include <linux/sysctl.h>
> > +#endif
> > +
> ...
> > +#if defined(CONFIG_SMP)
> > +static const struct ctl_table s390_spin_sysctl_table[] = {
> > +	{
> > +		.procname	= "spin_retry",
> > +		.data		= &spin_retry,
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= proc_dointvec,
> > +	},
> > +};
> > +
> > +static int __init init_s390_spin_sysctls(void)
> > +{
> > +	register_sysctl_init("kernel", s390_spin_sysctl_table);
> > +	return 0;
> > +}
> > +arch_initcall(init_s390_spin_sysctls);
> > +#endif
> 
> I see that you want to keep the existing CONFIG_SMP behaviour, but since a
> long time s390 enforces CONFIG_SMP=y (this was obviously never reflected in
> kernel/sysctl.c).
> Therefore the above ifdefs should be removed, and in addition the include
> statement should be added to the other linux includes at the top of the file.
I'll add these changes to my V2

Thx for the review

-- 

Joel Granados

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

* Re: [PATCH 3/8] ftrace: Move trace sysctls into trace.c
  2025-02-18  9:56 ` [PATCH 3/8] ftrace: Move trace sysctls into trace.c Joel Granados
@ 2025-03-04  1:44   ` Steven Rostedt
  2025-03-06 10:15     ` Joel Granados
  0 siblings, 1 reply; 16+ messages in thread
From: Steven Rostedt @ 2025-03-04  1:44 UTC (permalink / raw)
  To: Joel Granados
  Cc: Kees Cook, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Liang, Kan, David S. Miller, Andreas Larsson,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, linux-kernel,
	linux-fsdevel, linux-trace-kernel, linux-perf-users, sparclinux,
	linux-s390, linux-acpi

On Tue, 18 Feb 2025 10:56:19 +0100
Joel Granados <joel.granados@kernel.org> wrote:

Nit, change the subject to:

  tracing: Move trace sysctls into trace.c

as I try to only have the "ftrace:" label for modifications that affect
attaching to functions, and "tracing:" for everything else.

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

-- Steve


> 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>
> ---
>  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 fbabc3d848b3..59774513ae45 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 6514c13800a4..baa250e223a2 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 0e6d517e74e0..abfc0e56173b 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 */
> 


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

* Re: [PATCH 4/8] stack_tracer: move sysctl registration to kernel/trace/trace.c
  2025-02-18  9:56 ` [PATCH 4/8] stack_tracer: move sysctl registration to kernel/trace/trace.c Joel Granados
@ 2025-03-04  1:47   ` Steven Rostedt
  2025-03-06 10:37     ` Joel Granados
  0 siblings, 1 reply; 16+ messages in thread
From: Steven Rostedt @ 2025-03-04  1:47 UTC (permalink / raw)
  To: Joel Granados
  Cc: Kees Cook, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Liang, Kan, David S. Miller, Andreas Larsson,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, linux-kernel,
	linux-fsdevel, linux-trace-kernel, linux-perf-users, sparclinux,
	linux-s390, linux-acpi

On Tue, 18 Feb 2025 10:56:20 +0100
Joel Granados <joel.granados@kernel.org> wrote:

> Squash with ftrace:
> Move stac_tracer_enabled into trace_sysctl_table while keeping the
> CONFIG_STACK_TRACER ifdef. 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/sysctl.c      | 10 ----------
>  kernel/trace/trace.c |  9 +++++++++
>  2 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index baa250e223a2..dc3747cc72d4 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.c b/kernel/trace/trace.c
> index abfc0e56173b..17b449f9e330 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c

This should go into kernel/trace/trace_stack.c, and remove the #ifdef.

-- Steve

> @@ -166,6 +166,15 @@ static const struct ctl_table trace_sysctl_table[] = {
>  		.mode		= 0644,
>  		.proc_handler	= tracepoint_printk_sysctl,
>  	},
> +#ifdef CONFIG_STACK_TRACER
> +	{
> +		.procname	= "stack_tracer_enabled",
> +		.data		= &stack_tracer_enabled,
> +		.maxlen		= sizeof(int),
> +		.mode		= 0644,
> +		.proc_handler	= stack_trace_sysctl,
> +	},
> +#endif
>  };
>  
>  static int __init init_trace_sysctls(void)
> 


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

* Re: [PATCH 3/8] ftrace: Move trace sysctls into trace.c
  2025-03-04  1:44   ` Steven Rostedt
@ 2025-03-06 10:15     ` Joel Granados
  0 siblings, 0 replies; 16+ messages in thread
From: Joel Granados @ 2025-03-06 10:15 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Kees Cook, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Liang, Kan, David S. Miller, Andreas Larsson,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, linux-kernel,
	linux-fsdevel, linux-trace-kernel, linux-perf-users, sparclinux,
	linux-s390, linux-acpi

On Mon, Mar 03, 2025 at 08:44:55PM -0500, Steven Rostedt wrote:
> On Tue, 18 Feb 2025 10:56:19 +0100
> Joel Granados <joel.granados@kernel.org> wrote:
> 
> Nit, change the subject to:
> 
>   tracing: Move trace sysctls into trace.c
Done. Thx for the feedback 

Best
> 
> as I try to only have the "ftrace:" label for modifications that affect
> attaching to functions, and "tracing:" for everything else.
> 
> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> 
> -- Steve
> 
> 
> > 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>
> > ---
...
> > +	},
> > +};
> > +
> > +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 */
> > 
> 

-- 

Joel Granados

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

* Re: [PATCH 4/8] stack_tracer: move sysctl registration to kernel/trace/trace.c
  2025-03-04  1:47   ` Steven Rostedt
@ 2025-03-06 10:37     ` Joel Granados
  0 siblings, 0 replies; 16+ messages in thread
From: Joel Granados @ 2025-03-06 10:37 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Kees Cook, Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers,
	Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Liang, Kan, David S. Miller, Andreas Larsson,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Gerald Schaefer,
	Thomas Gleixner, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Rafael J. Wysocki, Len Brown, linux-kernel,
	linux-fsdevel, linux-trace-kernel, linux-perf-users, sparclinux,
	linux-s390, linux-acpi

On Mon, Mar 03, 2025 at 08:47:32PM -0500, Steven Rostedt wrote:
> On Tue, 18 Feb 2025 10:56:20 +0100
> Joel Granados <joel.granados@kernel.org> wrote:
> 
> > Squash with ftrace:
I'll also fix this little marker that I missed. And I'll not squash it,
as it is now going into trace_stack.c

> > Move stac_tracer_enabled into trace_sysctl_table while keeping the
> > CONFIG_STACK_TRACER ifdef. This is part of a greater effort to move ctl
I'll remove these comments from the commit message

> > 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/sysctl.c      | 10 ----------
> >  kernel/trace/trace.c |  9 +++++++++
> >  2 files changed, 9 insertions(+), 10 deletions(-)
> > 
> > diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> > index baa250e223a2..dc3747cc72d4 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.c b/kernel/trace/trace.c
> > index abfc0e56173b..17b449f9e330 100644
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> 
> This should go into kernel/trace/trace_stack.c, and remove the #ifdef.
Will send my V2 shortly with this modification.
> 
> -- Steve
> 
> > @@ -166,6 +166,15 @@ static const struct ctl_table trace_sysctl_table[] = {
> >  		.mode		= 0644,
> >  		.proc_handler	= tracepoint_printk_sysctl,
> >  	},
> > +#ifdef CONFIG_STACK_TRACER
> > +	{
> > +		.procname	= "stack_tracer_enabled",
> > +		.data		= &stack_tracer_enabled,
> > +		.maxlen		= sizeof(int),
> > +		.mode		= 0644,
> > +		.proc_handler	= stack_trace_sysctl,
> > +	},
> > +#endif
> >  };
> >  
> >  static int __init init_trace_sysctls(void)
> > 
> 

Thx for the review

Best

-- 

Joel Granados

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

end of thread, other threads:[~2025-03-06 10:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-18  9:56 [PATCH 0/8] sysctl: Move sysctls from kern_table into their respective subsystems Joel Granados
2025-02-18  9:56 ` [PATCH 1/8] panic: Move panic ctl tables into panic.c Joel Granados
2025-02-18  9:56 ` [PATCH 2/8] signal: Move signal ctl tables into signal.c Joel Granados
2025-02-18  9:56 ` [PATCH 3/8] ftrace: Move trace sysctls into trace.c Joel Granados
2025-03-04  1:44   ` Steven Rostedt
2025-03-06 10:15     ` Joel Granados
2025-02-18  9:56 ` [PATCH 4/8] stack_tracer: move sysctl registration to kernel/trace/trace.c Joel Granados
2025-03-04  1:47   ` Steven Rostedt
2025-03-06 10:37     ` Joel Granados
2025-02-18  9:56 ` [PATCH 5/8] events: Move perf_event sysctls into kernel/events Joel Granados
2025-02-18 10:35   ` Peter Zijlstra
2025-02-18  9:56 ` [PATCH 6/8] sparc: mv sparc sysctls into their own file under arch/sparc/kernel Joel Granados
2025-02-18  9:56 ` [PATCH 7/8] s390: mv s390 sysctls into their own file under arch/s390 dir joel granados
2025-02-18 14:08   ` Heiko Carstens
2025-02-21  7:59     ` Joel Granados
2025-02-18  9:56 ` [PATCH 8/8] x86: Move sysctls into arch/x86 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).