From patchwork Mon Aug 26 12:04:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13777715 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 DD2BCC5321D for ; Mon, 26 Aug 2024 12:06:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF2456B04CD; Mon, 26 Aug 2024 08:06:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C52D46B04CE; Mon, 26 Aug 2024 08:06:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 905E26B04D0; Mon, 26 Aug 2024 08:06:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 572B56B04CE for ; Mon, 26 Aug 2024 08:06:03 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C82BC41073 for ; Mon, 26 Aug 2024 12:06:02 +0000 (UTC) X-FDA: 82494268164.05.140CB32 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf08.hostedemail.com (Postfix) with ESMTP id 3AE32160014 for ; Mon, 26 Aug 2024 12:05:59 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1724673897; a=rsa-sha256; cv=none; b=n0ZFNlYmSRgzobFQ6uMz8sAVJ7Qbrk/mkhQ424v2xtl+mA9k60aoypMy5JIANvHAMdtstL zFq3qzOp24F6zMirW9VQ+4qFKfGl+HWRpyMYbl96xwzAH6SUcb4ncBTS/WkP4+QUUM1s+M 7LLeOd96xewUcSEm/tid/duQ9FuA5nI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.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=1724673897; 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=s+pueQE+ziS82PtFxQ2L1U07XouuPQdg0h3aHWVWwZE=; b=m2U6D61e+3bj3+iAwwmHCG4D3WfZmvlb9PdXq383XE8jfdQmBxTsD/zZ75T0VLtW+Y281M 3EYkaURlZV7h5jIfLPfdH9/C3Iu/CxhSync5skI/L0NMal5GCoWIcOCvLQVV1RAC9AHXwY /ueh6Syy8puq81W1zONLol0rtf+o5Ts= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Wsq6P4rRpz1HHLX; Mon, 26 Aug 2024 20:02:05 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 4166218002B; Mon, 26 Aug 2024 20:05:23 +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, 26 Aug 2024 20:05:20 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 01/15] mm: vmstat: move sysctls to its own files Date: Mon, 26 Aug 2024 20:04:35 +0800 Message-ID: <20240826120449.1666461-2-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826120449.1666461-1-yukaixiong@huawei.com> References: <20240826120449.1666461-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-Queue-Id: 3AE32160014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: aahcpeu19fd6ps9fcqmd1ya4aj4ahij9 X-HE-Tag: 1724673959-559861 X-HE-Meta: U2FsdGVkX1/1gdLA+MipbizlgLhlM1vDMREv2sX0Nz0IpPyj3MH5wxSlZjYcs/BuAfUb//lq1a+3JX0v3F4tJJJ8TYPCJn0o9jpKrS/gytFBr1TYOcyWAUmK3AZI9xdeIG2XqxCXtGJ92oVOHiJfF0l7Aqm0//nlORHHY4i6ifMmNqLT0t0p5cokeUEGTKn9hyyctqnWKBoHEsto4A7BLdWpiPiDidVVQGoFFuY3uBwRnW/S0BekPPYy0qQkTT9PorN4l1sFQlpZ323C+nNIdtyNjp+XozaCtQD3TAEkQGw5SW6wXTN7qqazI90TlPHb3Fam3iELfnsvHUN9et9rKxTASVLZDSm7JZxZmiCkkNwfm9uVZcMBtVXDZLs6FVGm+uZ4TaAhszeEeRKMKo051u5EsnJ05KTYXrN7oVE2DACXPbbsCoHICruhl8PAUfFdbnuCXo33qYCi91HJu8UZQDKM5FHVELqvTaXUKYi/1xiN9B5bR7M89gtEtF0KX3BHmYNAKMAZmjUvvr0gumOOI0tDhxY2aFbY/GKXHTFkLimatzffyEeV7mB5ajpr7s2o4Ksz5FzobDkAoKOTtg/6q0iuP35zCluMZH7bfeo0GnHOSA0d3RRxp5uTGwhY4iG/X9O3PgDFlFLMBO2FcRtqMTWpmDGEMLC4OJmzpkcl+oEJuI4DnqZekJTDWfJHXpb0mmyoLnCCyd0+CfZHEhBPL77S0ARt0/APlU6rN3u9hoT3kzgBKGG9x4EVRzjG/7OpP9iBLHNr8GOjCPLEO7dd8/U0e/a6gghNKNPuY08KCLN23ZcMhQROFu/HWqlnbj9k5C7dlZZPG3srHH9KZKe68lKCJQMtSK2FNTE0GRiVaBfU3ys9h1Jf6+LEDiNQuBPPs8XTqtGreyYgEF1br1iQtgM3bY/MUJ5UJwT7+Qy9X4khqC6e/9GfrRAwvMhocfmM4Jq8ENwCSo50KWxjLW/ rjh+j+Kb ZB3m8r4plVWOgRrVQCD6LJjMfGswNdknI3e/Eoz3qI6rbGhKOeQb0FxhG3zCZJEjeNWiJbxUqT6+/O/Dv6yUFwiwLMKxqg6uxjRNfxu7Swx6dakAdLn0PC7uan4aGSLW7cO4FG3gEg2uKFJXL8iGqf0pC0A== 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 --- 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 f41984dc856f..9f9d6a92b98f 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}}; @@ -1936,7 +1939,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; @@ -2174,6 +2177,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) @@ -2205,6 +2240,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 }