mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 02/11] kernel/trace: move stack_tracer_enabled sysctl to its own file
@ 2022-02-20  6:00 tangmeng
  2022-02-20 17:05 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: tangmeng @ 2022-02-20  6:00 UTC (permalink / raw)
  To: rostedt, mingo, mcgrof, keescook, yzaikin
  Cc: linux-kernel, linux-fsdevel, nizhen, zhanglianjie, nixiaoming, tangmeng

kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to places
where they actually belong.  The proc sysctl maintainers do not want to
know what sysctl knobs you wish to add for your own piece of code, we
just care about the core logic.

All filesystem syctls now get reviewed by fs folks. This commit
follows the commit of fs, move the stack_tracer_enabled sysctl to its
own file, kernel/trace/trace_stack.c.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
---
 include/linux/ftrace.h     |  6 ------
 kernel/sysctl.c            |  9 ---------
 kernel/trace/trace_stack.c | 26 ++++++++++++++++++++++++--
 3 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 9999e29187de..cc6f7532e038 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -392,12 +392,6 @@ static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs,
 #endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */
 
 #ifdef CONFIG_STACK_TRACER
-
-extern int stack_tracer_enabled;
-
-int stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
-		       size_t *lenp, loff_t *ppos);
-
 /* DO NOT MODIFY THIS VARIABLE DIRECTLY! */
 DECLARE_PER_CPU(int, disable_stack_tracer);
 
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d11390634321..b41138d64e5e 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1755,15 +1755,6 @@ static struct ctl_table kern_table[] = {
 		.proc_handler	= ftrace_enable_sysctl,
 	},
 #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_TRACING
 	{
 		.procname	= "ftrace_dump_on_oops",
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 5a48dba912ea..b871499cf7e6 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)
 {
@@ -513,7 +513,8 @@ static const struct file_operations stack_trace_filter_fops = {
 
 #endif /* CONFIG_DYNAMIC_FTRACE */
 
-int
+#ifdef CONFIG_SYSCTL
+static int
 stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
 		   size_t *lenp, loff_t *ppos)
 {
@@ -537,6 +538,25 @@ stack_trace_sysctl(struct ctl_table *table, int write, void *buffer,
 	return ret;
 }
 
+static struct ctl_table kern_trace_stack_table[] = {
+	{
+		.procname       = "stack_tracer_enabled",
+		.data           = &stack_tracer_enabled,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = stack_trace_sysctl,
+	},
+	{ }
+};
+
+static void __init kernel_trace_stack_sysctls_init(void)
+{
+	register_sysctl_init("kernel", kern_trace_stack_table);
+}
+#else
+#define kernel_trace_stack_sysctls_init() do { } while (0)
+#endif /* CONFIG_SYSCTL */
+
 static char stack_trace_filter_buf[COMMAND_LINE_SIZE+1] __initdata;
 
 static __init int enable_stacktrace(char *str)
@@ -576,6 +596,8 @@ static __init int stack_trace_init(void)
 	if (stack_tracer_enabled)
 		register_ftrace_function(&trace_ops);
 
+	kernel_trace_stack_sysctls_init();
+
 	return 0;
 }
 
-- 
2.20.1




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

* Re: [PATCH 02/11] kernel/trace: move stack_tracer_enabled sysctl to its own file
  2022-02-20  6:00 [PATCH 02/11] kernel/trace: move stack_tracer_enabled sysctl to its own file tangmeng
@ 2022-02-20 17:05 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2022-02-20 17:05 UTC (permalink / raw)
  To: tangmeng
  Cc: mingo, mcgrof, keescook, yzaikin, linux-kernel, linux-fsdevel,
	nizhen, zhanglianjie, nixiaoming

On Sun, 20 Feb 2022 14:00:17 +0800
tangmeng <tangmeng@uniontech.com> wrote:

> kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
> dishes, this makes it very difficult to maintain.
> 
> To help with this maintenance let's start by moving sysctls to places
> where they actually belong.  The proc sysctl maintainers do not want to
> know what sysctl knobs you wish to add for your own piece of code, we
> just care about the core logic.
> 
> All filesystem syctls now get reviewed by fs folks. This commit
> follows the commit of fs, move the stack_tracer_enabled sysctl to its
> own file, kernel/trace/trace_stack.c.
> 
> Signed-off-by: tangmeng <tangmeng@uniontech.com>

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

-- Steve

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

end of thread, other threads:[~2022-02-20 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-20  6:00 [PATCH 02/11] kernel/trace: move stack_tracer_enabled sysctl to its own file tangmeng
2022-02-20 17:05 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®