Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3208319pxb; Sun, 20 Feb 2022 12:35:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXbSDLdewEMV/JY938kVnKA7Ba0kJ4Ly43vGCBIc39O1IuojzxAEVi3o6WLCbHFj7CQ16D X-Received: by 2002:a50:d0c7:0:b0:410:b0ab:f1ce with SMTP id g7-20020a50d0c7000000b00410b0abf1cemr17941615edf.433.1645389313891; Sun, 20 Feb 2022 12:35:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645389313; cv=none; d=google.com; s=arc-20160816; b=rXXOSYo2m+cOLH4KqiTvKJ2NnxIlatlotWCuEwdR62CON6NL70+jwAiO+PYNkNYGkm iEfxZE4rZKHS0bMtfwAvhCM2CwMFC0W/7embtIfDTUSKjASgRvFgSB6b/CQ3BOa3SYOM thMl0vjmTxV8vxpkXsFXNTqsGYxp5IrhS70aNq6aY1fGlptevTKU0xzxpwTFjGdCUS6o aQHOb3Lc4oO/Q3uL8E+zL0cnaf4/aQQplma0G+039uFxCKN3QlnXD3qzFw7rzrK8yQRQ hsO99bVoeP9uivb5gxPGLsmi/1qlUSX2f/wxqWQn3L7HrQGlJrwBig2eXlQxu2bCGpJz ydZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=bPeUYBYPJsNUmSu96MAHY3FA0MM9LmHHz9GjiclH8zk=; b=IdFVPGwlJJvaJ2QfgYW43UpWubAM/yB/jyYhgkbWU4zxsuGVfnp6pkZoVRbCA9BHI+ /8cfnISUi9gClw6s1s9VQsgRj2i7RsiCxzx5TVZdTpbZ6/A+XJxhFpth2yXcrWhC2TKa LuA+vSbOQMYCjFi5Mo9n7WLze3U4tzSgntppKPxRwoaPhCpY9vHWCvHXf0ft89vV3HIh jh+fCIH7vMWAJUmH826hIHnzzk+4DG1SxXsyowOCBzobiJzN9Vf1X6HLk/vvTfBLKOhD qCKQkdNJZ3ePt86pN9JYjg30lKFmRbjPEpOCiXkyPkvsyzgnA8UXBx7kohksZ59U2fgw gGag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ek21si9109626edb.264.2022.02.20.12.34.50; Sun, 20 Feb 2022 12:35:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241890AbiBTGCl (ORCPT + 99 others); Sun, 20 Feb 2022 01:02:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242850AbiBTGCg (ORCPT ); Sun, 20 Feb 2022 01:02:36 -0500 Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D634FC7 for ; Sat, 19 Feb 2022 22:02:13 -0800 (PST) X-QQ-mid: bizesmtp84t1645336928t0ofvhkx Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:02:02 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: kG8stifNu8WQBk7A83W6qIcMVm8Uzj/tIiyGnpzPr0BaZqh144QpaVH6xBmhJ 7j2rDZ7XAii72Gwg1slHxFTYdOvGB+Nvw2vRAbIqHvJvII+KfGE03Un+Vd7e9ha0RqSVReK y7PnyOWuHlgPWVaTrMO+Hj5VGSzEE+Em+Y+IXjAsKOidPXfPBsSBxwaDfOMqZA56FJpCiLI hNxpbQMfYMWP5U54mCKyuivSWBc+Mj9jArgx7TyL9vlew0wA7UTQfkRBhBTh86bbCmelyPq 3iTMmr+Le1k0xxWhWx/djkks4lfWI900u3znx8zkz9PpgaQMXyykYfLvnR0bN/CZkAbZjAO 2U83kRirBqx5ReTBebJK6AJM6vXerZsN1oLNqHB X-QQ-GoodBg: 2 From: tangmeng 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 Subject: [PATCH 11/11] fs/userfaultfd: move userfaultfd sysctls to its own file Date: Sun, 20 Feb 2022 14:02:00 +0800 Message-Id: <20220220060200.14205-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 { } }; -- 2.20.1