From patchwork Mon Dec 23 14:15:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918972 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 EA701E7718E for ; Mon, 23 Dec 2024 14:20:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78B476B00D9; Mon, 23 Dec 2024 09:20:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 73B516B00DA; Mon, 23 Dec 2024 09:20:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B6596B00DB; Mon, 23 Dec 2024 09:20:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 36A546B00D9 for ; Mon, 23 Dec 2024 09:20:46 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E1073815B5 for ; Mon, 23 Dec 2024 14:20:45 +0000 (UTC) X-FDA: 82926434430.28.5DB99B0 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id 837F9140002 for ; Mon, 23 Dec 2024 14:20:14 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734963600; 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:in-reply-to:references:references; bh=rjfvDvGC+RNbFh+4I8dtAyivcxgIKW/Ns7KG+z0vGWo=; b=QsJSK/Hz8i68Kdks6+yXVyudBPCx1/MMce3xuFzmPNnfDw/K56RpJwVEh2HKH5TatUs3NP GXqIDq02ui2kZIDMgDugzXZd7/m6ITFSBK65AqktjIsGHAIPjrSy0LUC6a3sYSvTA/6WX3 Tu45N/JQA4KrE7WyQFvS0KI59fY/znw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963600; a=rsa-sha256; cv=none; b=JL176v8V7TTlSwGGgGmBiGD1J6EvN3MmLkIJxFEDQIPhXOxrfRl6G6AuVWpsGooqVsbkpc Vhs2yRnKuuDkvv+vifEQR/wdAVlpdnWnE0ZUYQp6wfbRu1jNqYX39MVcUFbzo2eIKfvwHR ptxefjZ71AArRR7iSgPpgyCLG3eHft8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4YH0WM6TXvzrRr1; Mon, 23 Dec 2024 22:18:55 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id A1CF51800D1; Mon, 23 Dec 2024 22:20:40 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 23 Dec 2024 22:20:37 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 04/15] mm: vmscan: move vmscan sysctls to mm/vmscan.c Date: Mon, 23 Dec 2024 22:15:39 +0800 Message-ID: <20241223141550.638616-21-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 837F9140002 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: hs9d7z5th5n7hc76hrtqet99xspgu4e7 X-HE-Tag: 1734963614-940621 X-HE-Meta: U2FsdGVkX1+u5jbeoLCByMKplKPmrQPwZVb33l8ZfgqLHVCyjqL9oKGISkCF4QOIEAy5FHvzH86lJqAO2fy6dw86JVmnTg+3bTTmGM7jP1zBggLhLkrBa98AZ4s+MHJ6UAnfFJFGuqubY7BQHNxnmBCN3WE4McOHhKruhg0gBm+OTrJVxYgqQg3RjzkhS6nsC6WIHX64ubsh1AdzwML+mGhLpx0D2Wcxk9VASmYBY0AxMtFDz+RdMXt4FvGBq6bgEZoxtNl0lxnb+t9iykNRnNTfbeC4cTfPgmCPQ9Pfcy9e+QQ1863qLTk6yWoBWLxuHK6zW2YxCtDPnWwbLLrxkPYOhbBP1LOM8K10kXHcWAhiI8EsuIq5gH4CG+JTte7aekRbejypnidtcVn8tW2jkhh8ljZyGdfYtIAnqj1c6wZAKRDF6j/TcWXIBI7mxob0qE1EyV2hUOaa5UdmD8MBx7k3PZ1oDo7BG3hh37lX9NosHW14k3INAhExV2ct8fbtipniGtebQKAKsycStvs8CyVIVWSmWLhM7nrxcCnkDTi03r639KQVDrCAACjprhc83Toku0OTjo12GYfNZ1fAke7b0P0AzB95sFyPccXtLIyDKl29tyJVIi4mqlCkMIRjvhZEAvJADID7t2K5ZXjGpWGqinODcTaLIWCFAavJtBBMLI1KkCbevjMojmwsfl+iVV9T2co5YyUjecL1YtbiTzQNxhEv/XNgbGXIwUz334G1DvEQdqcZSBECRIz3Q67PB23yeY/RkmOqI9IKsacdEvnvQ0Xma6uLcreco/JyVYQrypQt6YVxsXfLf4R1pDOghFViI208L0rblyLl9xYtIWgUHhBfkxO0mN0QUZYxks2bLMgJgJWuz0owzUksEM9eN7LsYouhKUdkBqKfqo40T2iZMIuP4iQw7+LcbuPMx/3chT0E4uw2gfiu2AE3F3U8ZZm1tq509lRfQS4T6CD CgNEkP7O FcQ4iYi6RcNqC9KCTKh6jLrKTXm2VKmIzBRg1F+8pgU5NDAJ7uq+Yc1Owb3inqOLT3y0RM0QXkqrtVhv6WKqEBoAkEjTirWR7hjLrRRsUvTYB0xaRW7cvI1N7qxKAsvEWGPpM8HUiRllO+0CHZZdNOqixEeRjdP8WemrYGHiFV9l+xiE= 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: List-Subscribe: List-Unsubscribe: This moves vm_swappiness and zone_reclaim_mode to mm/vmscan.c, as part of the kernel/sysctl.c cleaning, also moves some external variable declarations and function declarations from include/linux/swap.h into mm/internal.h. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v4: - const qualify struct ctl_table vmscan_sysctl_table v3: - change the title --- --- include/linux/swap.h | 9 --------- kernel/sysctl.c | 19 ------------------- mm/internal.h | 10 ++++++++++ mm/vmscan.c | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 187715eec3cb..db1a28683e10 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -427,19 +427,10 @@ extern int vm_swappiness; long remove_mapping(struct address_space *mapping, struct folio *folio); #ifdef CONFIG_NUMA -extern int node_reclaim_mode; extern int sysctl_min_unmapped_ratio; extern int sysctl_min_slab_ratio; -#else -#define node_reclaim_mode 0 #endif -static inline bool node_reclaim_enabled(void) -{ - /* Is any node_reclaim_mode bit set? */ - return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP); -} - void check_move_unevictable_folios(struct folio_batch *fbatch); extern void __meminit kswapd_run(int nid); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ab5d94f07e53..cb6ca272fe9f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2051,15 +2051,6 @@ static struct ctl_table vm_table[] = { .proc_handler = dirtytime_interval_handler, .extra1 = SYSCTL_ZERO, }, - { - .procname = "swappiness", - .data = &vm_swappiness, - .maxlen = sizeof(vm_swappiness), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_TWO_HUNDRED, - }, { .procname = "drop_caches", .data = &sysctl_drop_caches, @@ -2107,16 +2098,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif -#ifdef CONFIG_NUMA - { - .procname = "zone_reclaim_mode", - .data = &node_reclaim_mode, - .maxlen = sizeof(node_reclaim_mode), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", diff --git a/mm/internal.h b/mm/internal.h index 39227887e47b..ea2623dc414a 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1095,9 +1095,13 @@ static inline void mminit_verify_zonelist(void) #define NODE_RECLAIM_SUCCESS 1 #ifdef CONFIG_NUMA +extern int node_reclaim_mode; + extern int node_reclaim(struct pglist_data *, gfp_t, unsigned int); extern int find_next_best_node(int node, nodemask_t *used_node_mask); #else +#define node_reclaim_mode 0 + static inline int node_reclaim(struct pglist_data *pgdat, gfp_t mask, unsigned int order) { @@ -1109,6 +1113,12 @@ static inline int find_next_best_node(int node, nodemask_t *used_node_mask) } #endif +static inline bool node_reclaim_enabled(void) +{ + /* Is any node_reclaim_mode bit set? */ + return node_reclaim_mode & (RECLAIM_ZONE|RECLAIM_WRITE|RECLAIM_UNMAP); +} + /* * mm/memory-failure.c */ diff --git a/mm/vmscan.c b/mm/vmscan.c index 39886f435ec5..10cc05b5952d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7351,6 +7351,28 @@ void __meminit kswapd_stop(int nid) pgdat_kswapd_unlock(pgdat); } +static const struct ctl_table vmscan_sysctl_table[] = { + { + .procname = "swappiness", + .data = &vm_swappiness, + .maxlen = sizeof(vm_swappiness), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_TWO_HUNDRED, + }, +#ifdef CONFIG_NUMA + { + .procname = "zone_reclaim_mode", + .data = &node_reclaim_mode, + .maxlen = sizeof(node_reclaim_mode), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + } +#endif +}; + static int __init kswapd_init(void) { int nid; @@ -7358,6 +7380,7 @@ static int __init kswapd_init(void) swap_setup(); for_each_node_state(nid, N_MEMORY) kswapd_run(nid); + register_sysctl_init("vm", vmscan_sysctl_table); return 0; }