From patchwork Sun Feb 20 06:03:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Tang X-Patchwork-Id: 12752575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A847C433EF for ; Sun, 20 Feb 2022 06:04:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D57E46B0072; Sun, 20 Feb 2022 01:04:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CDF5B6B0074; Sun, 20 Feb 2022 01:04:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7FB26B0078; Sun, 20 Feb 2022 01:04:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id A44166B0072 for ; Sun, 20 Feb 2022 01:04:14 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5A162180B3E0C for ; Sun, 20 Feb 2022 06:04:14 +0000 (UTC) X-FDA: 79162118028.31.62857CE Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by imf11.hostedemail.com (Postfix) with ESMTP id D85E440003 for ; Sun, 20 Feb 2022 06:04:12 +0000 (UTC) X-QQ-mid: bizesmtp73t1645337042tx5jm81h Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:03:56 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: sOJWOW+s0sNKLHe1yAEwsqM1eezK/EuD2TDgyv2R5vlMpJ9Uf6gjfmFJEsxEh 0iv8+aBY3+ksXEqt0xYx2eecVRTxBbDFQmOWgJviZzsC4qTPGOXUYecmEjLU1HO/zTd//kN 2bmXaMJ9AnhX2GkcgKVMcyFCHSC+I+ynqu4NCGMXeA0Q+qX9gEV9V6+XYW+XbNGbZu4oSEE kOtMpq9IrEKh+IFCL4MaQSxwQi1LCXZlk31mBp11L/jSBYyvAXToaWHAK2YS4BYSrIk1Y5Y zNUsQKuyX81ReBnb/JGC1KmL4xSN4Jq0nmBL+kdZRNIKZQVqMqrEJsPv3la/ztadYilwKnC /oMI+/VDgMxphyFFrhQFrX8DzXT7iZGje8fBkqh X-QQ-GoodBg: 2 From: tangmeng To: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, nizhen@uniontech.com, zhanglianjie@uniontech.com, nixiaoming@huawei.com, tangmeng Subject: [PATCH 11/11] fs/userfaultfd: move userfaultfd sysctls to its own file Date: Sun, 20 Feb 2022 14:03:54 +0800 Message-Id: <20220220060354.14961-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf11.hostedemail.com: domain of tangmeng@uniontech.com designates 54.206.16.166 as permitted sender) smtp.mailfrom=tangmeng@uniontech.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D85E440003 X-Stat-Signature: aumw3xaf5chfn36hjurpxjyqpgkc3kb7 X-HE-Tag: 1645337052-487394 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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 #include -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 { } };