From: tangmeng <tangmeng@uniontech.com>
To: rostedt@goodmis.org, mingo@redhat.com, mcgrof@kernel.org,
keescook@chromium.org, yzaikin@google.com
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
nizhen@uniontech.com, zhanglianjie@uniontech.com,
nixiaoming@huawei.com, tangmeng <tangmeng@uniontech.com>
Subject: [PATCH 02/11] kernel/trace: move stack_tracer_enabled sysctl to its own file
Date: Sun, 20 Feb 2022 14:00:17 +0800 [thread overview]
Message-ID: <20220220060017.13285-1-tangmeng@uniontech.com> (raw)
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
next reply other threads:[~2022-02-20 6:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-20 6:00 tangmeng [this message]
2022-02-20 17:05 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220220060017.13285-1-tangmeng@uniontech.com \
--to=tangmeng@uniontech.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mingo@redhat.com \
--cc=nixiaoming@huawei.com \
--cc=nizhen@uniontech.com \
--cc=rostedt@goodmis.org \
--cc=yzaikin@google.com \
--cc=zhanglianjie@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®