From patchwork Tue Sep 3 03:29:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787950 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 3F93BCD3427 for ; Tue, 3 Sep 2024 03:31:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A6268D0127; Mon, 2 Sep 2024 23:31:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5565E8D0119; Mon, 2 Sep 2024 23:31:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41E2D8D0127; Mon, 2 Sep 2024 23:31:10 -0400 (EDT) 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 2680E8D0119 for ; Mon, 2 Sep 2024 23:31:10 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9759716010C for ; Tue, 3 Sep 2024 03:31:09 +0000 (UTC) X-FDA: 82522001058.19.DB94CF4 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf07.hostedemail.com (Postfix) with ESMTP id 1A82A40014 for ; Tue, 3 Sep 2024 03:31:06 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1725334220; 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=1+uGiXQyelMEBDm1UN2avaaiQu1zwQexosIDFQPm00A=; b=32qHCruRbF+SgmZg9hLaGo0Bt10gV7EeEpAJqJE75YwXm6P96u0HqPgZjSrmdAXTPgfxh/ ifpk4VarPcd50MDOKBbrdu9AxQ+3APRDjFTyJSWpv3oa/TAf+2ukQJnnRiEZjiVEJzjBre BfwP6KzZ1rmBhHS8AGPI/DTo6OZ64rs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1725334220; a=rsa-sha256; cv=none; b=kkqDuukDaMEwOpwsPP5Dpo2RiAiCGrijCqLkkgrUP2Kdp7qUXbf1qOGSiQ+ybYQKmBI9Ce 2k7syTYF1DPL8FS3djKIDtSldlK/anSZAnneeDN7r3xla3cFvz8YwoiXmFL1qolMdLsf+Z cAhSpT4E369GR86Vf/IAUk1HdnrLaeA= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WyWNh4sHnz2Dbj8; Tue, 3 Sep 2024 11:30:44 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 505771402CF; Tue, 3 Sep 2024 11:31:03 +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; Tue, 3 Sep 2024 11:31:00 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 01/15] mm: vmstat: move sysctls to its own files Date: Tue, 3 Sep 2024 11:29:57 +0800 Message-ID: <20240903033011.2870608-2-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 1A82A40014 X-Stat-Signature: 6k97zbmbjud3gum9tm45k88zgqcuafrb X-HE-Tag: 1725334266-42096 X-HE-Meta: U2FsdGVkX1+bCw1CdCNr1rlFg45STO1BgRypocRlEUZ0tXJf+0hSWNWs1bxh1z29MFeEbQ39uAXhYR/+imHJAYI2mM6xzo3r04irWf0x4pAakUjpecnf9AZ1D9j0QhCojccsHhwYtgH1E1K+SFb4u5fx0ipH7k22ZCEsvRt7qouIdpl1NyTtAKOm7d6QB6T+669Hb+45aquwkDQtchRFvm0Ogw3X8GRiS+/J733D8OhgwM6xGwjO14/07ViYSUZ0poh6jLqH8k6UrpiMYivG5yJRuUR54j2SsAv+7WGgIXFNVHA0H1kMlNixrryj0fz5IeNRRO47rmIgFhsoCkyjETRvwME6gOcvQ9P37mJ6iJ4o2aNst7xYDUylLS0nG//Vmxlo4uHMvhzQmhk9oTgEGZXJRFqwLjXK3d+/nbGDJaTvgy9vTI35hbbUB5TwAOw3mTr3RTWfI39FBpcAqeiQ7P4yjAOMuqp+/jigWOdWc0ww5b4Cs4wjNj/t7iIlmYkkWYKiZ9Udz3eE1rdZtUY6UAyOkdIw6SRcNI6EBHmG3NFdb7gY1eDCt+MSASAhrU58hTf9ya4J3/7OOOoPaal6mhHhGo2huwKhOPVbFSyDXFME81a0cbloitw6tDA/jVXbkL+BvysKGe8Lf/9iWDdnkdOqlPJC8MaWGixiIGXvyxkUXfiMudzpk4kqLVm3CdJ+ctJfjI69/S2WkCc43FwWCgJZ4COOH/Kbmj2nGsyQXjcKnW2HW1sV//HHFHh4oY8U+DUNf/kwDKi83Aknq3cNIYVKRT5Ggx9cil+9iEdS6AiJkRmgpRofJRbw0ZypzerxOkHxDCiVVMWZotPqWbUNRxAowi6B1a6QGr7djijyIjRnYpSnTBa2AeJhESQ4Y9vgxg7e2jdLmBy1C+ced55kr5kIFwY/eLw6uQlmsMxG1CxKPDSvoye4heE5hi9QpALqcesk34izPzg1r143OCD tIVxaNFC attR4I4NVCjYCwo6TzcB89MUhd1TqNkhnS4lRrM7HBvan7pVRy7tarP/qx7FiTYhsxZ61dckT4xtG35EAjQdc/Ql6CHyaGfsSD1DuGiy2n4Otwc0nUPbRdPaHZF6JuIh7ocZqtFl4Jv0gNQu6wGvNhq7rae+mL8F5MuF7YKL9iTPO9fcMY6h0ALNSpluo+fRqH+clgT6iEmvujsM= 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 --- include/linux/vmstat.h | 11 ----------- kernel/sysctl.c | 28 ---------------------------- mm/vmstat.c | 42 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index d2761bf8ff32..b2ccb6845595 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 79e6cb1d5c48..726b866af57b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -2081,17 +2080,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, @@ -2157,22 +2145,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 bb081ae4d0ae..343735ab669d 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}}; @@ -1937,7 +1940,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; @@ -2175,6 +2178,38 @@ static int __init vmstat_late_init(void) late_initcall(vmstat_late_init); #endif +#ifdef CONFIG_PROC_FS +static 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) @@ -2206,6 +2241,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 }