From patchwork Sat Jan 11 07:07:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13935835 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 BAF34E7719C for ; Sat, 11 Jan 2025 07:12:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59C6C6B009A; Sat, 11 Jan 2025 02:12:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 525E06B009B; Sat, 11 Jan 2025 02:12:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A08A6B009C; Sat, 11 Jan 2025 02:12:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1AE2E6B009A for ; Sat, 11 Jan 2025 02:12:37 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CE4AE160A2E for ; Sat, 11 Jan 2025 07:12:36 +0000 (UTC) X-FDA: 82994303112.08.FE434FA Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf09.hostedemail.com (Postfix) with ESMTP id 518C9140006 for ; Sat, 11 Jan 2025 07:12:33 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736579555; 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=u+kpxXQ7n3Azx1RGE25K0gJ5xLgBOXqzBRbO/YM0rKQ=; b=PwVBTWsO9XJtSeiUfYvWBr+HuoxEjyOflCAuYFFX9i5DfDKnTg8FFr8tNDukvRGLnvbyft uY8OgTgtUCM1VWoCOro5FFLPO/ODkk0cvjKyqmsvKiBcvcK5hurBFGKbhtyoACG6ZECUPO lXG4DuAoi9+Onix7Kuh+jWhJFmBOu5o= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736579555; a=rsa-sha256; cv=none; b=aBeBYah2YNaVUwNb6b1atBZEff+k6ZpOsCIZbgCmVqHQkNxJQAebJC40IMCheo6QPBXfwH nvSIRSfI6F2i8drMmz7MeXggM2VWv1wcCaOHluO6tVqfWuQOpJdFbmugIZBupM2ozxrRcf g+ANROR1zJWeEVaVEDfCn2YzezBAnqU= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YVV516XRFz2DhnV; Sat, 11 Jan 2025 15:09:25 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id E72E41A0188; Sat, 11 Jan 2025 15:12:30 +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, 11 Jan 2025 15:12:27 +0800 From: Kaixiong Yu To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 -next 04/16] mm: vmscan: move vmscan sysctls to mm/vmscan.c Date: Sat, 11 Jan 2025 15:07:39 +0800 Message-ID: <20250111070751.2588654-5-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111070751.2588654-1-yukaixiong@huawei.com> References: <20250111070751.2588654-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 518C9140006 X-Rspam-User: X-Stat-Signature: e7wmptjjgwtoeatocepy7bg7g6fizykj X-HE-Tag: 1736579553-736030 X-HE-Meta: U2FsdGVkX18i/MdkB0uzChcovicCW5/8vkZYm/00b6h3XpsSN1UkUo39PuslZrJ+yrgbY12hstfx1H4dSeb5/JQKYnyOWmfmTttgRJN67MVdUvhEUHMXXH6UTb54jEDHFN2DChodIfWWoYPM7HhC6GbsXSDfSVqDPkTpySCCR6urewHiS0olKxvvXB0GibBSRcV7hP65089Uu7AhlecyJbpI2HXJCle/QzyZO2NeoVFgT31unYhHDJn7kthiDIEiosEXD88lziTG1pbC20kHJLHo35wCefiOcbv868wnq/ulDBtB0qbhVS0BAqlkyAYhaHUwpCMYKAqeMNrhK45Xv1sgCIQkkjY2IqAC1PcXUmB4x3dZ+39o1Zx2s6gmD7wQWOOKU89/RwMRgek1kmhXTkMEAszPkxKU1TgGNHsBpUMqot2g2sT5PCbKSx9dZWtdGGLC3Mxq2r2SjmvSj7HXVbBtU3rN9gaq5xoMnmJHNYKjYUD53a+A0fzzc3o7lNtgi/MkL/OMx9MDGhfoGNMM1g0TnqqEmiZ158gXE4RlQFugrYUTm5/ALpHJsIREZnBa58JETg8OqJi55gZ09W4tVLxyiA2fNi7rQ/AcpLKNhX/dpFK3ArWz8qc8ixBqvN+ET1OBtXhlhwlyZOvPjHZsxcK79CgFuPg0cEyBWN/PPpqnAozcDMCNvx52te49XcypWVqsLznf/+ZAQ2hJGq7rGijXkf6W0MLaUkFgbdEY46ejJJO/CqGhsL+8rfPbLv9cdIeTQkVCWk/HZr3GgOtyw/JECyrtqNoxzJBEqEFaIyde5Okg2JRZFFPECMj5EqRF2EYQ2ZYQgYxfCCS6rJT6oy0dyB2iT/jljrzXvXm0PGBkkJrctFMLQ1OP0nzmUpfB5L4qJIf63rQ7oUgOR8GC+P23KEjD+PdI02ecVZgNm312uOGTR10xzBNRQcpRwXeUd7a7rslR3HifvfMJ2q7 BWmOMeVD ya+JR5Ww6+Y5VuTdpoUGqGsWtsAWyVfhEweN1XdtwfxyjsYRpu+4GqsfpcZ1AvVscbpZVv1XAmxwp+DsJJ7HV1F8E3dUnG0bJYPtnaL/mJGzU29R1Hin/zq82mkRemIQkpz4pnEyL4AWqVdOiokMDYuOAyQgZTsgBCBEFox0an0D0CbY= 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 b13b72645db3..a98c757400fe 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -433,19 +433,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 109ef30fee11..cdbbe4c215c0 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1097,9 +1097,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) { @@ -1111,6 +1115,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 6d06bb40d5ad..f1183519bf41 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7404,6 +7404,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; @@ -7411,6 +7433,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; }