From patchwork Sun Feb 20 06:01:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Tang X-Patchwork-Id: 12752565 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 B83B9C433F5 for ; Sun, 20 Feb 2022 06:01:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD24D6B0072; Sun, 20 Feb 2022 01:01:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B82BF6B0073; Sun, 20 Feb 2022 01:01:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4AFF6B0074; Sun, 20 Feb 2022 01:01:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id 95EFC6B0072 for ; Sun, 20 Feb 2022 01:01:34 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 26D0C9AC96 for ; Sun, 20 Feb 2022 06:01:34 +0000 (UTC) X-FDA: 79162111308.20.12322E2 Received: from smtpproxy21.qq.com (smtpbg704.qq.com [203.205.195.105]) by imf31.hostedemail.com (Postfix) with ESMTP id 0BCA420004 for ; Sun, 20 Feb 2022 06:01:32 +0000 (UTC) X-QQ-mid: bizesmtp82t1645336882t5dgk557 Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:01:16 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: zD6y7hNAcUDOz2spGL/eUKdvHQFW318WJmvVp1I5o3JA883k/G16UFiqIcHw4 PBZ45w9nlRbhLwZwLDc91e8FdhgMGUn61raT5T9pXHP1bIUcBLW/oW3bXuXhP3ZhHBBbw4l sdn+5SZ7+S6rIzzBNhT4bOxGaUOTTxQn3REmqbN6PWYflwJz2iSsrIZZ5XNQlNYtQcdLZFO nhDonfnvqbgU1bSTmKhWJ6kaJtkFZmLR/YAC7aoB21xhpZbyStZK7UL4WM3y8VYc+u23GH8 X578cnMVz9F37uklWZb+CU0sgSVjRtn/OnhTJwN3HFkVWOGFIUONEBk2H/5we+6FkMvqlHs f+FSmlATG7vdRv5ELgUXlO5onmn9p+WlGxBF21p X-QQ-GoodBg: 2 From: tangmeng To: 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 06/11] mm/vmstat: move vmstat sysctls to its own file Date: Sun, 20 Feb 2022 14:01:10 +0800 Message-Id: <20220220060110.13770-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:qybgforeign6 X-QQ-Bgrelay: 1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0BCA420004 X-Stat-Signature: ejobefipqw3735m7gc5g1nnkb5ihttak Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf31.hostedemail.com: domain of tangmeng@uniontech.com designates 203.205.195.105 as permitted sender) smtp.mailfrom=tangmeng@uniontech.com X-HE-Tag: 1645336892-815377 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 vmstat sysctls to its own file, mm/vmstat.c. vmstat_refresh is defined when CONFIG_PROC_FS is defined, so macro control is added to stat_refresh. Signed-off-by: tangmeng --- include/linux/vmstat.h | 9 -------- kernel/sysctl.c | 25 --------------------- mm/vmstat.c | 50 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index bfe38869498d..b615d8d7c1d2 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -10,15 +10,10 @@ #include #include -extern int sysctl_stat_interval; - #ifdef CONFIG_NUMA #define ENABLE_NUMA_STAT 1 #define DISABLE_NUMA_STAT 0 -extern int sysctl_vm_numa_stat; DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key); -int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write, - void *buffer, size_t *length, loff_t *ppos); #endif struct reclaim_stat { @@ -300,10 +295,6 @@ void quiet_vmstat(void); void cpu_vm_stats_fold(int cpu); void refresh_zone_stat_thresholds(void); -struct ctl_table; -int vmstat_refresh(struct ctl_table *, int write, void *buffer, size_t *lenp, - loff_t *ppos); - void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *); int calculate_pressure_threshold(struct zone *zone); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 62499e3207aa..31f2c6e21392 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2192,15 +2192,6 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = &hugetlb_mempolicy_sysctl_handler, }, - { - .procname = "numa_stat", - .data = &sysctl_vm_numa_stat, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = sysctl_vm_numa_stat_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, #endif { .procname = "hugetlb_shm_group", @@ -2377,22 +2368,6 @@ static struct ctl_table vm_table[] = { .extra2 = SYSCTL_ONE_HUNDRED, }, #endif -#ifdef CONFIG_SMP - { - .procname = "stat_interval", - .data = &sysctl_stat_interval, - .maxlen = sizeof(sysctl_stat_interval), - .mode = 0644, - .proc_handler = proc_dointvec_jiffies, - }, - { - .procname = "stat_refresh", - .data = NULL, - .maxlen = 0, - .mode = 0600, - .proc_handler = vmstat_refresh, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", diff --git a/mm/vmstat.c b/mm/vmstat.c index 4057372745d0..e7eeba4db2eb 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -32,7 +32,7 @@ #include "internal.h" #ifdef CONFIG_NUMA -int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; +static int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; /* zero numa counters within a zone */ static void zero_zone_numa_counters(struct zone *zone) @@ -74,7 +74,7 @@ static void invalid_numa_statistics(void) static DEFINE_MUTEX(vm_numa_stat_lock); -int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write, +static int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret, oldval; @@ -1853,7 +1853,7 @@ static const struct seq_operations vmstat_op = { #ifdef CONFIG_SMP static DEFINE_PER_CPU(struct delayed_work, vmstat_work); -int sysctl_stat_interval __read_mostly = HZ; +static int sysctl_stat_interval __read_mostly = HZ; #ifdef CONFIG_PROC_FS static void refresh_vm_stats(struct work_struct *work) @@ -1861,7 +1861,7 @@ static void refresh_vm_stats(struct work_struct *work) refresh_cpu_vm_stats(true); } -int vmstat_refresh(struct ctl_table *table, int write, +static int vmstat_refresh(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { long val; @@ -2238,3 +2238,45 @@ static int __init extfrag_debug_init(void) module_init(extfrag_debug_init); #endif + +#ifdef CONFIG_SYSCTL +static struct ctl_table vm_stat_table[] = { +#ifdef CONFIG_NUMA + { + .procname = "numa_stat", + .data = &sysctl_vm_numa_stat, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = sysctl_vm_numa_stat_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, +#endif /* CONFIG_NUMA */ +#ifdef CONFIG_SMP + { + .procname = "stat_interval", + .data = &sysctl_stat_interval, + .maxlen = sizeof(sysctl_stat_interval), + .mode = 0644, + .proc_handler = proc_dointvec_jiffies, + }, +#ifdef CONFIG_PROC_FS + { + .procname = "stat_refresh", + .data = NULL, + .maxlen = 0, + .mode = 0600, + .proc_handler = vmstat_refresh, + }, +#endif /* CONFIG_PROC_FS */ +#endif /* CONFIG_SMP */ + { } +}; + +static __init int vm_stat_sysctls_init(void) +{ + register_sysctl_init("vm", vm_stat_table); + return 0; +} +late_initcall(vm_stat_sysctls_init); +#endif /* CONFIG_SYSCTL */ 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, 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 From patchwork Sun Feb 20 06:01:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Tang X-Patchwork-Id: 12752568 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 6B9DBC433EF for ; Sun, 20 Feb 2022 06:02:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 012EA6B0075; Sun, 20 Feb 2022 01:02:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F04676B0078; Sun, 20 Feb 2022 01:02:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF2FD6B007B; Sun, 20 Feb 2022 01:02:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id D22DB6B0075 for ; Sun, 20 Feb 2022 01:02:08 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 9B57060372 for ; Sun, 20 Feb 2022 06:02:08 +0000 (UTC) X-FDA: 79162112736.05.AD536B3 Received: from smtpbg152.qq.com (smtpbg152.qq.com [13.245.186.79]) by imf05.hostedemail.com (Postfix) with ESMTP id EFCB6100002 for ; Sun, 20 Feb 2022 06:02:05 +0000 (UTC) X-QQ-mid: bizesmtp83t1645336917tfkame2n Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:01:51 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: 4LFlwc+MlXkQ8gqbBA0q6azNy4FS1Wp5//1Uq4m3wJCqupGWBCLm4SAGWY39E d+iIj+Wv2qwxluAPiItIHm2vHTu9tlW2cYh9/+NYMgheyjVewkcP5Ia8AQ6oKZPoBm8OCrn XGx+2RzTo0DYxdemrR2ynLPwTWRgT3E7ZwgvFoZUzkT8uKT5sm61ndzj4FVNF4ww1PlRxeW XjKH4OQRKd4bh6wTqC4MwRkMZOSBpycSD7ou4QzwsFSgPnPPgF43ILh/iij7P5hxrgiDKsG VfSYnxCDrK3098yCmiAhwujlQx8XSn2FdMIYs2o2auaA91PQr7gofumlnImAAAXWDShmI6n b3S9MB2w68SHzCsrEQ4wPaebW5diY714Dx+mjye X-QQ-GoodBg: 2 From: tangmeng To: 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 09/11] mm/filemap: move filemap sysctls to its own file Date: Sun, 20 Feb 2022 14:01:49 +0800 Message-Id: <20220220060149.14110-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-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: EFCB6100002 X-Stat-Signature: ic74e7f6pp318dcqiuuc1xz981sgn39w Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of tangmeng@uniontech.com designates 13.245.186.79 as permitted sender) smtp.mailfrom=tangmeng@uniontech.com; dmarc=none X-Rspam-User: X-HE-Tag: 1645336925-668839 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 filemap sysctls to its own file, mm/filemap.c. Signed-off-by: tangmeng --- include/linux/mm.h | 2 -- kernel/sysctl.c | 8 -------- mm/filemap.c | 24 +++++++++++++++++++++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 213cc569b192..c3c7cb58c847 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -39,8 +39,6 @@ struct anon_vma_chain; struct user_struct; struct pt_regs; -extern int sysctl_page_lock_unfairness; - void init_mm_internals(void); #ifndef CONFIG_NUMA /* Don't use mapnrs, do it properly */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 1a1504862f4f..b51b0b92fdc1 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2261,14 +2261,6 @@ static struct ctl_table vm_table[] = { .proc_handler = percpu_pagelist_high_fraction_sysctl_handler, .extra1 = SYSCTL_ZERO, }, - { - .procname = "page_lock_unfairness", - .data = &sysctl_page_lock_unfairness, - .maxlen = sizeof(sysctl_page_lock_unfairness), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, #ifdef CONFIG_MMU { .procname = "max_map_count", diff --git a/mm/filemap.c b/mm/filemap.c index ad8c39d90bf9..f264e7e12f59 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1235,7 +1235,29 @@ static inline bool folio_trylock_flag(struct folio *folio, int bit_nr, } /* How many times do we accept lock stealing from under a waiter? */ -int sysctl_page_lock_unfairness = 5; +static int sysctl_page_lock_unfairness = 5; + +#ifdef CONFIG_SYSCTL +static struct ctl_table vm_filemap_table[] = { + { + + .procname = "page_lock_unfairness", + .data = &sysctl_page_lock_unfairness, + .maxlen = sizeof(sysctl_page_lock_unfairness), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, + { } +}; + +static __init int vm_filemap_sysctls_init(void) +{ + register_sysctl_init("vm", vm_filemap_table); + return 0; +} +late_initcall(vm_filemap_sysctls_init); +#endif /* CONFIG_SYSCTL */ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr, int state, enum behavior behavior) From patchwork Sun Feb 20 06:06:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Tang X-Patchwork-Id: 12752576 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 7A55EC433F5 for ; Sun, 20 Feb 2022 06:07:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05A016B0072; Sun, 20 Feb 2022 01:07:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 00A936B0073; Sun, 20 Feb 2022 01:07:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E14906B0074; Sun, 20 Feb 2022 01:07:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id D04276B0072 for ; Sun, 20 Feb 2022 01:07:04 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7BD942243B for ; Sun, 20 Feb 2022 06:07:04 +0000 (UTC) X-FDA: 79162125168.05.B9021D8 Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 7339C40004 for ; Sun, 20 Feb 2022 06:07:01 +0000 (UTC) X-QQ-mid: bizesmtp88t1645337208t7nkhfkg Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:06:33 +0800 (CST) X-QQ-SSF: 01400000002000B0F000000A0000000 X-QQ-FEAT: d3XYZ9avhmAtY8bKX2/d7LpBuqdLrdgaVpVdorzRFP1KIykOsY0uqX7+VH2MI 6bcYkZM/2LQgM1uL/YpI8EvW8EoP2rWGqRlW/+agsMpI4yEY6x64pIBGOf0F0iMnbGsDVeg 4mVODKp39iheZu9YCLOWvbhtTSX5JBGxDg9vlgAkY1sOsKL2qtPUT53Of791wLzTsKGrBTA U+Z0SkLJqznMM6JR0jmH0OKKi73aq0+U3Z6OQeU7wwU5kkgtmF71wUQHg92QPVDOaZ0jbbU gwRhd4t74rsPTE1IrA2bzHonEcAR+UU0Z4jPni66V9hZboyC00ffLqD5B1ydYTkiKvKGQ48 j540cPL1Re4R5MigM6JXDuzvzrUHc4JcGOLAZVD X-QQ-GoodBg: 1 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 10/11] fs/drop_caches: move drop_caches sysctls to its own file Date: Sun, 20 Feb 2022 14:06:26 +0800 Message-Id: <20220220060626.15885-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 Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of tangmeng@uniontech.com designates 54.92.39.34 as permitted sender) smtp.mailfrom=tangmeng@uniontech.com X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7339C40004 X-Stat-Signature: hocaa84qfmygn4oxyybsa4ojhn4c5iuw X-HE-Tag: 1645337221-407059 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 drop_caches sysctls to its own file, fs/drop_caches.c. Signed-off-by: tangmeng --- fs/drop_caches.c | 26 ++++++++++++++++++++++++-- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index e619c31b6bd9..5e044a2d75ef 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -13,7 +13,7 @@ #include "internal.h" /* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches; static void drop_pagecache_sb(struct super_block *sb, void *unused) { @@ -47,7 +47,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) iput(toput_inode); } -int drop_caches_sysctl_handler(struct ctl_table *table, int write, +static int drop_caches_sysctl_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret; @@ -75,3 +75,25 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, } return 0; } + +#ifdef CONFIG_SYSCTL +static struct ctl_table vm_drop_caches_table[] = { + { + .procname = "drop_caches", + .data = &sysctl_drop_caches, + .maxlen = sizeof(int), + .mode = 0200, + .proc_handler = drop_caches_sysctl_handler, + .extra1 = SYSCTL_ONE, + .extra2 = SYSCTL_FOUR, + }, + { } +}; + +static __init int vm_drop_caches_sysctls_init(void) +{ + register_sysctl_init("vm", vm_drop_caches_table); + return 0; +} +late_initcall(vm_drop_caches_sysctls_init); +#endif /* CONFIG_SYSCTL */ diff --git a/include/linux/mm.h b/include/linux/mm.h index c3c7cb58c847..775befb2786b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3126,12 +3126,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr) extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm); -#ifdef CONFIG_SYSCTL -extern int sysctl_drop_caches; -int drop_caches_sysctl_handler(struct ctl_table *, int, void *, size_t *, - loff_t *); -#endif - void drop_slab(void); #ifndef CONFIG_MMU diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b51b0b92fdc1..657b7bfe38f6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2182,15 +2182,6 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = lowmem_reserve_ratio_sysctl_handler, }, - { - .procname = "drop_caches", - .data = &sysctl_drop_caches, - .maxlen = sizeof(int), - .mode = 0200, - .proc_handler = drop_caches_sysctl_handler, - .extra1 = SYSCTL_ONE, - .extra2 = SYSCTL_FOUR, - }, #ifdef CONFIG_COMPACTION { .procname = "compact_memory", 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 { } };