mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: tangmeng <tangmeng@uniontech.com>
To: 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 04/11] kernel/fork: move threads-max sysctl to its own file
Date: Sun, 20 Feb 2022 14:00:41 +0800	[thread overview]
Message-ID: <20220220060041.13531-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 threads-max sysctl to its
own file, kernel/fork.c.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
---
 include/linux/sysctl.h |  3 ---
 kernel/fork.c          | 22 +++++++++++++++++++++-
 kernel/sysctl.c        |  7 -------
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index e00bf436d63b..1d3467b5e2f3 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -295,7 +295,4 @@ static inline void do_sysctl_args(void)
 }
 #endif /* CONFIG_SYSCTL */
 
-int sysctl_max_threads(struct ctl_table *table, int write, void *buffer,
-		size_t *lenp, loff_t *ppos);
-
 #endif /* _LINUX_SYSCTL_H */
diff --git a/kernel/fork.c b/kernel/fork.c
index d75a528f7b21..0ac42feb3f71 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -3143,7 +3143,8 @@ int unshare_files(void)
 	return 0;
 }
 
-int sysctl_max_threads(struct ctl_table *table, int write,
+#ifdef CONFIG_SYSCTL
+static int sysctl_max_threads(struct ctl_table *table, int write,
 		       void *buffer, size_t *lenp, loff_t *ppos)
 {
 	struct ctl_table t;
@@ -3165,3 +3166,22 @@ int sysctl_max_threads(struct ctl_table *table, int write,
 
 	return 0;
 }
+
+static struct ctl_table kern_fork_table[] = {
+	{
+		.procname       = "threads-max",
+		.data           = NULL,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = sysctl_max_threads,
+	},
+	{ }
+};
+
+static __init int kernel_fork_sysctls_init(void)
+{
+	register_sysctl_init("kernel", kern_fork_table);
+	return 0;
+}
+late_initcall(kernel_fork_sysctls_init);
+#endif /* CONFIG_SYSCTL */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 126d47e8224d..e6d99bbf9a9d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1829,13 +1829,6 @@ static struct ctl_table kern_table[] = {
 		.proc_handler	= proc_do_cad_pid,
 	},
 #endif
-	{
-		.procname	= "threads-max",
-		.data		= NULL,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= sysctl_max_threads,
-	},
 	{
 		.procname	= "usermodehelper",
 		.mode		= 0555,
-- 
2.20.1




                 reply	other threads:[~2022-02-20  6:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220220060041.13531-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=nixiaoming@huawei.com \
    --cc=nizhen@uniontech.com \
    --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®