linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH sysctl-next v2] latencytop: move sysctl to its own file
@ 2022-02-23  9:47 Liao Hua
  2022-04-06 22:39 ` Luis Chamberlain
  0 siblings, 1 reply; 2+ messages in thread
From: Liao Hua @ 2022-02-23  9:47 UTC (permalink / raw)
  To: mcgrof, keescook, yzaikin, nixiaoming
  Cc: linux-kernel, linux-fsdevel, wangfangpeng1

From: liaohua <liaohua4@huawei.com>

This moves latencytop sysctl to kernel/latencytop.c

Signed-off-by: liaohua <liaohua4@huawei.com>

------
v2:
 Move latencytop sysctl to its own file base based on sysctl-next.

 v1: https://lore.kernel.org/lkml/20220219072433.86983-1-liaohua4@huawei.com/
  Move latencytop sysctl to its own file base based on linux master.
---
 include/linux/latencytop.h |  3 ---
 kernel/latencytop.c        | 41 +++++++++++++++++++++++++++++------------
 kernel/sysctl.c            | 10 ----------
 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 ae5e59396b5d..4d76e6239f7c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -65,7 +65,6 @@
 #include <linux/bpf.h>
 #include <linux/mount.h>
 #include <linux/userfaultfd_k.h>
-#include <linux/latencytop.h>
 #include <linux/pid.h>
 #include <linux/delayacct.h>
 
@@ -1723,15 +1722,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
 #ifdef CONFIG_BLK_DEV_INITRD
 	{
 		.procname	= "real-root-dev",
-- 
2.12.3


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

* Re: [PATCH sysctl-next v2] latencytop: move sysctl to its own file
  2022-02-23  9:47 [PATCH sysctl-next v2] latencytop: move sysctl to its own file Liao Hua
@ 2022-04-06 22:39 ` Luis Chamberlain
  0 siblings, 0 replies; 2+ messages in thread
From: Luis Chamberlain @ 2022-04-06 22:39 UTC (permalink / raw)
  To: Liao Hua
  Cc: keescook, yzaikin, nixiaoming, linux-kernel, linux-fsdevel,
	wangfangpeng1

On Wed, Feb 23, 2022 at 05:47:10PM +0800, Liao Hua wrote:
> From: liaohua <liaohua4@huawei.com>
> 
> This moves latencytop sysctl to kernel/latencytop.c
> 
> Signed-off-by: liaohua <liaohua4@huawei.com>

Please base your patch on the latest sysctl-next and resubmit.

[0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=sysctl-next

  Luis

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

end of thread, other threads:[~2022-04-06 22:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23  9:47 [PATCH sysctl-next v2] latencytop: move sysctl to its own file Liao Hua
2022-04-06 22:39 ` Luis Chamberlain

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).