From patchwork Sat Dec 28 14:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13922365 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 3E584E77188 for ; Sat, 28 Dec 2024 15:02:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFFAE6B0085; Sat, 28 Dec 2024 10:01:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB0D36B0088; Sat, 28 Dec 2024 10:01:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A78C36B0089; Sat, 28 Dec 2024 10:01:59 -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 7F7C36B0085 for ; Sat, 28 Dec 2024 10:01:59 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0709C1A17ED for ; Sat, 28 Dec 2024 15:01:59 +0000 (UTC) X-FDA: 82944681414.22.7D91318 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf01.hostedemail.com (Postfix) with ESMTP id BDC6440017 for ; Sat, 28 Dec 2024 15:01:22 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 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=1735398096; 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=4RL/9lE7KC55TAt+DcK4y1ybUzXuOOxoqDbBIyF0dTA=; b=6VzR8bzW93grsudxcj+2IMJ4v+p5h4ARZZckJGBhtrt1juIq8cqBjdr5JE+8GIVWQyyWvS CngrID5Zm/DmSOb0FelKWbPnB3K8YzHPP+1T0xnMVNF4Jtr1sdKJoNZtJdY4rCfnAgUBRt 5Dpf0Kd4X19Xfv4Og9aFmtFZ3dHXxuY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735398096; a=rsa-sha256; cv=none; b=kX98eAUnfr8j2TxFjPAiAt7s23wtrW2Bbo3ig0DlBUjgCw8E7g6C/WF9aaMc2gUb1SZPq2 Ic9bnd0Y1103pigOSxHEOCAyuTAztqArCuW71HlsgDJ0ZOt5SlKA2UAJ+HznBx8049p7yv Vyb0draAXqeIq329kXCoKPYdzXZeYC0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YL59N0JR2z1T7Z7; Sat, 28 Dec 2024 22:59:04 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 3E452180042; Sat, 28 Dec 2024 23:01:52 +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:48 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 03/15] mm: swap: move sysctl to mm/swap.c Date: Sat, 28 Dec 2024 22:57:34 +0800 Message-ID: <20241228145746.2783627-4-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-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BDC6440017 X-Stat-Signature: 9ntmgzug4myp8xu59qqcuakbwywcw36c X-Rspam-User: X-HE-Tag: 1735398082-5178 X-HE-Meta: U2FsdGVkX1+a8tklnkUHz3rocK9d634lBL+bYdL1RD+9ladqXymz67iuijGECU1W6e7uCTXGCAvtO0Ako4fAeEGp3L1/SK3Jmc09P2Mqr4nR6NRaBjRy/AmVL+7IOIVcSdaz3JX+SJbqCygFCYyfy6ZrxpQPtpLgUpzlas/Ig0o1ZDB0uocxSeB9YII0DoqoWCWeseSxZBeWBCQl7HBhYETQoONmTDIPddJvJnSWEHdaWW6l49ZlFSnu0m/r+EZ0cNFFqpJn/bbYjXXVgCGTjX+xTyZQ7LIOBhVsTWUU7kZQPinBD/Uq+CmT1QmDYbQkhqp1Di9Rr/fpLmc1GzDtdxtr2Pfp565HpeqYj0m0BThM7gb1J/pCfgi4vb7tBsUBOn7dtQYGUcYYm50Q8tCkGmiuqiOVGwj7eloLmzSs6HdtR6EkIKEy2AQHo8JkSSLzOCcUmp4BaTU9/bgGaWSbT3DyOpkg2z7LEDPkH4zEXObPhxUdUqERfd0cW2Tecbuw0vL8vMXfACwCC1zIZj3SIkw2KUbSpamhRuWBbeiNwv8UtmLgVGkuo+Zn+z2x1ftPk/igRqXHCA5zqpYjoUIkqssr+x2Pu0iwMQBwq/zIumdR2ffm+y8ft9c3z3eNTqVo4vgNsb29UpoYZDkP87PABmz3pCJ9LI90+skulS/vGWgHkUEMeH+ON+Ce3T2dHbZSKKaO0KlOn3Vw6xOMvYX0199Y6vGnI3pww7MXlGpKcyagZPK4POuZ2V0atRmJfv+jNnX9+0PMC3zn7yt0a0AO2F26abU9x4dT/eliD/L3nWPbDX5K4+VrYONTgQd0JE3fRvPsSZqal/OxkHNBqQcE6C9KrwyWteoNBwhugAWwGfxmjoJrnmflaEvmO2AfoVMdpw836cqtO2fRkkJ+lNsJGFW9Lt+05dHmj/0yyaqGQAyPvKFQUVTGyNlg9evgUxAL5u5NyeW7ovD3WvsKxST 7B7SkiWD Ainfz78+RR3QhOsGX1Tp5HXjYfe8Uz9c6L9E35V5wHi37D9aQmciEOvyJBz4iLPLZqA9egrts25ZKHRo4uScqfVkn3d7iaAfG010zvjpAtxwMC+u4+lr8MXFhsBAEJEyTVi6qj68Pz4BryKcbysFaUL5RJ4wGv7G6safeaI0gYPZEqGhi+8G9EPMEU52Z5446552KXOK18UVlwd8gARe893nWVGSBu2Y3IEJ9BcvoD432Q11Nd6dxi0KlnScXFiCeBY6sx1vtcQXxCzFjVumx+F4NU82R9gjz/0iRP3JCR3WCJUyyuwJahN/YPD8C/NPEr7TE 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: The page-cluster belongs to mm/swap.c, move it to mm/swap.c . Removes the redundant external variable declaration and unneeded include(linux/swap.h). Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v4: - const qualify struct ctl_table swap_sysctl_table v3: - change the title --- --- include/linux/mm.h | 2 -- kernel/sysctl.c | 10 ---------- mm/swap.c | 16 +++++++++++++++- mm/swap.h | 1 + 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index dbdf8950d681..8941ba3d9a77 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -76,8 +76,6 @@ static inline void totalram_pages_add(long count) } extern void * high_memory; -extern int page_cluster; -extern const int page_cluster_max; #ifdef CONFIG_SYSCTL extern int sysctl_legacy_va_layout; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 23c8db80da5d..ab5d94f07e53 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -2044,15 +2043,6 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = overcommit_kbytes_handler, }, - { - .procname = "page-cluster", - .data = &page_cluster, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = (void *)&page_cluster_max, - }, { .procname = "dirtytime_expire_seconds", .data = &dirtytime_expire_interval, diff --git a/mm/swap.c b/mm/swap.c index 062c8565b899..d3344123381c 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -45,7 +45,7 @@ /* How many pages do we try to swap or page in/out together? As a power of 2 */ int page_cluster; -const int page_cluster_max = 31; +static const int page_cluster_max = 31; struct cpu_fbatches { /* @@ -1072,6 +1072,18 @@ void folio_batch_remove_exceptionals(struct folio_batch *fbatch) fbatch->nr = j; } +static const struct ctl_table swap_sysctl_table[] = { + { + .procname = "page-cluster", + .data = &page_cluster, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = (void *)&page_cluster_max, + } +}; + /* * Perform any setup for the swap system */ @@ -1088,4 +1100,6 @@ void __init swap_setup(void) * Right now other parts of the system means that we * _really_ don't want to cluster much more */ + + register_sysctl_init("vm", swap_sysctl_table); } diff --git a/mm/swap.h b/mm/swap.h index ad2f121de970..274dcc6219a0 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -3,6 +3,7 @@ #define _MM_SWAP_H struct mempolicy; +extern int page_cluster; #ifdef CONFIG_SWAP #include /* for swp_offset */