From patchwork Mon Dec 23 14:15:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918957 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 57EEFE7718E for ; Mon, 23 Dec 2024 14:19:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D57DA6B00B7; Mon, 23 Dec 2024 09:19:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D075D6B00B9; Mon, 23 Dec 2024 09:19:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCF2D6B00B8; Mon, 23 Dec 2024 09:19:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9F6FC6B00AC for ; Mon, 23 Dec 2024 09:19:53 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 569B3160DD8 for ; Mon, 23 Dec 2024 14:19:53 +0000 (UTC) X-FDA: 82926431154.25.2551515 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf04.hostedemail.com (Postfix) with ESMTP id 471FA40018 for ; Mon, 23 Dec 2024 14:19:10 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 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=1734963556; a=rsa-sha256; cv=none; b=vyqykacPwvi+gg9ptHm5jsI3Pw97PPHwfHtf+te+RcSTvbbl4g3karNmxZDXNaDYcN+pQo XlrmYj6tQH9TkxW6wkFWVzvRp2dtnwV7ALK77pyKYCiJuvYZUHzXBPsJYrU6Sb/rVsAa6N MFXVIjsI9KzvxubVgUbohNIIHyhnAxY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.187 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=1734963556; 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=WKEVQHK7MVDBjANLmmaSRBhSq/etnnBN41/pFyN8PW3CbFFOc6Sp+HTxyWFfef89dcVZ8V trePeES3vsr6a1zMqqCcTfBvQ31GPGskUeQYJYq1vkDMKMOPrvtVMfG84zLxL9A7Ki5jqd F4uWztIgKQum//AFHOUe0YGoVgZsdzE= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4YH0ST4tLgz11NKd; Mon, 23 Dec 2024 22:16:25 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 44843140391; Mon, 23 Dec 2024 22:19:47 +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:19:43 +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:23 +0800 Message-ID: <20241223141550.638616-5-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: 471FA40018 X-Stat-Signature: hs9d7z5th5n7hc76hrtqet99xspgu4e7 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734963550-189964 X-HE-Meta: U2FsdGVkX1+pW1a5ZnsHNmn/zOLbF9kR31pvWlt7H6fV5OE8SCGDc38BK9G0OF/0S0WNWY0mmlaRO7munVcWV2UPirCsSxqsnzaQC1NdLG+ZhE3sPx8EdLEDPdlcfqeBik/Z8lAiZ69r0rqFPD+6k/OAtskp++Z7dDKrOxp35YFhb27CpyrMCfET098XbHEGWRlVZ5XzEBeYPPeZ7j4Noratii7IdolurepAnbTs1FOa02ockNNGhhQr5jwjr29X17Dw1OrMdSsxZKaF6XP7oMpmlsV4yod2pKkQ3tV/z00Aj54ZQRSUBP3r61drdeN1YBO35geei8iiTVY36zLUT39ZZr2NhJ2fQrUWQGHrAtgTjYEP2DEF3i6phzOdUoPaHGq54Vbsq/dMM4cLFNbiBa7TC6Ks3W9y4dVsl6Pj/yoH/KomCvOp5LVq1qJhyzmcK/1Yj+xP7EmLxzwmo3uQaWcSZhwPYzaY0MhhkbMitAPVMct2gAS5AUSR+yUKP4I7aPX4cTIcZdB7qzEUUFWQWOcgPTAr8ylFPoCAkLjPsRXXxYtKC694eqOc/qM/OMhJjwEGsVDLlgv3ffuQM2BZrNXf1bBalRmK3KZBtdaImm/4dK/Aj+F0vwFQwG5qoeb5/GQlXF72KOCtx3MEGOWwvJ8MWIEtpkO2/JrM7LPbYI4L4UZF9/N75EUEqW4zs0VtXIR1Uef6nfF9F8Lzz1H3fXCWFD9MeHy/U5tANyzRdy5rKp39eQaWxTyOSSpOdnM9RpQzBR3hDEXySLK7cEVOFmA4q8fW2SeKXv3LOKT3IqjmCSUNk339XRo2Pm2RoZ6mvgJK8PAilcYxXLHQIuuPv5S8qTjgVlWR7g5HDUy6dirgjBgsI1TaTYCaYa38Y/2fYpFnu0x3kxjSy+y/1KutAlrRyBsaQiEDsBNq1wxbl47uU8GZd4K9cf+mLSJ/m7/cDlFI9BEYaV0segw+jOL gUdG+pvo Qu+pr306hR1zotrOOisCgtaHbAfCMGYS4H5E0ZEJfunHwHXrEvUXJH17DTbMuhxMdgvlS5Mi7wgA98q/3e39cI5AuDX4h7/RkeXigq/6TPpgwDS6yBCVUGA4gobX16tEhK/YCsYWH6jdqhUSvVzQ+f9aWkXjN2MyBGYjjN+ZTp8c0gv4= 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; }