From mboxrd@z Thu Jan 1 00:00:00 1970 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 7A55EC433F5 for ; Sun, 20 Feb 2022 06:07:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05A016B0072; Sun, 20 Feb 2022 01:07:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 00A936B0073; Sun, 20 Feb 2022 01:07:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E14906B0074; Sun, 20 Feb 2022 01:07:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id D04276B0072 for ; Sun, 20 Feb 2022 01:07:04 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7BD942243B for ; Sun, 20 Feb 2022 06:07:04 +0000 (UTC) X-FDA: 79162125168.05.B9021D8 Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 7339C40004 for ; Sun, 20 Feb 2022 06:07:01 +0000 (UTC) X-QQ-mid: bizesmtp88t1645337208t7nkhfkg Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:06:33 +0800 (CST) X-QQ-SSF: 01400000002000B0F000000A0000000 X-QQ-FEAT: d3XYZ9avhmAtY8bKX2/d7LpBuqdLrdgaVpVdorzRFP1KIykOsY0uqX7+VH2MI 6bcYkZM/2LQgM1uL/YpI8EvW8EoP2rWGqRlW/+agsMpI4yEY6x64pIBGOf0F0iMnbGsDVeg 4mVODKp39iheZu9YCLOWvbhtTSX5JBGxDg9vlgAkY1sOsKL2qtPUT53Of791wLzTsKGrBTA U+Z0SkLJqznMM6JR0jmH0OKKi73aq0+U3Z6OQeU7wwU5kkgtmF71wUQHg92QPVDOaZ0jbbU gwRhd4t74rsPTE1IrA2bzHonEcAR+UU0Z4jPni66V9hZboyC00ffLqD5B1ydYTkiKvKGQ48 j540cPL1Re4R5MigM6JXDuzvzrUHc4JcGOLAZVD X-QQ-GoodBg: 1 From: tangmeng To: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, nizhen@uniontech.com, zhanglianjie@uniontech.com, nixiaoming@huawei.com, tangmeng Subject: [PATCH 10/11] fs/drop_caches: move drop_caches sysctls to its own file Date: Sun, 20 Feb 2022 14:06:26 +0800 Message-Id: <20220220060626.15885-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:qybgforeign1 X-QQ-Bgrelay: 1 Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf07.hostedemail.com: domain of tangmeng@uniontech.com designates 54.92.39.34 as permitted sender) smtp.mailfrom=tangmeng@uniontech.com X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7339C40004 X-Stat-Signature: hocaa84qfmygn4oxyybsa4ojhn4c5iuw X-HE-Tag: 1645337221-407059 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: 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 drop_caches sysctls to its own file, fs/drop_caches.c. Signed-off-by: tangmeng --- fs/drop_caches.c | 26 ++++++++++++++++++++++++-- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index e619c31b6bd9..5e044a2d75ef 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -13,7 +13,7 @@ #include "internal.h" /* A global variable is a bit ugly, but it keeps the code simple */ -int sysctl_drop_caches; +static int sysctl_drop_caches; static void drop_pagecache_sb(struct super_block *sb, void *unused) { @@ -47,7 +47,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) iput(toput_inode); } -int drop_caches_sysctl_handler(struct ctl_table *table, int write, +static int drop_caches_sysctl_handler(struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret; @@ -75,3 +75,25 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, } return 0; } + +#ifdef CONFIG_SYSCTL +static struct ctl_table vm_drop_caches_table[] = { + { + .procname = "drop_caches", + .data = &sysctl_drop_caches, + .maxlen = sizeof(int), + .mode = 0200, + .proc_handler = drop_caches_sysctl_handler, + .extra1 = SYSCTL_ONE, + .extra2 = SYSCTL_FOUR, + }, + { } +}; + +static __init int vm_drop_caches_sysctls_init(void) +{ + register_sysctl_init("vm", vm_drop_caches_table); + return 0; +} +late_initcall(vm_drop_caches_sysctls_init); +#endif /* CONFIG_SYSCTL */ diff --git a/include/linux/mm.h b/include/linux/mm.h index c3c7cb58c847..775befb2786b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3126,12 +3126,6 @@ static inline int in_gate_area(struct mm_struct *mm, unsigned long addr) extern bool process_shares_mm(struct task_struct *p, struct mm_struct *mm); -#ifdef CONFIG_SYSCTL -extern int sysctl_drop_caches; -int drop_caches_sysctl_handler(struct ctl_table *, int, void *, size_t *, - loff_t *); -#endif - void drop_slab(void); #ifndef CONFIG_MMU diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b51b0b92fdc1..657b7bfe38f6 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2182,15 +2182,6 @@ static struct ctl_table vm_table[] = { .mode = 0644, .proc_handler = lowmem_reserve_ratio_sysctl_handler, }, - { - .procname = "drop_caches", - .data = &sysctl_drop_caches, - .maxlen = sizeof(int), - .mode = 0200, - .proc_handler = drop_caches_sysctl_handler, - .extra1 = SYSCTL_ONE, - .extra2 = SYSCTL_FOUR, - }, #ifdef CONFIG_COMPACTION { .procname = "compact_memory", -- 2.20.1