From patchwork Thu Oct 10 15:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830201 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 2E205CF11F8 for ; Thu, 10 Oct 2024 14:12:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE82B6B009E; Thu, 10 Oct 2024 10:12:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A72696B009F; Thu, 10 Oct 2024 10:12:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EA786B00A1; Thu, 10 Oct 2024 10:12:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6D58E6B009E for ; Thu, 10 Oct 2024 10:12:09 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CC22B120140 for ; Thu, 10 Oct 2024 14:12:05 +0000 (UTC) X-FDA: 82657881936.11.88A4F97 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf10.hostedemail.com (Postfix) with ESMTP id BE72AC001C for ; Thu, 10 Oct 2024 14:12:05 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 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=1728569483; 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=lCQrL2I1/DxYS61YKTMcXplK++j12MCPMTYeBUKqYUE=; b=S2AZ43xtCi7qFDaleeJ8CxPGRdhtRxfSd17qaC64/7hICK2GBIcaOqA+kwACfpgWW8ucZV iO2F/veomL/7SonTNil1+j5BLtSbW33lJKrh7DScbAw2jpEwf8s3KUG1ZypNHyTGT/nVWE d3UGgO5HFb7V1IZugsZ6kbP9rnpjvvI= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.35 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=1728569483; a=rsa-sha256; cv=none; b=ifjDOY9qvcuihLG5kdNZqZIt7jL8+A3aKkenpSCk1lVS7qirOOt6YI4qghnLxU/XM68CW4 mLdP7zuJDvAThtJ0wk3Bu5laet65RQdAup6xNOeOFbvonDwmojHe1+p5tt6v69t+uoxAi2 vfjLBGMEepxcxQk3YT/nhpH+RBN4UyM= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4XPWrH3jK8z1SCPP; Thu, 10 Oct 2024 22:10:55 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id C68131400DC; Thu, 10 Oct 2024 22:12:02 +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; Thu, 10 Oct 2024 22:11:59 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 10/15] fs: drop_caches: move sysctl to fs/drop_caches.c Date: Thu, 10 Oct 2024 23:22:10 +0800 Message-ID: <20241010152215.3025842-11-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspam-User: X-Stat-Signature: b4xfejno3dy6dg9rnrdf1bp5ht46d3np X-Rspamd-Queue-Id: BE72AC001C X-Rspamd-Server: rspam11 X-HE-Tag: 1728569525-558072 X-HE-Meta: U2FsdGVkX1/ZbbMMARe/4Z8i725mGEXZV3Xom2kzd/ANAoAaYJTedWT7pcGHyO/tSeHEbEUqVeBmbEAU1XMidLvxbrzUu+22w2qxVeYhMdd5HdsAVUqr9CB16hOfolQWUwBE4vGz2SjiYr2Cez6EFpUNG4pqDBauAnwpKFnM8RlVd56wOrKXHF5Hjjwn6guQxBTPpyuSVk9t6RRXtLYRmpmrtXC31DQcp5I+sAgzBZfaQR/FvitDL6kKzQzjeNi7Pi9ylvrfrkj74YvAxV0yXqWKNuHhJQ7XzPR8gPTAniWxpFQ4+AabXARht8tJAe6FlJIU9valnf0CKmaACRAYPi7Lm76q4lPFtilS7j36OVJjNRYrXC4dgfuXopRG2iRN/VXXWRkfXftrIludZIerfyKtrROYgaDZfc8hvyqN6I99CaGfW/tz9QvxoDgGuZmg3TC7s+d9+4EfhctPjgJwlcxJLFI8kRxa/gjhail/Jsd4xhFnAr01zn/X47aJsqo47zGSkFFPiJr9lW8aItFrJs6xdnZQKbn0Bhnv4SZ8uVZUjGXCZMUv8440rfU6sY8M0P0NJLdRBZWPCGJd220ylI1aUX1ibVZPofgc3IEZJxclEfl2DnMi1gFEOvS4DvStdHTqxLDXGXVkgDE4jb7RmAX0IqjcNOnOzUGeHE0kr4HFDZZMxD8FyZbG+WnrfDsqqkpjo5vujmFs9M6y8PJoKHAg3MtBgrVBDU3p24tH9VPacHup3WelwOrKMUSuAJ2rIjXHZJbViBNMUcd3En1ZbLrRlnbUBcuz2QTudblk5TLoj1A4xAjqYb04G1p/0c9Ldfjkc/MQIKQqb4+yTsoBL59KdDGdZX++VYOGiHq+CDmcNyFkue9H909wNsj+JN6XdNrhm37C+mU9J8NSp4VZCu2CGEGTtdVrDIZknBXmwlXDNjbJ8HK1uVfyO+UspdxmBOcXdG3CSnIHHRwSKlZ 4x2n8oX9 w1Smc4BwOn0bfN/86sZKqJZ8S1/7ccLsqzD0dyPy82ZR/JYrFnIODHyWvTKsJh09TfBhUdkf8fFHHQXaXRPC07p2MDd5/izYhYe6VIw0N6VTxDdCWSkaEW56ByFUsKwNgxevsrO5M7wXeDihc48/FBr8dQUo3u7Tw8OkYkHR3R1FcNFWmTX7dtc0L8XMNUy4UFBMPB1pEH+jqWijleUnnaoWuOg== 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: The sysctl_drop_caches to fs/drop_caches.c, move it to fs/drop_caches.c from /kernel/sysctl.c. And remove the useless extern variable declaration from include/linux/mm.h Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Reviewed-by: Jan Kara Reviewed-by: Christian Brauner --- v3: - change the title --- fs/drop_caches.c | 23 +++++++++++++++++++++-- include/linux/mm.h | 6 ------ kernel/sysctl.c | 9 --------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/fs/drop_caches.c b/fs/drop_caches.c index d45ef541d848..f2551ace800f 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c @@ -14,7 +14,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) { @@ -48,7 +48,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) iput(toput_inode); } -int drop_caches_sysctl_handler(const struct ctl_table *table, int write, +static int drop_caches_sysctl_handler(const struct ctl_table *table, int write, void *buffer, size_t *length, loff_t *ppos) { int ret; @@ -77,3 +77,22 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write, } return 0; } + +static struct ctl_table 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 int __init init_vm_drop_caches_sysctls(void) +{ + register_sysctl_init("vm", drop_caches_table); + return 0; +} +fs_initcall(init_vm_drop_caches_sysctls); diff --git a/include/linux/mm.h b/include/linux/mm.h index c7f73bf32024..ed2e7425c838 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3791,12 +3791,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(const 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 373e018b950c..d638a1bac9af 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2024,15 +2024,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_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, - }, { .procname = "vfs_cache_pressure", .data = &sysctl_vfs_cache_pressure,