From patchwork Sun Feb 20 06:01:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Tang X-Patchwork-Id: 12752566 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 BE90DC433EF for ; Sun, 20 Feb 2022 06:01:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 124F76B0073; Sun, 20 Feb 2022 01:01:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D3CF6B0074; Sun, 20 Feb 2022 01:01:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2C356B0075; Sun, 20 Feb 2022 01:01:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0134.hostedemail.com [216.40.44.134]) by kanga.kvack.org (Postfix) with ESMTP id E53DE6B0073 for ; Sun, 20 Feb 2022 01:01:40 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 99C9789D37 for ; Sun, 20 Feb 2022 06:01:40 +0000 (UTC) X-FDA: 79162111560.30.878A33A Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) by imf31.hostedemail.com (Postfix) with ESMTP id 6EDE720003 for ; Sun, 20 Feb 2022 06:01:39 +0000 (UTC) X-QQ-mid: bizesmtp76t1645336893tmnmssis Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:01:27 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: HoyAXBWgsklMLx45Q65e9S1zIxrVT15UuJ2vKorwsFn98tS8WzQL3Ja3N5+YS uCEmB4z3YaBlyXfs4A1mikfBwd4xOHC+I7wNiSQtrEAvnG9MKqTP3NKRXIsoOaX1M4MQfzW CvP58Tlf4BfpiNkohfbUrnJMD8E1M/5aJRCWoTSIr1/QiPtivA/HtsXJxOlZPVrJ2/2g0gq ctA3erE5waMiZGa5L0gvdl2GFjZExQl0GKnzkqDD992KrR5pD0vYy//uzIiMcASfSlAjXNR uiGdDMgCdckwUm5d/hdmGlveNxGlZOomroS5Z8HpQwQOvlM/hmQocQ+4n0zolqJM12bscP8 o/f2wU1j6Cy8WRV/UBI9VFWCpuKqI+BGFHv5DGA X-QQ-GoodBg: 2 From: tangmeng To: mike.kravetz@oracle.com, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, nizhen@uniontech.com, zhanglianjie@uniontech.com, nixiaoming@huawei.com, tangmeng Subject: [PATCH 07/11] fs/hugetlbfs: move hugetlibfs sysctls to its own file Date: Sun, 20 Feb 2022 14:01:25 +0800 Message-Id: <20220220060125.13904-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:qybgforeign1 X-QQ-Bgrelay: 1 X-Stat-Signature: n1xjkj39qtfsqw4hkm1nz6tmkb9ef4p3 X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=none; spf=pass (imf31.hostedemail.com: domain of tangmeng@uniontech.com designates 18.169.211.239 as permitted sender) smtp.mailfrom=tangmeng@uniontech.com; dmarc=none X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 6EDE720003 X-HE-Tag: 1645336899-228464 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 hugetlbfs sysctls to its own file, fs/hugetlbfs/inode.c. Signed-off-by: tangmeng --- fs/hugetlbfs/inode.c | 21 ++++++++++++++++++++- include/linux/hugetlb.h | 1 - kernel/sysctl.c | 7 ------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index a7c6c7498be0..3f386d9d8ad3 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -62,7 +62,26 @@ struct hugetlbfs_fs_context { umode_t mode; }; -int sysctl_hugetlb_shm_group; +static int sysctl_hugetlb_shm_group; +#if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_SYSCTL) +static struct ctl_table vm_hugetlbfs_table[] = { + { + .procname = "hugetlb_shm_group", + .data = &sysctl_hugetlb_shm_group, + .maxlen = sizeof(gid_t), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + { } +}; + +static __init int vm_hugetlbfs_sysctls_init(void) +{ + register_sysctl_init("vm", vm_hugetlbfs_table); + return 0; +} +late_initcall(vm_hugetlbfs_sysctls_init); +#endif enum hugetlb_param { Opt_gid, diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index d1897a69c540..f307e1963851 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -181,7 +181,6 @@ pte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma, struct address_space *hugetlb_page_mapping_lock_write(struct page *hpage); -extern int sysctl_hugetlb_shm_group; extern struct list_head huge_boot_pages; /* arch callbacks */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 31f2c6e21392..dc5e313c9e6b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2193,13 +2193,6 @@ static struct ctl_table vm_table[] = { .proc_handler = &hugetlb_mempolicy_sysctl_handler, }, #endif - { - .procname = "hugetlb_shm_group", - .data = &sysctl_hugetlb_shm_group, - .maxlen = sizeof(gid_t), - .mode = 0644, - .proc_handler = proc_dointvec, - }, { .procname = "nr_overcommit_hugepages", .data = NULL,