From patchwork Sun Feb 20 06:01:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Tang X-Patchwork-Id: 12752567 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 981A6C433F5 for ; Sun, 20 Feb 2022 06:02:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F88C6B0074; Sun, 20 Feb 2022 01:02:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A7D86B0075; Sun, 20 Feb 2022 01:02:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1708D6B0078; Sun, 20 Feb 2022 01:02:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 0AF2E6B0074 for ; Sun, 20 Feb 2022 01:02:00 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AF10C94FCF for ; Sun, 20 Feb 2022 06:01:59 +0000 (UTC) X-FDA: 79162112358.13.B6472F5 Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by imf20.hostedemail.com (Postfix) with ESMTP id 6BDB11C0005 for ; Sun, 20 Feb 2022 06:01:56 +0000 (UTC) X-QQ-mid: bizesmtp79t1645336906taxdyayp Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:01:40 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: F3yR32iATbgAptDoI3vmu8Pc5GgqoUhffNL6Adxaif3ZyUAw/CPtH+G9srbBJ w9hjWWP8XIyr1+M+HNwMJYFh0vBx/e58dqRnDdtWoEmYGz93YRrJpmqqg8rO6ODwNGYgQLo k27/YHfZ963q4G4gUn5SpB7Ngo/i3arw6Cgm9PSIFvPjHimr+rkhn8ARu/fMKBjJHJQVCqs ONnGnrfcOO40PxF1Ip83my/8cz01L9L/mdH4jHdfEQudKDBRDJL0QmxJT3xWjZGQJ7XyZ5I dBmdRt9Ul/ZpxzksMqdFEu/0/WegvObicpc3+dn7Cp5UY5Vb8GzQbH2sTLJKFBmLXFlsjd8 rTBAaWFrQg9lky10nKQVvbQbxA6qfLGsssylv/wQK7mkHquf0A= X-QQ-GoodBg: 2 From: tangmeng To: mike.kravetz@oracle.com, akpm@linux-foundation.org, 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 08/11] mm/hugetlb: move hugetlib sysctls to its own file Date: Sun, 20 Feb 2022 14:01:36 +0800 Message-Id: <20220220060136.14001-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: 7jwgiu541sn6hpnk5hhbkakp6bt7scp8 X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of tangmeng@uniontech.com designates 54.207.22.56 as permitted sender) smtp.mailfrom=tangmeng@uniontech.com; dmarc=none X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 6BDB11C0005 X-HE-Tag: 1645336916-834363 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 hugetlb sysctls to its own file, mm/hugetlb.c. 'hugetlb_treat_movable_handler' is not currently used, so only delete it from the linux/hugetlb.h. Signed-off-by: tangmeng --- include/linux/hugetlb.h | 8 -------- kernel/sysctl.c | 26 ------------------------ mm/hugetlb.c | 44 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index f307e1963851..bf807418828a 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -13,7 +13,6 @@ #include #include -struct ctl_table; struct user_struct; struct mmu_gather; @@ -125,13 +124,6 @@ void hugepage_put_subpool(struct hugepage_subpool *spool); void reset_vma_resv_huge_pages(struct vm_area_struct *vma); void clear_vma_resv_huge_pages(struct vm_area_struct *vma); -int hugetlb_sysctl_handler(struct ctl_table *, int, void *, size_t *, loff_t *); -int hugetlb_overcommit_handler(struct ctl_table *, int, void *, size_t *, - loff_t *); -int hugetlb_treat_movable_handler(struct ctl_table *, int, void *, size_t *, - loff_t *); -int hugetlb_mempolicy_sysctl_handler(struct ctl_table *, int, void *, size_t *, - loff_t *); int move_hugetlb_page_tables(struct vm_area_struct *vma, struct vm_area_struct *new_vma, diff --git a/kernel/sysctl.c b/kernel/sysctl.c index dc5e313c9e6b..1a1504862f4f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -2176,31 +2175,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO_HUNDRED, }, -#ifdef CONFIG_HUGETLB_PAGE - { - .procname = "nr_hugepages", - .data = NULL, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = hugetlb_sysctl_handler, - }, -#ifdef CONFIG_NUMA - { - .procname = "nr_hugepages_mempolicy", - .data = NULL, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = &hugetlb_mempolicy_sysctl_handler, - }, -#endif - { - .procname = "nr_overcommit_hugepages", - .data = NULL, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = hugetlb_overcommit_handler, - }, -#endif { .procname = "lowmem_reserve_ratio", .data = &sysctl_lowmem_reserve_ratio, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 61895cc01d09..2b1da0c0871b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4359,7 +4359,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy, return ret; } -int hugetlb_sysctl_handler(struct ctl_table *table, int write, +static int hugetlb_sysctl_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { @@ -4368,7 +4368,7 @@ int hugetlb_sysctl_handler(struct ctl_table *table, int write, } #ifdef CONFIG_NUMA -int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write, +static int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { return hugetlb_sysctl_handler_common(true, table, write, @@ -4376,7 +4376,7 @@ int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write, } #endif /* CONFIG_NUMA */ -int hugetlb_overcommit_handler(struct ctl_table *table, int write, +static int hugetlb_overcommit_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { struct hstate *h = &default_hstate; @@ -7028,3 +7028,41 @@ void __init hugetlb_cma_check(void) } #endif /* CONFIG_CMA */ + +#ifdef CONFIG_SYSCTL +static struct ctl_table vm_mm_hugetlb_table[] = { +#ifdef CONFIG_HUGETLB_PAGE + { + .procname = "nr_hugepages", + .data = NULL, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = hugetlb_sysctl_handler, + }, +#ifdef CONFIG_NUMA + { + .procname = "nr_hugepages_mempolicy", + .data = NULL, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = &hugetlb_mempolicy_sysctl_handler, + }, +#endif + { + .procname = "nr_overcommit_hugepages", + .data = NULL, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = hugetlb_overcommit_handler, + }, +#endif + { } +}; + +static __init int vm_mm_hugetlb_sysctls_init(void) +{ + register_sysctl_init("vm", vm_mm_hugetlb_table); + return 0; +} +late_initcall(vm_mm_hugetlb_sysctls_init); +#endif