From patchwork Thu Mar 9 12:20:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13167304 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 A638FC64EC4 for ; Thu, 9 Mar 2023 11:59:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE0F96B0071; Thu, 9 Mar 2023 06:59:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D90E06B0072; Thu, 9 Mar 2023 06:59:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C598E6B0075; Thu, 9 Mar 2023 06:59:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B7B686B0071 for ; Thu, 9 Mar 2023 06:59:44 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 86757C1084 for ; Thu, 9 Mar 2023 11:59:44 +0000 (UTC) X-FDA: 80549215488.02.DBE322E Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf01.hostedemail.com (Postfix) with ESMTP id 2827240005 for ; Thu, 9 Mar 2023 11:59:40 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678363182; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=WeQRhZSrgdx1cdygLNyUBl3BdAa0+zJuiUhxqs31FG0=; b=8CzZAYv/Ye+s/fyqIJ6RH64BJPpxY/IEMDSfbG9rVxvxjrBLt6Uf1G6mdgH8QFbTEBjLwf 4ZBe32uim9/pu+WSCTdtBnUms2rL8zNfGQptvVzm5zMZMlypdGLopyq+saq7g/wJWnkEi8 SJlyBaEMmPxDRZgFuYwfX6AS/UBKX70= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678363182; a=rsa-sha256; cv=none; b=6hIvrvXKJoRDH3QRt3rYLpLDPOx/yyDUr5+IqoMDO5wxZvL4Fj5xZ7nwvui8KnDmhojLAm LlNGkZYesbHtTf+judVA5IRke3aazhuDC8lFAH8LVklApYD8gLh1K+c8LgQsRXxP6xr2L1 zk2zHjCaqSOOXiTMF8Pwzo1wDbLJ6E8= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4PXSQl5b4qzKmb9; Thu, 9 Mar 2023 19:59:27 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 9 Mar 2023 19:59:35 +0800 From: Kefeng Wang To: Luis Chamberlain , Mike Kravetz , Muchun Song CC: Andrew Morton , , , , Kees Cook , Iurii Zaikin , Kefeng Wang Subject: [PATCH] mm: hugetlb: move hugeltb sysctls to its own file Date: Thu, 9 Mar 2023 20:20:11 +0800 Message-ID: <20230309122011.61969-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2827240005 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 34s54fd5nidbehgz9dz4kgtanod3mpso X-HE-Tag: 1678363180-376727 X-HE-Meta: U2FsdGVkX1902Zl0kbq9rzarhAycbhjVLAvQ9L88Fwn8uQGojXONd2UfLJnV8AJM7c8HPgOyfS5l8jfGL9dAO4/I/HWObe1qDJJRllb0ewjk/FZ9OS/gwpVbaPuHZwcLx3fBLoq+kL2o2drDsKzy23jT9+kAZKbt0n6jE/GVj9T35c0w7LIWJ7SRRS4CUYdbuEQbpznTX8ohOb4plHDIqi0jHQjlq7AKJYDg9JRDbN7MoeSS/vXmOQtuL3k0s0j+HWYUDnZd0a6+6BYNNsoJ0r2ZiEJ0LT6fIpJoq8lXMSiGbYrVa3eTG84Z2K6+H9Ll+K67W8dVqGbuvZALtbAKVlhol2J/0rtgdcQ4mrq9HXcWnVAtrhvLq/3fodNem2GwXP8L8AKtvirfssnYrIMKillGqr9fUANIrgCRWgUdKdURZZKK6+ymzymW6t7KTA6Bmj5mdxUbggYxhy4mdIloDHPU0WLpLUW/J03ASAbGo9ZFckmlZAouhWkEesFBgemIKb5klPoq4tWIYBxVvFQq+VNJZxK0ssFOpXtyuvFyE3BuuQMfg5KLGJOzPxh0VjoqdymYXIv+BwhiZmbI9GKSsQ4TSgO8DZSIihJfYcDzU3UilIChXRmR0LOIu5ILLsZDVqJpPOv4A0PcL96dpCRbhEkW/ITb/t++/gkPHzAivwwi2uUO/N06Fb2fT0qMRP6Bzd3Ut0iiR3dVOMqpPwZn+OaDtbBzyxe5HaV77Ggbgf8kp5+ICp5NpXWFWISglkehPqOEj4+BSosYHpHjObyFVU8mR/jNeIxyUC9OSi0yHhySCjmO5PazRFztsP0eLJanjQfJcYjJ1SryM+TJd6eRR8HXkhYGmGxJfE5jcFLTtYrljOjw5whERUT2OSz1ODYVCOGuaLZO9ksY91iLw8JErA4zKzK5uP+XXK9ZnpZfmaX/pfafkzzyZ93psM5Oh/+vPq/jeWMjCdjlrUibT1J DLnWIQGk GVzl5JlYpooIvM4cebK4A2PYUSDyX17DDeMbahP0mcUpUiRevz1SKFZ7khtow0Sgk7XH3vJXl93QupCCI7Ft6OW/Yc9oBbaKDbJL0VVSIK5B5dDggwUv0nJcGf0Qxe3ddCuDxUPRHb1uHFfMBqoFeKzYHEJr6HNx5pUah 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: This moves all hugetlb sysctls to its own file, also kill an useless hugetlb_treat_movable_handler() defination. Signed-off-by: Kefeng Wang Reviewed-by: Luis Chamberlain Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- include/linux/hugetlb.h | 8 ------- kernel/sysctl.c | 32 -------------------------- mm/hugetlb.c | 51 ++++++++++++++++++++++++++++++++++++++--- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 7c977d234aba..4056b05d81ed 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -124,14 +124,6 @@ void hugepage_put_subpool(struct hugepage_subpool *spool); void hugetlb_dup_vma_private(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, unsigned long old_addr, unsigned long new_addr, diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c14552a662ae..ce0297acf97c 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2140,38 +2140,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, -#endif -#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 = "hugetlb_shm_group", - .data = &sysctl_hugetlb_shm_group, - .maxlen = sizeof(gid_t), - .mode = 0644, - .proc_handler = proc_dointvec, - }, - { - .procname = "nr_overcommit_hugepages", - .data = NULL, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = hugetlb_overcommit_handler, - }, #endif { .procname = "lowmem_reserve_ratio", diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 712e32b38295..c44958a0f586 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4202,6 +4202,12 @@ static void __init hugetlb_sysfs_init(void) hugetlb_register_all_nodes(); } +#ifdef CONFIG_SYSCTL +static void hugetlb_sysctl_init(void); +#else +static inline void hugetlb_sysctl_init(void) { } +#endif + static int __init hugetlb_init(void) { int i; @@ -4257,6 +4263,7 @@ static int __init hugetlb_init(void) hugetlb_sysfs_init(); hugetlb_cgroup_file_init(); + hugetlb_sysctl_init(); #ifdef CONFIG_SMP num_fault_mutexes = roundup_pow_of_two(8 * num_possible_cpus()); @@ -4588,7 +4595,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) { @@ -4597,7 +4604,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, @@ -4605,7 +4612,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; @@ -4634,6 +4641,44 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write, return ret; } +static struct ctl_table hugetlb_table[] = { + { + .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 = "hugetlb_shm_group", + .data = &sysctl_hugetlb_shm_group, + .maxlen = sizeof(gid_t), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + { + .procname = "nr_overcommit_hugepages", + .data = NULL, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = hugetlb_overcommit_handler, + }, + { } +}; + +static void hugetlb_sysctl_init(void) +{ + register_sysctl_init("vm", hugetlb_table); +} #endif /* CONFIG_SYSCTL */ void hugetlb_report_meminfo(struct seq_file *m)