From patchwork Sat Jan 11 07:07:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13935834 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 6AB80E7719A for ; Sat, 11 Jan 2025 07:12:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01F196B0099; Sat, 11 Jan 2025 02:12:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F0FB36B009A; Sat, 11 Jan 2025 02:12:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFE806B009B; Sat, 11 Jan 2025 02:12:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BE99A6B0099 for ; Sat, 11 Jan 2025 02:12:35 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6D328C1104 for ; Sat, 11 Jan 2025 07:12:35 +0000 (UTC) X-FDA: 82994303070.14.A6DF468 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf10.hostedemail.com (Postfix) with ESMTP id 137DCC0003 for ; Sat, 11 Jan 2025 07:12:32 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1736579553; 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=OsBPli+Wj7Y+O/vcSAGFSGTIy9nboiO7cAlq8sbiAz4=; b=0zEQFNrlL8n7SKffOq50JBjUgjz9NE9PXyUUh76sYx5TmDT1gfCuRPCIYFlTp2Lnq2A67I LUFg8dC+C2l4gcAz/GXTnFpjNtbcUeFDpIIOoPqKK/ovXn/UaoI8nDM6qPfIIqnj2VfFhH ZEx2+AW8cikaL5Q8qkmmwGGUekzGkOw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1736579553; a=rsa-sha256; cv=none; b=B8QbaiIy+32sQexv+0GelMPOezUlwpmpNr2ulIU/8ksNnLA+fbaND2e8EZKMeayVYigzd5 x0PvLIggblBs0wwoGpcPPfC2MNlI6+LBB612lOzEfR8Ayinbjs6ms8ztmabUARB7nUy2JN lFEUC2CPiaG6RZH+BT8VGoD0Hxw+pYM= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4YVV6Z3mXnzrSD8; Sat, 11 Jan 2025 15:10:46 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 7F8FB180218; Sat, 11 Jan 2025 15:12:27 +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:23 +0800 From: Kaixiong Yu To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 -next 03/16] mm: swap: move sysctl to mm/swap.c Date: Sat, 11 Jan 2025 15:07:38 +0800 Message-ID: <20250111070751.2588654-4-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: rspam05 X-Stat-Signature: poo7m1rk18nfor635nbzgsx8rz39cka7 X-Rspamd-Queue-Id: 137DCC0003 X-Rspam-User: X-HE-Tag: 1736579552-151257 X-HE-Meta: U2FsdGVkX19QvpGsqJZ6HzaQ50UZcGJ11/rgf9JlfBCm5Zm5V/2FFsZYGkA4rV8XI6l5tPkRvYdhi17sL++tX6PdHIeCInQ6bGlyMwlTgjZn+XB6FMQiSOQ5ARgTQyBVkR+Rb5t5PkQYSw8JULt455Fmxslz7ccaH86QfMYtloq6Mo6czGC9+4f473UY2tUvwY+OT1BNrYQrTSvZFhnah9dAkfiolYb79OxMJo6zoOpbG93nWcayfYMK5Divo6h77WPXD5Q0KG8Kkk5zO1Lk2/AEYrFSA56SdC9mN+I3HywGscxikESouLEET9TiskJ9jHqndJTIfkTsYtOinvIlQaz4PUtydX9cSzkjyvIa9jhMl/kW1fTpaZKDw15e/sIwuYJxx3P8HUSU8dJyWY8eWkTNS8ZRhqhMHsxZQkkl8JQLuljLoJdwcawd/9hiXyQcmS76qvCcEw5ls1NVJQEr0KnDMEswdUuEa+CEcQTXRFs0oeBMqyDB+zxUopw3fgkhIoaYVxN/hrY5Fh3eXklZ9kCRhlsj3Eg72HKRW6K1NI8+Ou6rbl2pcMojMqUGv8YPzIpt8OQHsdD0LciEX242gtnIG9VBXVao6widohdcKuWUQ3X/6YWBPPRiFn5GfZSrH6dtxlfAsivtDsFkIdPboDHM8wV7eS4SlNlYBtOdpNO3zMH1tfAGOTJCFm/tuhX2goNguTbZW1cRBZbhWRl67B3RLIr3pU2KWvQ60lMSKWRFMBNffPUVE/ro3LZEwfr/cfBJ8eynchMznk/ulC48DfGobq0YwGvvbGXApbs5rlOMUfH0DdXsFGRjD0kfy/p7RA3mSQkvxdV56fpLP9piDJkJEXv9oOTLwy87Rk0i9Q7hNGlxUnmxd0xk2LF/n1W70lXjZsT5wMCMHWjD8LrBHY9D3UluuUhvhH9nwuSvRG/DD5Oo06ztqtdvLT6/0ctr0L867fuYY/sh3/ElYrH zLgos86f OFfMcazqSMYybBNhOXQriK4+TLHQGxk7aLfxAVXZiOVqgq7zb8orL9wLRNy+ypwfZHHBmpNy0zCw4TNvuJW2EFuXzlPk0XK+c+dqLzbmrqtSoOrfdEfrGgn7xiGWeIGd6oQerr+VPL0WGiXN0lXt6iE0SUkntWN40RO5ZYtUMxSAy6CjEQ4ozYY3Df0EO/nBRAUAFj2pmLICVvbsAX5rwMbrmBlEBQAlutCiORagKmdNaN7YrBQZayq81k7z/eq1n2qkwF3VXaVOaGejgt8D/tr+MEfMNdyyslgQPRhDDYwCkJTh+CHPlO78ekQ4EfqpfKe1OZ65Cvt43b8Q= 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 b9a63a6c960f..fb00ee129f77 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -77,8 +77,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 fc8281ef4241..b81cce146eb2 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 { /* @@ -1076,6 +1076,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 */ @@ -1092,4 +1104,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 */