From patchwork Sat Dec 28 14:57:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13922366 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 96514E77188 for ; Sat, 28 Dec 2024 15:02:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 263026B008C; Sat, 28 Dec 2024 10:02:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 239186B0092; Sat, 28 Dec 2024 10:02:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 101676B0093; Sat, 28 Dec 2024 10:02:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E72196B008C for ; Sat, 28 Dec 2024 10:02:02 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 991C381722 for ; Sat, 28 Dec 2024 15:02:02 +0000 (UTC) X-FDA: 82944682464.29.642C339 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf03.hostedemail.com (Postfix) with ESMTP id CC9A820004 for ; Sat, 28 Dec 2024 15:01:39 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 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=1735398100; 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=ggjA+8DmHNg8Dx2A8D3lN70W4hP6MJQsmxuaNUFJKfjgLkV4gmDIeO87grjaftzy+u7iL3 lonFClX6gQYG3dLEd3ijWJxNift+nfPj/LxPx+szV5cjjYuBKv8zw2Okjld/b2HsDc9rUf pjI1hTgiMlnGXGrwm7rVTI1wXldGisE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735398100; a=rsa-sha256; cv=none; b=tvLo8sFEmgJXz6TqEGZEfMuJR3v9p/2jV/PqW13wKxEg136cqDdFmzrK9lm+CWI8lVT7jo Tr4EpEoPi4FNLF9RFspRC0uOt9VmVLFjQkRcIfBRnQFCdSvXCXmbr4XKWrgQdI/UEacbDz GeEhrtCI9ZRxdiDcw+d/bOqs3tjC7Eo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YL59S20XSz1kxHY; Sat, 28 Dec 2024 22:59:08 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id B02AC140136; Sat, 28 Dec 2024 23:01:55 +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; Sat, 28 Dec 2024 23:01:52 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 04/15] mm: vmscan: move vmscan sysctls to mm/vmscan.c Date: Sat, 28 Dec 2024 22:57:35 +0800 Message-ID: <20241228145746.2783627-5-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241228145746.2783627-1-yukaixiong@huawei.com> References: <20241228145746.2783627-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: oje65kpsqnzgfqfo7cot3mcf4x81nnt7 X-Rspamd-Queue-Id: CC9A820004 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1735398099-900435 X-HE-Meta: U2FsdGVkX18nsnkygSjAjEIZwlKmYF3qBaTWBOmDKAcpZGPGzXfjrUGFmXOOqRCXlcZp/CTMomZq0iWsQIMctIEciJu3Jq4RR8G+3+aO4nw4JvA7pFosLViohh3N6nSfVXlBtV3NFQhb8PSndzNvqdVLAQ0xc5owUU/FG5ri0nuW7ZzSNy1jsb3a5n8IQgQiDK2AwjiM8qaHXVIJtfhouVWVRbO/vybpCXDkd2eywHZzdH0BvwkpDr/p4Ad1O0rdEPXSGZ/4/WpSqX/OPblGQmwddBklrtd4lYMHvJmbGPdTiZKkZ6aiZssYJj9B+9FO6GLob0aS2jYmLcme6y0w8q52wP7Lc5au3qPckTXCr5XJw/KPGoTYodscbAHhRk5IEtDSYOuxnpCFn/dgkWIfZahLlBVyizjcav7f4UFIcVyrUUi23hjrhTIYDOk4pj/GDrkWPUlcagc+0lwKxXcPxDFBBZxdwp5Tho4bhUU7B5Bmtp7qH+fRy5DtyXFCF6RgB4jIAK2cNRenIJ1D5Od0hq0RluxQkdFVHPLb1R0Y4Z3cPHjEf4hnGSdgU7JHQZnRbXd2LRMvJ3I/y1861HtwQXqYY4LfdfmODpqOseabh1RQGIG67slshYxuU5uwK23Gk0Z7QDL2w4UT4ZUek6TajHZFX/Wrw0/tAVHl1rK2Hg0qP3ubOkuopfG61ZMT4EpHg3nikix6UvfIQV9irQsxTA71UKZM0JrDHNdXbMkn0EYBuaZyCK7zFEzkdCcB1Mz6ab23V8OoW6okvEiuPsrJjfMsHcVX4q9mbEt4tmzx/2DC9G9Twiv9nE8MQh9/nqfTBbZuPuuAkosmJ5PBx16SGSaZ9QvlxL9K0GIo3ivSvjF2WJ/QqqVRDsz13Cy7d+CzK38Q84vpTMOrd3f5k+NHaWy0Ox7pnHCjKREO7xeKMlVtDSAdwk+fSZ0Ngj8qJy5w7sZajd3PGItRRnxomJs +78mLfLr vP5oLDgH2sugSJsqJYvDdDcxifnU5Yd8zKzqhM8A0tLipXh1bjdrXJkiBiKXqUV3BIHRv3Ip4hZcsmWg8PH04lXMl4oeeGeB/eUtyBu25PZneu3mf0vGZ2SX7olu3Dqwuc5P8lB0Dm5uCrd55ZhTov2pM08MXcHwQiqC39b5ABVldck5NhdNqEEcQImsN/fK1GlSrCBoBxvq+ctiTTkZtnZGeIylsQa2hMHYTfuqZU5jMm6y1uxD7h7QRZhOkw48BsHYoUrT8RqGxdjI3vUEbTvQf8r9tWXK5Uek2FX3/aJgACuiiDs2iBLTJt5f0w+6JXkMY 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; }