Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3214088pxb; Sun, 20 Feb 2022 12:47:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9aYEystw1bdid4tjxBU7Tz/oGC/L9N5+LKNubtW0/ZPRYFD4c+R/UCXo5hSjXouKO8mOq X-Received: by 2002:aa7:909a:0:b0:4e1:6d4:5905 with SMTP id i26-20020aa7909a000000b004e106d45905mr17349886pfa.34.1645390050281; Sun, 20 Feb 2022 12:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645390050; cv=none; d=google.com; s=arc-20160816; b=xjScZcgcZxYVWlYt0vF0A8pZ7toWOBRHce/ZPiypSZVnYRXpIy9Eviz0oz8Z1SbiU1 Ujty7zyIdOIyn1AiihF9prBunvC08UiPYkjQeWsLeKY4Su8qVTf5CjCjQnB9j8jxUoni vNJ1TG6AQgZc85NCuQbkb+WDQoFIoa/zUb1zVQCQ2PBDK1sGL0P8Fl6WnzZRgXHqa+Nn AG1Di6qxoxt+jem5zAUQpzbBa0tfYoJGIXKIzRaQnVO+JEr4SN3l4wBEzJGTKRs7XxWM Hn2uJiXgimwJV3qNb9Roo7+OPLMERa2tg/zVVFxlYbImoWcOtR4Oos9xmLoK9/IsFiAe +3JA== 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=TTJBfm6EePYTEIkYzvyAB9iOIRv+FziL9c6EST8c0cw=; b=J8deCJUqSmzEvtU/uQJB2OOVdElVVgPbRn7Yebhza0JSoObp8c8fjIs/Q6zRSTa1At ru5CIlGHckE6b4royGuqi4/r7iymeDxPTuVQIdKH1+hB40GfI0ili4oCgMCeimmtjjw9 vMoDSDJhKXnBc55U2Djb9RzZ/4//n3Z7ln2514atMaqdjIbuTvVjM7RRPwdzih8yvBck XiITNfGMCJQJ2HKHrv2wc4OQ9XjzMOC9LMNn9bQ7GWbKr7Cj1TLCHErGZMMB0j4cOLNc hTCUMiFJv7uRUYItOCsMGzKIYrz+uhXOorm/zjiMfglIFMdy+iIHtQy6fTfpHi5cWM6v SE9g== 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 17si7268364pfo.197.2022.02.20.12.47.15; Sun, 20 Feb 2022 12:47:30 -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 S237385AbiBTGHU (ORCPT + 99 others); Sun, 20 Feb 2022 01:07:20 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbiBTGHT (ORCPT ); Sun, 20 Feb 2022 01:07:19 -0500 Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E514BDC0 for ; Sat, 19 Feb 2022 22:06:57 -0800 (PST) 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 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 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