From: tangmeng <tangmeng@uniontech.com>
To: viro@zeniv.linux.org.uk, 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 11/11] fs/userfaultfd: move userfaultfd sysctls to its own file
Date: Sun, 20 Feb 2022 14:02:00 +0800 [thread overview]
Message-ID: <20220220060200.14205-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 userfaultfd sysctls to its own file,
fs/userfdfault.c.
Signed-off-by: tangmeng <tangmeng@uniontech.com>
---
fs/userfaultfd.c | 23 ++++++++++++++++++++++-
include/linux/userfaultfd_k.h | 2 --
kernel/sysctl.c | 11 -----------
3 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index e26b10132d47..796d828dd2bb 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -30,7 +30,28 @@
#include <linux/security.h>
#include <linux/hugetlb.h>
-int sysctl_unprivileged_userfaultfd __read_mostly;
+static int sysctl_unprivileged_userfaultfd __read_mostly;
+#ifdef CONFIG_SYSCTL
+static struct ctl_table vm_userfaultfd_table[] = {
+ {
+ .procname = "unprivileged_userfaultfd",
+ .data = &sysctl_unprivileged_userfaultfd,
+ .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_ONE,
+ },
+ { }
+};
+
+static __init int vm_userfaultfd_sysctls_init(void)
+{
+ register_sysctl_init("vm", vm_userfaultfd_table);
+ return 0;
+}
+late_initcall(vm_userfaultfd_sysctls_init);
+#endif /* CONFIG_SYSCTL */
static struct kmem_cache *userfaultfd_ctx_cachep __read_mostly;
diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h
index 33cea484d1ad..0ece3026203f 100644
--- a/include/linux/userfaultfd_k.h
+++ b/include/linux/userfaultfd_k.h
@@ -33,8 +33,6 @@
#define UFFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
#define UFFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS)
-extern int sysctl_unprivileged_userfaultfd;
-
extern vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason);
/*
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 657b7bfe38f6..bc74f2bdaa52 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2407,17 +2407,6 @@ static struct ctl_table vm_table[] = {
.extra1 = (void *)&mmap_rnd_compat_bits_min,
.extra2 = (void *)&mmap_rnd_compat_bits_max,
},
-#endif
-#ifdef CONFIG_USERFAULTFD
- {
- .procname = "unprivileged_userfaultfd",
- .data = &sysctl_unprivileged_userfaultfd,
- .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_ONE,
- },
#endif
{ }
};
--
2.20.1
next reply other threads:[~2022-02-20 6:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-20 6:02 tangmeng [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-02-20 6:03 [PATCH 11/11] fs/userfaultfd: move userfaultfd sysctls to its own file tangmeng
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=20220220060200.14205-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=viro@zeniv.linux.org.uk \
--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;
as well as URLs for NNTP newsgroup(s).