From patchwork Sat Dec 28 14:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13922363 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 D51B0E77191 for ; Sat, 28 Dec 2024 15:01:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3A4C6B007B; Sat, 28 Dec 2024 10:01:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC0C26B0088; Sat, 28 Dec 2024 10:01:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A77796B007B; Sat, 28 Dec 2024 10:01:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 85BF86B0082 for ; Sat, 28 Dec 2024 10:01:51 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4DE67B12EA for ; Sat, 28 Dec 2024 15:01:51 +0000 (UTC) X-FDA: 82944680658.06.3D5A84A Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf03.hostedemail.com (Postfix) with ESMTP id 979DD20015 for ; Sat, 28 Dec 2024 15:01:28 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.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=1735398068; a=rsa-sha256; cv=none; b=FZe7beIrD7QKLkBhV0R3SNhugamKJNxnK62bVLq2ZRAOQrzVYBxPMjGH9BIDLkmx/aaHJV JC7d0tlL4EwLKvnOC52PFpGVAjOFMPrLVL8ChuWouLYy/EAZV0Ua9lMOD9SuxpURN6xj5p D/+yOeAsUKOix+bncml5dRROwfAY7I4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.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=1735398068; 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=kkeawcA2Ivr3oQxrii7ZBXnTeXsAU4dzmySeTIgTS7E=; b=QdpL2VhT1mMTeHWTKWYefofjNi28eazF4EXHUxkItAcPCq8d8ulGYhT1BpmZtAk9w2a7Ts qnFSRvvrIVA+OFYAmALINM2b6/TqNvW+Wb3lWkZjuP70i3p6itQAUBUT0yCpXoc8jay78d w4LiKMLplij6GE9l34U5nPZHq0/iVfc= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4YL59F1Q7Fz1T7Z0; Sat, 28 Dec 2024 22:58:57 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 631E51402C7; Sat, 28 Dec 2024 23:01:45 +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:41 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 01/15] mm: vmstat: move sysctls to mm/vmstat.c Date: Sat, 28 Dec 2024 22:57:32 +0800 Message-ID: <20241228145746.2783627-2-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: rspam04 X-Rspamd-Queue-Id: 979DD20015 X-Stat-Signature: sp9m3zciferfgprn1b57om6n17ir4taz X-Rspam-User: X-HE-Tag: 1735398088-450987 X-HE-Meta: U2FsdGVkX19ei8xN0H4GRrT6Nix22329U7dZEXVj8Fvvvhp7Ln2fIpXSfziNKw++Aqs31U+EWOrh22W6uqV84WvogLDkIDmqpA5zCD7t0B6lIlCaMIsjWTCziCZzSiWfA3pbyDUPYFRHVGwkBWsP+m9qjhiRADlwZT1BRVKL+pg8gxtG4Mr2tojDhLDeNr1cQjVXktQmrnMp2c97/1cNT/psPDELreMuesHfFQKDyMjPPLI/qlhz6PefdKdsl24nOA3vDyea6uoo+Ez5QvKcZu8TFv/Qh/Xe1UWtcOneVeWst43UJhXxmvvabC2LDW1WchxTByysukK32f3kSBC7+igYSrOWUxHhG84R14+zcI6qSZKTemfBMJO9bGUzRtd8sNBqlHeSoSkGlw0p+JutKUYpXfGBHepaejOEOFkKvo+Nzj1bgYBqwsbXSLy0gGBOHoO9zWrW8ysJmhnst8ye2TiKCIPu2IzGkGWP2CcMVsAUVQmhWWdbpbnG8VbG7EVrgTCEmEYRnS1aVfkhwSB1HFVzjWv3oacYjV5WfP7KzqheMZtP11xOJtqhMg+hDZleP0ctN+J0IuRYNZSrh+VI+vkR3H71tpMWphOqO58QbECAVxF/mspjqwkEjuwFP7lUmBEV5nMK7esAhQv0PwQr2B5itErpYbd5/rPoDPzDxrBvUCUmFiLZ60hh7m7IV18EC6k8VnHKyfvXVkclu3TLbhO/kjxmaSdrKsQ48vCUQ8Laoga74zwDxqe/4YT6/qxEkT2xAnzoqA5R9gSHq/ou2hnsl/IBLqXQw1NqlRd2RxHZoKKNpCzQYqtU2zdZr4Q6/VZDNi6hxdfA86Dki8MVEDOZTtkznv5AsqusxVx1ctVKD6imGSrXb1J4+e/7fxla2PkVdqv81275CUYibJbpZBLzN7ofdkzpc11RNobqW5EQz74Gt8c4zX/AtyoRvg/6Ah9zcdjrvh/pEfmeVif JEPYqRli EyuCXXoQGIWXlRvO1YpN1cfxRaZ8hlIa/5DUClOISi+WR23OY7Fd21egifYJgG2GV3Sq7ikiJPCqDXvTH6o9Sx86yhEteXr13LjnQQhEx1QPMqjelRv+BEzY1fWhyaWfCNZXTwLzxyyJgO72ztnNtKCeUCtIpL2r0M3Rra5S2KBsOKGw+XQW2omsL0MQU1lWsb5kGDIs6Ly1dumXPl1eeZheiWq0HUQeQIGqQsgRYjEsX4YpCQEYQ7d/WZ9zKxPjupVDKk4IHdvJlv5UZsr5ngT5QWUBbuwY6+uEZ4CjM4uzl+CMLpUTOuuGNFV+Rtyfft0n1 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 all vmstat related sysctls to its own file, removes useless extern variable declarations, and do some related clean-ups. To avoid compiler warnings when CONFIG_PROC_FS is not defined, add the macro definition CONFIG_PROC_FS ahead CONFIG_NUMA in vmstat.c. Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v4: - const qualify struct ctl_table vmstat_table v3: - change the title - change sysctl_stat_interval to static type --- --- include/linux/vmstat.h | 11 ----------- kernel/sysctl.c | 28 --------------------------- mm/vmstat.c | 44 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 9f3a04345b86..4751e3ecc467 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -10,15 +10,8 @@ #include #include -extern int sysctl_stat_interval; - #ifdef CONFIG_NUMA -#define ENABLE_NUMA_STAT 1 -#define DISABLE_NUMA_STAT 0 -extern int sysctl_vm_numa_stat; DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key); -int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, - void *buffer, size_t *length, loff_t *ppos); #endif struct reclaim_stat { @@ -304,10 +297,6 @@ void quiet_vmstat(void); void cpu_vm_stats_fold(int cpu); void refresh_zone_stat_thresholds(void); -struct ctl_table; -int vmstat_refresh(const struct ctl_table *, int write, void *buffer, size_t *lenp, - loff_t *ppos); - void drain_zonestat(struct zone *zone, struct per_cpu_zonestat *); int calculate_pressure_threshold(struct zone *zone); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 7ae7a4136855..f1ab251fc2d0 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -2071,17 +2070,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO_HUNDRED, }, -#ifdef CONFIG_NUMA - { - .procname = "numa_stat", - .data = &sysctl_vm_numa_stat, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = sysctl_vm_numa_stat_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif { .procname = "drop_caches", .data = &sysctl_drop_caches, @@ -2147,22 +2135,6 @@ static struct ctl_table vm_table[] = { .extra1 = SYSCTL_ZERO, }, #endif -#ifdef CONFIG_SMP - { - .procname = "stat_interval", - .data = &sysctl_stat_interval, - .maxlen = sizeof(sysctl_stat_interval), - .mode = 0644, - .proc_handler = proc_dointvec_jiffies, - }, - { - .procname = "stat_refresh", - .data = NULL, - .maxlen = 0, - .mode = 0600, - .proc_handler = vmstat_refresh, - }, -#endif #ifdef CONFIG_MMU { .procname = "mmap_min_addr", diff --git a/mm/vmstat.c b/mm/vmstat.c index 4d016314a56c..cb4dcd4c6715 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -31,8 +31,10 @@ #include "internal.h" +#ifdef CONFIG_PROC_FS #ifdef CONFIG_NUMA -int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; +#define ENABLE_NUMA_STAT 1 +static int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; /* zero numa counters within a zone */ static void zero_zone_numa_counters(struct zone *zone) @@ -74,7 +76,7 @@ static void invalid_numa_statistics(void) static DEFINE_MUTEX(vm_numa_stat_lock); -int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, +static int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret, oldval; @@ -102,6 +104,7 @@ int sysctl_vm_numa_stat_handler(const struct ctl_table *table, int write, return ret; } #endif +#endif /* CONFIG_PROC_FS */ #ifdef CONFIG_VM_EVENT_COUNTERS DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}}; @@ -1938,7 +1941,7 @@ static const struct seq_operations vmstat_op = { #ifdef CONFIG_SMP static DEFINE_PER_CPU(struct delayed_work, vmstat_work); -int sysctl_stat_interval __read_mostly = HZ; +static int sysctl_stat_interval __read_mostly = HZ; static int vmstat_late_init_done; #ifdef CONFIG_PROC_FS @@ -1947,7 +1950,7 @@ static void refresh_vm_stats(struct work_struct *work) refresh_cpu_vm_stats(true); } -int vmstat_refresh(const struct ctl_table *table, int write, +static int vmstat_refresh(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { long val; @@ -2185,6 +2188,38 @@ static int __init vmstat_late_init(void) late_initcall(vmstat_late_init); #endif +#ifdef CONFIG_PROC_FS +static const struct ctl_table vmstat_table[] = { +#ifdef CONFIG_SMP + { + .procname = "stat_interval", + .data = &sysctl_stat_interval, + .maxlen = sizeof(sysctl_stat_interval), + .mode = 0644, + .proc_handler = proc_dointvec_jiffies, + }, + { + .procname = "stat_refresh", + .data = NULL, + .maxlen = 0, + .mode = 0600, + .proc_handler = vmstat_refresh, + }, +#endif +#ifdef CONFIG_NUMA + { + .procname = "numa_stat", + .data = &sysctl_vm_numa_stat, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = sysctl_vm_numa_stat_handler, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, +#endif +}; +#endif + struct workqueue_struct *mm_percpu_wq; void __init init_mm_internals(void) @@ -2216,6 +2251,7 @@ void __init init_mm_internals(void) proc_create_seq("pagetypeinfo", 0400, NULL, &pagetypeinfo_op); proc_create_seq("vmstat", 0444, NULL, &vmstat_op); proc_create_seq("zoneinfo", 0444, NULL, &zoneinfo_op); + register_sysctl_init("vm", vmstat_table); #endif }