From patchwork Thu Oct 10 15:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830195 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 92800CF11F5 for ; Thu, 10 Oct 2024 14:11:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 397FD6B008A; Thu, 10 Oct 2024 10:11:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31D916B008C; Thu, 10 Oct 2024 10:11:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 149606B0092; Thu, 10 Oct 2024 10:11:50 -0400 (EDT) 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 EC9AD6B008A for ; Thu, 10 Oct 2024 10:11:49 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 86E76120140 for ; Thu, 10 Oct 2024 14:11:46 +0000 (UTC) X-FDA: 82657881138.30.64E20A7 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf20.hostedemail.com (Postfix) with ESMTP id CF8D51C0025 for ; Thu, 10 Oct 2024 14:11:45 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 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=1728569369; 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=yW/O80OCskqq9OCT7qIQ/2hREsg1DGEceF3YaqJVfrM=; b=IrUTlJnYSLwqDkAxl+J3FsFkJARTATHx4XmbUMlmEe5e33tNdiaY7Wp7eAQIG76d5mnDyW t7pEJ0Q0pgVnHZ+VrL06AuG8zrI/CPcYkWArRPJ1iXCR04emRoa6HXUxvGGLodOXt7Ibwb PEg5/9x4bPZUrv7oMUkB2oQxP0gtlyU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569369; a=rsa-sha256; cv=none; b=L8YSIWvZfcmVRS65pSwIZqbrCh5PlpkBNN+39o1XWNMLaxgNE0WVhzX8jolQAzvhbtpk9A 69hCQw96IUmk/lyZqW3t3ZLjZPqOpFgFOuU0JWF/AMwqQlKxsNDGnE9IZgQXOZmmk7orX9 bMk8PImSMV+AYY2Gsgw37Lb5dEXIylg= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XPWmS55yMz1HKl3; Thu, 10 Oct 2024 22:07:36 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id A35011400DC; Thu, 10 Oct 2024 22:11:43 +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; Thu, 10 Oct 2024 22:11:40 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 04/15] mm: vmscan: move vmscan sysctls to mm/vmscan.c Date: Thu, 10 Oct 2024 23:22:04 +0800 Message-ID: <20241010152215.3025842-5-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Stat-Signature: ouek8yhxafeo77g44r451u63rad3xh1i X-Rspamd-Queue-Id: CF8D51C0025 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728569505-920086 X-HE-Meta: U2FsdGVkX18vSKAIYTGe6eSBo6ydsBR1gMQKgCKzYbp4b2FlwxTV4rYGSiPofgNu2ncn4vzWyGhUIrAvXPY5X+lOSlfmMiDwZiafcM/KqDSk1SecFDG7pbe1/TYQ70jfiHRio5M/oMl3o/4XC+MVpjpZezIhEUzNtH0r2CG7ZEwaOveh0HOiCsEWddkDh7DioQa3G2kgCw4wRIKINwt884e/QDNqzuTWE7spcPKaTqmf3wHiio+BkNeTKqMFRJZfVxR4cpri7pMRGSZWMdxLME0PZUaDYuBinQM9j48bFDabrOo//yxza7sAv98QvXuDSKoAtqIg/5YpqgnuOpwYVk8XLQ97I3BUNjKIYaUjQ5cmZ+B2kNh2ZROo+Inx+l5u2RIfRoymGdfegFhTM119Mt8me/bcInYFpOd2vOdBFbuXaWlLXPELRi9dzsYTzkCNeL0Pr2HNjqj/dsTPlo+evhSsIgiTlSfntukWmyPMyzrdUZSN1PjxVDBLtzQDavtlnpAogNO1ZLHPYy6KNBec50lozqTjI0ufu3OOKNPnhUvk7FsOuHbtkDGw2/v0/7/AC+7Oa0FtLpmQTRcLXe6KZcj+BWYXMTcTO0RcyO5eA/4MV/Kb6DdeO3Vm2MBOMpNOcGUS9+Lz9+O36O/dZpVod2FPxAoz252d12SfeVfRMWr3IZZt2FFwdv927cUbsyL1e37ajlpBc5CIRzTjh6tte4/EGi5QlZvhyyJSdcqI+5e4Ahyr12SE274JUvglFqEFVtX884V+ByTG5uF21ejAMmIOYhGG2sP9Dw2/iB+rK40xPe7OV/I2FZJb1Iv674aUURj1g5ZHETtq6RLcAgF7fe/aVDtFLCXJbE+Yb2cNs5OO4odds9r/+FKyFN0hZfxyZ8hAvmh/l3PxL5jnqxhtnNnBZZe6oP5igj5dVJiX6CGa7MzoxM54/pvgcea6xBs/5AhkDkuCCwaOZHMF2eP +k/VseoY D77+zOOzn4D/qKxpsfQRj3x1dp30FFKlGJGvkBuG1qB+SPaF64cVLdVkB1rZcFWiEf7KQATxYurKgkHoh3PlyCDdSIAbowoED4ZKEdv/aNzodP1kf5aDE8bkcxiF0RSzz+Fvu1AxErxqmMwpWM3T+QapZDLLLViyxwKc9xXWOd/+7bOk= 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 --- 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 ca533b478c21..c95fb8d87b05 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -425,19 +425,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 9fad501311a1..184d39944e16 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2061,15 +2061,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, @@ -2117,16 +2108,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 906da6280c2d..84c46fe6a07c 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1038,9 +1038,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) { @@ -1052,6 +1056,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 f9919b522c01..1188978e46d5 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7384,6 +7384,28 @@ void __meminit kswapd_stop(int nid) pgdat_kswapd_unlock(pgdat); } +static 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; @@ -7391,6 +7413,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; }