From patchwork Tue Sep 3 03:30:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787953 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 0BC1FCD3427 for ; Tue, 3 Sep 2024 03:31:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D25C28D012A; Mon, 2 Sep 2024 23:31:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B726A8D0119; Mon, 2 Sep 2024 23:31:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A131D8D012A; Mon, 2 Sep 2024 23:31:16 -0400 (EDT) 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 873598D0119 for ; Mon, 2 Sep 2024 23:31:16 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 46917120379 for ; Tue, 3 Sep 2024 03:31:16 +0000 (UTC) X-FDA: 82522001352.28.529DBDB Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf16.hostedemail.com (Postfix) with ESMTP id C7697180009 for ; Tue, 3 Sep 2024 03:31:13 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.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=1725334226; a=rsa-sha256; cv=none; b=0IW3KjdsSRKtrjVhJsHC1RHKr39w7tf6EV6FbQOQLP0pAhTli2cxGg3HC3d4xTGl14b89t 3cn4P7UpR3aPWKELiK/r8byRY30j0TiHYb+D7Xqq3hzRxvR65wph3cPJhIHSsOHk6/wYks ToXEyppUPBDtA4GWnQuwd8yqoYtxe1M= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.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=1725334226; 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=dPZ4B66OrpxX1lXvlzW3vSo48wGUSKYJIM1Kmd147qI=; b=cyN+Yd85ddgYVkUujdPGhutftwTj+HuceOcOYXjWXVlRkjNt/AsOkGUUX/jY7QtgiMr436 L8CcpAaAjNNIqF8YgB8wQNtvkFDLKe7e8bSXXFBbWCArRQ1pcp9jufDmt6fZ32UJdLx5pY q2TPtUv3L49wrTo9pOg/K7GeXz4b+r4= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WyWNr1FM9z2DbjD; Tue, 3 Sep 2024 11:30:52 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id CAF761400D7; Tue, 3 Sep 2024 11:31:10 +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; Tue, 3 Sep 2024 11:31:08 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 04/15] mm: vmscan: move vmscan sysctls to its own file Date: Tue, 3 Sep 2024 11:30:00 +0800 Message-ID: <20240903033011.2870608-5-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: ocgz5w9548gdggf6kktuez3nw75h3hqr X-Rspamd-Queue-Id: C7697180009 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1725334273-156854 X-HE-Meta: U2FsdGVkX18FFR9WiUyrT/tRpnGZIdCBPH7YcsnX8rqEaf6UI3IjsWr6i5LA7i+ldMwGBTVdNayde84f/hHP8TZFYES20qa0l7lLu1sQ9O6C/AA/VfN4fnvG+NsoHBDafdYz724cg/fhtcLeE5bj1zdr1ZIeHw2k2Gx8/NU/4fv2BP8iRMo7hZ9Khrgb5jZTwcOETCiFct0nFQaobF5Kx0bBgUDgDp0Q15iBcUImhXKpZGwY40XhGHbOKw9nzxygvPIZ+C2qKSf+U0ic+pJd2FcL/pu9KU+cuL429D80SC/Lq8i69AEHIrjHW+0i4Q1So3pkxXTOFclg88RgVu2uVB3VTIuxRkNwxeNGFrW9TaDZlXfHMHYR9zX5a8pG+tDlG5XxgI2lMmxCWQhFcP95EuRMZvLHsk6K8gYgP5nYA6LLSKkzkceHl981ZxgvHpea4sMw5+W87iw50KBWS2oPDQ//T6nsMItU4azP3wPoFGgeLYETVjmbLRxespCf72FUupCgmN4pIOrY4WRMSbWZ/0UzSSXrBzWu7w22RSsg+sKXllforOPWKP7Ed7f1BSGGEDHQca5SBe1ZR0GJxxHGHxI6Ju/tjC4zWnJIAQllGGuvLGqrZhLRqbgJXa3h/eTHAxyVG/fDL/FgJEd0sbSRUPN89wmBqjRau6qz59iA10rEhs7AR/cs2bgxcRICzo/+upi2SLcM1sCiKFu49ZMggpm+9q+lI0bN36KhdqMZfvkvbRnQM0aRjoy532J0Wi0g/LjNa4IvJLw1cQ2hTzd5juyje2tdmMjfq8fEfFhDUsiW9+YixDr06ctycnavkkFd2OI7jzuyGj7huVQKym4TWkr84girQzHuHt8vzcWG2dYJVBv8x94Wkr0aGi45y9pZK49gjHj8nTRx0rE0mfrOeR5r/JSDRWmiv9Jetzq++HuIqe04ATyDer3Asb78YY60IwwNmHJluEVlwSBUVVR rVFmMzAv nOoZbbM58qQkORIT1K0zPQUQvTekPktok18EtPhUP71kdiF9uxmVTUx33kEpHj3RCZIMPt6QiwitTx97m1eA9yjSi53mKo/sPAb0x2DNOTZK/s4g9qISHYtUDNIqwMeY0PA+TvXbOub4GoS6v+liP/tRQMU9hXF66sezJVPx7mVq4JQA= 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 its own file, 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 --- 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 44c8dec1f0d7..482e63d70d96 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1029,9 +1029,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) { @@ -1043,6 +1047,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 a9b6a8196f95..b736fa322935 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -7373,6 +7373,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; @@ -7380,6 +7402,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; }