summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliaohua <liaohua4@huawei.com>2022-04-07 09:29:48 +0200
committerLuis Chamberlain <mcgrof@kernel.org>2022-04-21 20:40:59 +0200
commit988f11e046401f8561c4afefa506a50f0203de40 (patch)
treea692772598b543025cc940cfe402f9cee1f43839
parentftrace: fix building with SYSCTL=n but DYNAMIC_FTRACE=y (diff)
downloadlinux-988f11e046401f8561c4afefa506a50f0203de40.tar.xz
linux-988f11e046401f8561c4afefa506a50f0203de40.zip
latencytop: move sysctl to its own file
This moves latencytop sysctl to kernel/latencytop.c Signed-off-by: liaohua <liaohua4@huawei.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
-rw-r--r--include/linux/latencytop.h3
-rw-r--r--kernel/latencytop.c41
-rw-r--r--kernel/sysctl.c10
3 files changed, 29 insertions, 25 deletions
diff --git a/include/linux/latencytop.h b/include/linux/latencytop.h
index abe3d95f795b..84f1053cf2a8 100644
--- a/include/linux/latencytop.h
+++ b/include/linux/latencytop.h
@@ -38,9 +38,6 @@ account_scheduler_latency(struct task_struct *task, int usecs, int inter)
void clear_tsk_latency_tracing(struct task_struct *p);
-int sysctl_latencytop(struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos);
-
#else
static inline void
diff --git a/kernel/latencytop.c b/kernel/latencytop.c
index 166d7bf49666..76166df011a4 100644
--- a/kernel/latencytop.c
+++ b/kernel/latencytop.c
@@ -55,6 +55,7 @@
#include <linux/sched/stat.h>
#include <linux/list.h>
#include <linux/stacktrace.h>
+#include <linux/sysctl.h>
static DEFINE_RAW_SPINLOCK(latency_lock);
@@ -63,6 +64,31 @@ static struct latency_record latency_record[MAXLR];
int latencytop_enabled;
+#ifdef CONFIG_SYSCTL
+static int sysctl_latencytop(struct ctl_table *table, int write, void *buffer,
+ size_t *lenp, loff_t *ppos)
+{
+ int err;
+
+ err = proc_dointvec(table, write, buffer, lenp, ppos);
+ if (latencytop_enabled)
+ force_schedstat_enabled();
+
+ return err;
+}
+
+static struct ctl_table latencytop_sysctl[] = {
+ {
+ .procname = "latencytop",
+ .data = &latencytop_enabled,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = sysctl_latencytop,
+ },
+ {}
+};
+#endif
+
void clear_tsk_latency_tracing(struct task_struct *p)
{
unsigned long flags;
@@ -266,18 +292,9 @@ static const struct proc_ops lstats_proc_ops = {
static int __init init_lstats_procfs(void)
{
proc_create("latency_stats", 0644, NULL, &lstats_proc_ops);
+#ifdef CONFIG_SYSCTL
+ register_sysctl_init("kernel", latencytop_sysctl);
+#endif
return 0;
}
-
-int sysctl_latencytop(struct ctl_table *table, int write, void *buffer,
- size_t *lenp, loff_t *ppos)
-{
- int err;
-
- err = proc_dointvec(table, write, buffer, lenp, ppos);
- if (latencytop_enabled)
- force_schedstat_enabled();
-
- return err;
-}
device_initcall(init_lstats_procfs);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c0fdf465a93d..b60345cbadf0 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -64,7 +64,6 @@
#include <linux/kexec.h>
#include <linux/mount.h>
#include <linux/userfaultfd_k.h>
-#include <linux/latencytop.h>
#include <linux/pid.h>
#include "../lib/kstrtox.h"
@@ -1624,15 +1623,6 @@ static struct ctl_table kern_table[] = {
.extra2 = SYSCTL_ONE,
},
#endif
-#ifdef CONFIG_LATENCYTOP
- {
- .procname = "latencytop",
- .data = &latencytop_enabled,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = sysctl_latencytop,
- },
-#endif
{
.procname = "print-fatal-signals",
.data = &print_fatal_signals,