From patchwork Mon Dec 23 14:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918971 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 E6EABE7718B for ; Mon, 23 Dec 2024 14:20:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73E156B00D7; Mon, 23 Dec 2024 09:20:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F0436B00D8; Mon, 23 Dec 2024 09:20:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58F376B00D9; Mon, 23 Dec 2024 09:20:43 -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 37C2F6B00D7 for ; Mon, 23 Dec 2024 09:20:43 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DC8E31C6A5B for ; Mon, 23 Dec 2024 14:20:42 +0000 (UTC) X-FDA: 82926434010.11.199EC9D Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf12.hostedemail.com (Postfix) with ESMTP id D10F740007 for ; Mon, 23 Dec 2024 14:20:23 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963605; a=rsa-sha256; cv=none; b=2Rd26nlxx8kOBQ3u2gUJSsHna+0Jz681kUlth5YuXNTkB1aJDVHNKbcEWN1NpLsk9WNJwU kOGMg2yGLSR2HAO7Raby/qldRG6MsYrlo2QD+6v+b5Idot9PZbPaQSdLYzZrntxW/90ZC7 iwWmfJX5RYg141eEIdf8uJE/M9cjKNg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734963605; 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=3cuFi//AnlRiBNqTRukK1c6s/mrVEhZxHE5/raJJjkcKNKbHgj9bO+xj8JhYsglLQXbET6 KHcl7OAAEXwNLfTOWb/Vf5uQLxlPjfiJD+VYLbaHyfxOYkdwMdhjM9FlSYaI8bxjuHZGbV NXo+cW4hfi1pLqsk8DJSdR3ay2nP+hQ= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YH0Xn1FS9z1JG5j; Mon, 23 Dec 2024 22:20:09 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 5FF2E140202; Mon, 23 Dec 2024 22:20:37 +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:20:32 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 03/15] mm: swap: move sysctl to mm/swap.c Date: Mon, 23 Dec 2024 22:15:38 +0800 Message-ID: <20241223141550.638616-20-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-Server: rspam04 X-Rspamd-Queue-Id: D10F740007 X-Stat-Signature: td5cdm6amgjq6e55gpe57hkhhkmkfgub X-Rspam-User: X-HE-Tag: 1734963623-512480 X-HE-Meta: U2FsdGVkX1/S/45YOeG110QDzK+YMO6NR6kEPkWR5Rrly0gHNfRr/ngfFdOhyaK3MkDC+6Ow8ECYpNqz/j1msnnvb7Mv8g7utXIDArzOYvrv+6Sb6TMr+OSC5AstGvFYAWz/LLJt7WdXuW/A5Wc4KIF6MzfFTFDX6rUur9gqi/AlUlTWQ+4vFwAx+aGl2gqD+npkUqUzvHzwKG3QDrOyIPeiSNFHyYhjk3g7uP/0QtbGWaQ9L9ODeru/KvxquW3FP3ZZ7ZaA1kLJKPF31vXPi2zdwJULqqPmjYdNah3BL5XFQrpmqqqheZP2KgzzhyzqKhXwAllbWlUhDBgRcBoCTjSwkcdZ88teuJ/WBXeIGfovrtcKhitl2u1vXSIkybMMPkdgU4rNTuL5RI5JnMdX4FUyaSk2Q4HLP8HNGUpkzziFILHhO5OHLJASZvyV1gBWa9f+YStjNVierkVKbCIZmvK+KvW9oZJKboMi2/qxKqPQy0wny6ohFzuba69kddOHC5HBfsbDTFr66xROl82b4SrRxY+OGLhoGXje+AE3MDRQbqboevCOnde6W1oU4wBwYFJJ5dtUAmDJ04cCtWTny4GDK+wOAaLCEInH8oRyN7RLOu+cyOdaROmEPZxWJjsQ//1R5MSbHQa/CRBA5Jd/KeXsXTPJ7+q5L/qxelkse1GBxt9H+qqq8NYQ+2s1xz2yw5XJgsVVCTKClWTFSnOtWVsZs30k0lNWPUQ0yt26G56lr4W7CvA/0Gd/a8W8F0Z1/hnq+fZ1JUkH5HkxGsUuA9IKI0Yv3/ZpPIaEmoyDrbh40At2Ap3mWP5/QW42fBejQRSqJ+VDM99lRcYHWHsxj8ZOlHkxM+5vrOETg0AwJTALsu/mlp8gRNFvyjADTvBMrKYepcwYHGFzM4ULvKTQeQQoNbNVY9LWoffjpAtZ+8dTN3q0UJuJiKQ7kiMphuzVLumcqGRcxlfiBXEFopX GTNpFJ6+ j4MtMKgrpof6O4LTPH++/hOij1Kkxr6AMJ8RLr7pW6TuvenCY878WVzp8wQVYxxoWMy18OkRaWqj9WxTk1MSR3tv/zPzZO5icgNIzTkfJYLUVcC+DNXN3gNMpbt0VKsopoM/OuhivKV9FkSA4tnJPpg18YYiUBbjnJPntll/2J2GFB1g= 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 */