From patchwork Mon Dec 23 14:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918956 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 AF103E7718B for ; Mon, 23 Dec 2024 14:19:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 455FB6B00B5; Mon, 23 Dec 2024 09:19:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 405CB6B00B6; Mon, 23 Dec 2024 09:19:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CDCD6B00B7; Mon, 23 Dec 2024 09:19:51 -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 0D2D66B00B5 for ; Mon, 23 Dec 2024 09:19:51 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AA9311C6A1F for ; Mon, 23 Dec 2024 14:19:50 +0000 (UTC) X-FDA: 82926431280.21.FC514D7 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf13.hostedemail.com (Postfix) with ESMTP id 51FC620003 for ; Mon, 23 Dec 2024 14:19:10 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963553; a=rsa-sha256; cv=none; b=A0S7TiNExhn0gonp+/BYI2hCUy7ibgA2sW5SukVF2vJtBN+PUHKL45N/kGSBtbUzHaKL6r 5JbuQifWaer0ylYSS9jqnbC6YvgCRp7gOc8+uEVO+h5gG+mS8lyjXUr9Bd79Uz69tpvIwX 6GDXDWZWR5uoV1hyaS1ChvmU7KeOLoY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 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=1734963553; 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=H1MASwi5BahZPwRd4clCSqoijGaDr7E4/WRs7jrZbMlvnQu/YffxGGbaqZ/T3jBtGKf3Gk c/uDcfIu0IJsOkEzC1JoWBv6mRY/No3d3RmpKchBBh9WTOeNukgeqrvGxHdmFXZSGqOEH5 vYgKUmwGaYukpb6IaWSPrP1gHUjlABg= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YH0TB1fQ0z1T711; Mon, 23 Dec 2024 22:17:02 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 087BF180043; Mon, 23 Dec 2024 22:19:44 +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:19:40 +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:22 +0800 Message-ID: <20241223141550.638616-4-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: 51FC620003 X-Stat-Signature: td5cdm6amgjq6e55gpe57hkhhkmkfgub X-Rspam-User: X-HE-Tag: 1734963550-874470 X-HE-Meta: U2FsdGVkX1/aa/9nUE8HBGpdnljyWMMIR9TMs24T2zGMEE6f5KRuWwfTGk2KXFZaVmCqRweTPGn9oM8jfMeQacDnz51g6gZIfD+hdUzQPPAUqPgFcp2IJl3JBuuHt4cKkB3+36ld1TTqxU4BUVb4Ek3PHrXICpg1HrnRJ7FmEaHF1AZ7U0me2p5jW++B8CwZ1f4APA0fWAHJJjsYItccooAMNG1InDg+C6Ee6MQ2Om8VldoHz9eW6Mp4z5yEJl9kQ2XpEhxCAb+bdMK0LVuiBh5IFKYxNyOcRiVmLMxjDsIujyA9hPkcEI0Yx0lXJyPQgso+JeQUsXhShWWrEjcjnpHPMc4fHUIa7cQWAGC+NQyzERv0YWr/NAt+tCc9+PMLh7of3eGoWf5goW+x6DYMZhCMs+ETUTtG/LgIM/jcWI3AOB3iQWPxMw1YsJ7Y++Zgeqen/c5iz/n2HkE4CzdphMKrjGi8sekV061zKEiirOdqfEEut2+g0ojhRiVh9MKC4/2eNwgYHFB73inTc42EV2VnCEIJEN5eSfGn6LdHMKd8zaB8yla9aEfvYzItUB5svKE49aN9IPT00HYXupUDFC9RZ6HWYrSRb3BZW1zBxynQKntTo2nul71DDJnI4/zYCA6xs8HbakZfpPipzIVSrER+yJ1E3kGpknHqYAcJ9EQ0Qp1FFuZ/FTXirw7XU5h3DStqCuq8a5hrsB5UAyJkB7m6gym8Sg9IHeClYOQTZdyZoCxlfcX823StEDuPdh8kNkiTsCwi6WtPsAKSRz4p5uiq7XRCt+AVY0etGLJP9+sCSqhjJ9kUzKHMKyHGBZf/pDkmt1wXdnJaNy8Mk9gHHLzi5NvPggv629lTcBHsRoIJ18jo+hASh9/pt0bsf+gz518Ysr3CSoPKdg7gJFK1De6y/+6I1pgAyJV1zyVx1cVxTjkxQhIAMI60cv4/GFI8l5dNZVgTt4NhM4N0Ch5 0jwhkLl3 LqIDQ2QOcsKzE5lJ3yx3nwsbRVdsiPmPwF0XmuhwqWQ26cc6Na41LNB4MOUtb4RKl20A5h6D9xf1HrnTBtNQAnb3lh0Cd6jkJofC9kpmB7DRLyviE6PFFyQRwRjdSZ2jJDB360BuE2N4oxUcwbk0+sKZFKfD66DJuqQxB 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 */