Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp2749850pxb; Sat, 19 Feb 2022 22:57:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFEl4rMJcjmmKdQYnPxG43+55fjReF1aewCEjAmfzpT4ca/Ml4SvI97DtyQrMxc/7J96WD X-Received: by 2002:aa7:c0d0:0:b0:410:d576:8808 with SMTP id j16-20020aa7c0d0000000b00410d5768808mr15828373edp.340.1645340240577; Sat, 19 Feb 2022 22:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645340240; cv=none; d=google.com; s=arc-20160816; b=Tt8EAnWvvp2nyTtP/dORGnd/PydkmOiELEh10L6PoYFPuH1hapMlRQyvYAbh3BN8Qo SGJKJ1Ao8tYzzV3IH4tg2CXMdqks7KwIjBSONOWOS+Mf9pT2TPjUJwlTBTJ74ba3fRSK Ox2YSJ5vzvI4Oc6pE8JviLZ4qdMZQMv4Ml7PCl3c2O9IAUFFoeCgpk0/cuRhMeZDw2g1 R5cmuFLWYTHd+6GOcFsAJ50RVYGOlB3kCQDxTpEpqBVIvkFo7H/yDqzhOHSkacib1tbj JrSvr6x1IcD5iSJWPCb7Su28eOGg6z5mQ4evde9mdw4/f3ioXvTZxwbwJXIHYIoZnf8m REPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=Bftdej8kEq5YiGP20CDI/OmX2oTRovFKhkHWpeg1X48=; b=ImkzGuS7ABq9A0s4+0cIWFljcUIhcIPqx7/iZXTrTctLBxppRmabxLrPbVydhg5apk xXReo7pZSgRU29zr95kfxDXzggGAGBjc5uF3Qb4BFxwqAtJFg5Qq3C0eZ52f1ECXB1mo jiKmerQJLjcgCSMsY9NHeU5+EVqfreaVclFS/I6NVUHGcI8soVQWKsE+7cz+cOBRSWtc kYeUU3zOPcDobbcPxKqVsm4g34HwLMcCNSblE07qMKsyYR0RI5J59DnZlB50sIUYRq+2 gnLVSXhXvyrMEDlHUgmHBjUSV/py3sJ1mr6Jgcy3fcVGLnhYz+2/pg8HW45AO+5zYrHz T9/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15si8676817edc.536.2022.02.19.22.56.57; Sat, 19 Feb 2022 22:57:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239843AbiBTGCD (ORCPT + 99 others); Sun, 20 Feb 2022 01:02:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240685AbiBTGCA (ORCPT ); Sun, 20 Feb 2022 01:02:00 -0500 Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2C413C for ; Sat, 19 Feb 2022 22:01:33 -0800 (PST) X-QQ-mid: bizesmtp82t1645336882t5dgk557 Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:01:16 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: zD6y7hNAcUDOz2spGL/eUKdvHQFW318WJmvVp1I5o3JA883k/G16UFiqIcHw4 PBZ45w9nlRbhLwZwLDc91e8FdhgMGUn61raT5T9pXHP1bIUcBLW/oW3bXuXhP3ZhHBBbw4l sdn+5SZ7+S6rIzzBNhT4bOxGaUOTTxQn3REmqbN6PWYflwJz2iSsrIZZ5XNQlNYtQcdLZFO nhDonfnvqbgU1bSTmKhWJ6kaJtkFZmLR/YAC7aoB21xhpZbyStZK7UL4WM3y8VYc+u23GH8 X578cnMVz9F37uklWZb+CU0sgSVjRtn/OnhTJwN3HFkVWOGFIUONEBk2H/5we+6FkMvqlHs f+FSmlATG7vdRv5ELgUXlO5onmn9p+WlGxBF21p X-QQ-GoodBg: 2 From: tangmeng To: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, nizhen@uniontech.com, zhanglianjie@uniontech.com, nixiaoming@huawei.com, tangmeng Subject: [PATCH 06/11] mm/vmstat: move vmstat sysctls to its own file Date: Sun, 20 Feb 2022 14:01:10 +0800 Message-Id: <20220220060110.13770-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign6 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic. All filesystem syctls now get reviewed by fs folks. This commit follows the commit of fs, move the vmstat sysctls to its own file, mm/vmstat.c. vmstat_refresh is defined when CONFIG_PROC_FS is defined, so macro control is added to stat_refresh. Signed-off-by: tangmeng --- include/linux/vmstat.h | 9 -------- kernel/sysctl.c | 25 --------------------- mm/vmstat.c | 50 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index bfe38869498d..b615d8d7c1d2 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -10,15 +10,10 @@ #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(struct ctl_table *table, int write, - void *buffer, size_t *length, loff_t *ppos); #endif struct reclaim_stat { @@ -300,10 +295,6 @@ void quiet_vmstat(void); void cpu_vm_stats_fold(int cpu); void refresh_zone_stat_thresholds(void); -struct ctl_table; -int vmstat_refresh(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 62499e3207aa..31f2c6e21392 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2192,15 +2192,6 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = &hugetlb_mempolicy_sysctl_handler, }, - { - .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 = "hugetlb_shm_group", @@ -2377,22 +2368,6 @@ static struct ctl_table vm_table[] = { .extra2 = SYSCTL_ONE_HUNDRED, }, #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 4057372745d0..e7eeba4db2eb 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -32,7 +32,7 @@ #include "internal.h" #ifdef CONFIG_NUMA -int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; +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 +74,7 @@ static void invalid_numa_statistics(void) static DEFINE_MUTEX(vm_numa_stat_lock); -int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write, +static int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret, oldval; @@ -1853,7 +1853,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; #ifdef CONFIG_PROC_FS static void refresh_vm_stats(struct work_struct *work) @@ -1861,7 +1861,7 @@ static void refresh_vm_stats(struct work_struct *work) refresh_cpu_vm_stats(true); } -int vmstat_refresh(struct ctl_table *table, int write, +static int vmstat_refresh(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { long val; @@ -2238,3 +2238,45 @@ static int __init extfrag_debug_init(void) module_init(extfrag_debug_init); #endif + +#ifdef CONFIG_SYSCTL +static struct ctl_table vm_stat_table[] = { +#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 /* CONFIG_NUMA */ +#ifdef CONFIG_SMP + { + .procname = "stat_interval", + .data = &sysctl_stat_interval, + .maxlen = sizeof(sysctl_stat_interval), + .mode = 0644, + .proc_handler = proc_dointvec_jiffies, + }, +#ifdef CONFIG_PROC_FS + { + .procname = "stat_refresh", + .data = NULL, + .maxlen = 0, + .mode = 0600, + .proc_handler = vmstat_refresh, + }, +#endif /* CONFIG_PROC_FS */ +#endif /* CONFIG_SMP */ + { } +}; + +static __init int vm_stat_sysctls_init(void) +{ + register_sysctl_init("vm", vm_stat_table); + return 0; +} +late_initcall(vm_stat_sysctls_init); +#endif /* CONFIG_SYSCTL */ -- 2.20.1