All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: akpm@linux-foundation.org, keescook@chromium.org,
	yzaikin@google.com, nixiaoming@huawei.com, ebiederm@xmission.com
Cc: linux-fsdevel@vger.kernel.org, patches@lists.linux.dev,
	Luis Chamberlain <mcgrof@kernel.org>,
	Domenico Andreoli <domenico.andreoli@linux.com>,
	Tong Zhang <ztong0001@gmail.com>
Subject: [PATCH v2] fs: move binfmt_misc sysctl to its own file as built-in
Date: Wed,  9 Feb 2022 14:57:58 -0800	[thread overview]
Message-ID: <20220209225758.476724-1-mcgrof@kernel.org> (raw)

This is the second attempt to move binfmt_misc sysctl to its
own file. The issue with the first move was that we moved
the binfmt_misc sysctls to the binfmt_misc module, but the
way things work on some systems is that the binfmt_misc
module will load if the sysctl is present. If we don't force
the sysctl on, the module won't load. The proper thing to do
is to register the sysctl if the module was built or the
binfmt_misc code was built-in, we do this by using the helper
IS_ENABLED() now.

The rationale for the move:

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.

This moves the binfmt_misc sysctl to its own file to help remove clutter
from kernel/sysctl.c.

Cc: Domenico Andreoli <domenico.andreoli@linux.com>
Cc: Tong Zhang <ztong0001@gmail.com>
Reviewed-by: Tong Zhang <ztong0001@gmail.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---

Andrew,

If we get tested-by from Domenico and Tong I think this is ready.

Demenico, Tong, can you please test this patch? Linus' tree
should already have all the prior work reverted as Domenico requested
so this starts fresh.

 fs/file_table.c |  2 ++
 kernel/sysctl.c | 13 -------------
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/fs/file_table.c b/fs/file_table.c
index 57edef16dce4..4969021fa676 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {
 static int __init init_fs_stat_sysctls(void)
 {
 	register_sysctl_init("fs", fs_stat_sysctls);
+	if (IS_ENABLED(CONFIG_BINFMT_MISC))
+		register_sysctl_mount_point("fs/binfmt_misc");
 	return 0;
 }
 fs_initcall(init_fs_stat_sysctls);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 241cfc6bc36f..788b9a34d5ab 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2735,17 +2735,6 @@ static struct ctl_table vm_table[] = {
 	{ }
 };
 
-static struct ctl_table fs_table[] = {
-#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
-	{
-		.procname	= "binfmt_misc",
-		.mode		= 0555,
-		.child		= sysctl_mount_point,
-	},
-#endif
-	{ }
-};
-
 static struct ctl_table debug_table[] = {
 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
 	{
@@ -2765,7 +2754,6 @@ static struct ctl_table dev_table[] = {
 
 DECLARE_SYSCTL_BASE(kernel, kern_table);
 DECLARE_SYSCTL_BASE(vm, vm_table);
-DECLARE_SYSCTL_BASE(fs, fs_table);
 DECLARE_SYSCTL_BASE(debug, debug_table);
 DECLARE_SYSCTL_BASE(dev, dev_table);
 
@@ -2773,7 +2761,6 @@ int __init sysctl_init_bases(void)
 {
 	register_sysctl_base(kernel);
 	register_sysctl_base(vm);
-	register_sysctl_base(fs);
 	register_sysctl_base(debug);
 	register_sysctl_base(dev);
 
-- 
2.34.1


             reply	other threads:[~2022-02-09 22:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 22:57 Luis Chamberlain [this message]
2022-02-09 23:15 ` [PATCH v2] fs: move binfmt_misc sysctl to its own file as built-in Tong Zhang
2022-02-09 23:18   ` Tong Zhang
2022-02-09 23:29   ` Luis Chamberlain
2022-02-09 23:39     ` Tong Zhang
2022-02-10  0:14       ` Tong Zhang
2022-02-10  0:23         ` Luis Chamberlain

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=20220209225758.476724-1-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=domenico.andreoli@linux.com \
    --cc=ebiederm@xmission.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=nixiaoming@huawei.com \
    --cc=patches@lists.linux.dev \
    --cc=yzaikin@google.com \
    --cc=ztong0001@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.