* [PATCH 11/11] fs/userfaultfd: move userfaultfd sysctls to its own file
@ 2022-02-20 6:03 tangmeng
0 siblings, 0 replies; 2+ messages in thread
From: tangmeng @ 2022-02-20 6:03 UTC (permalink / raw)
To: viro, akpm, mcgrof, keescook, yzaikin
Cc: linux-mm, linux-kernel, linux-fsdevel, nizhen, zhanglianjie,
nixiaoming, tangmeng
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 11/11] fs/userfaultfd: move userfaultfd sysctls to its own file
@ 2022-02-20 6:02 tangmeng
0 siblings, 0 replies; 2+ messages in thread
From: tangmeng @ 2022-02-20 6:02 UTC (permalink / raw)
To: viro, mcgrof, keescook, yzaikin
Cc: linux-kernel, linux-fsdevel, nizhen, zhanglianjie, nixiaoming,
tangmeng
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-20 6:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-20 6:03 [PATCH 11/11] fs/userfaultfd: move userfaultfd sysctls to its own file tangmeng
-- strict thread matches above, loose matches on Subject: below --
2022-02-20 6:02 tangmeng
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).