From patchwork Mon Aug 26 12:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13777712 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 877F6C5321E for ; Mon, 26 Aug 2024 12:06:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A805E6B04C9; Mon, 26 Aug 2024 08:06:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A09A16B04CB; Mon, 26 Aug 2024 08:06:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E77A6B04CC; Mon, 26 Aug 2024 08:06:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 5B40D6B04C9 for ; Mon, 26 Aug 2024 08:06:00 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 134E3120FF3 for ; Mon, 26 Aug 2024 12:06:00 +0000 (UTC) X-FDA: 82494268080.13.3C934F9 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf04.hostedemail.com (Postfix) with ESMTP id A02DA40014 for ; Mon, 26 Aug 2024 12:05:56 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1724673862; 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=pN4AFoIHeIFRa/0u/GT3udNYVs6mCB8eMlNQ1KKGTJU=; b=MbCOYcV/AstCd0XFpsaUqDz0HyM/ZOBzWAtWH/NQnAHVZJgGClkmcSTreL1F+jtDebJtR0 19EhEf/CrmP1iiz7nb3CMhB9T3Ikj+c+7S5F1BHSxw/sH90kfMG9a40bMaUCqY+DEz7kqZ v11Eaa1OTZef8MRvHX9JVwQgwo5y3uA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724673862; a=rsa-sha256; cv=none; b=DyO+VBKEW31rIi8VPr/IDR+7fzFsd/2+HymWFwghsYMEz2Mnh5hzFHlOIaC1XOVOEZjHqw 5W059xsaUaKLAilQDv0DY7ppqvpniWuqxqTiSoCc5cyc/e8W63hFxe8Quzq/FA+znlafXW MXvdX+VSAl1/EyE7Ei3bAH6tueLvqI0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WsqBW6Kndz2Cnfm; Mon, 26 Aug 2024 20:05:39 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id A83AD1A0188; Mon, 26 Aug 2024 20:05:48 +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:46 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 12/15] fs: dcache: move the sysctl into its own file Date: Mon, 26 Aug 2024 20:04:46 +0800 Message-ID: <20240826120449.1666461-13-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-Server: rspam07 X-Rspamd-Queue-Id: A02DA40014 X-Stat-Signature: e8twmo9jthz3dpr7ifcn6bo4bebt94nm X-Rspam-User: X-HE-Tag: 1724673956-140370 X-HE-Meta: U2FsdGVkX18gOVdhIYIM5/rGfbLbf+odTpb5HbOwbSPiIOeWsZ9z84ZJWdKGK2KI4TaL/3qlq/sN+HvfuQiIq/WKqKCVaxmz7bzkzwWcGPpzZILHXu2+vbwueFaJqgHM1D2KIWEiVjnAe0TmeJHgMMxkFqJfHXEavZqu8C+ERpNYRW5Z3ysxOYmEJtLoqjxhR58vjJKvtLADLMy/dD3L/dZ/i7bMBmCQNDQZsNpSBYtFvm7/dqP3aYmvB79NVhj1bGXi2yZ0y7hsluffCT4qUTKrxG6sQUQzTTO7i+HLD9b4F6RBBm5Qfvb4j36Q1rRAKTiMnvD0r23BJ6KPZFxDClhs8pXh2y+kF2785EyEcut2josNsVO1XvbLHGDU3KFOMQcO5YRMC/aqT945GdUo7YTxgNcnNdhhH6qmiiCM8HOb6BStPkDj1SVrsrvu27N1IG02wjXCokFGWrHtI6hKhSApP8y2MNLW0Y/AaxPHPaPpsauwET36S9XS2UXZKxuzeCXiWsjoQRWShW1Ts+BCxLI8DyX6HUyskZdkpTdqfADawvq5qqgaIXWxNa6SeatFQKuTVd9hIT5eZ2LSBIPnBJ96cMYSSiW7PSktKREgPYtofEMeiTiFDP/IQGhlXCEQQe67Q7uKKW0r8K19xMSEPkqAfQ3jQXcUimNrQJn7vqh4yG1jdzKGXnxvbD4QyxaJjQXudfYyf/VZkGmb0wmyQEhbEAimdX+hJzKk0JHagjtVmOQnpg7sqV+14Gv4z08Kf627JB9FM7o7G2mkqyUAnMNSEo7BgzXJf/XRyp04LNJ1EzXFRe3at11rt7GZwywP8APSy46FTF/ErGL42nceZT4RZ7x+/yAtNT+agUPtLvMGPqLnVivFjEojPaLG8uuRpd8dEqhynJ1pfkczkdL6t9/4FS8+6k9mcGt+5tvgznCfzXpGO4Vr1KTYaN3nR3JypIOMNogdEI7AuAxovI0 w+Yw1igH j2DsKQYxVOCxMfYXgFjaGHmWcGLoYAuaTVZbOepE4dsMhHlEtYx2ECpls2StEmQYcKPDIIh0HSmJQPdL2XUawlTYHCHMnEF3Q60JvrumpCjBLcwegPnVxIqQsD3NYrnzYYZWeuuRVv6HEGOnnSxH2nDZLnvrIXON9s7yG4TVCY7DLr3TjGm4DIaslg8AHVADjfTlczmiClmgBeO7JNmRJmFsvR+kTV8xyCYwESMu0kFqPdD+tM3KhRLvintiLp0iJgE/zSuDE5Kw1I/LAFp+ADWbBJQ== 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_vfs_cache_pressure belongs to fs/dcache.c, move it to its own file from kernel/sysctl.c. As a part of fs/dcache.c cleaning, sysctl_vfs_cache_pressure is changed to a static variable, and export vfs_pressure_ratio with EXPORT_SYMBOL_GPL to be used by other files. And move the unneeded include(linux/dcache.h). Signed-off-by: Kaixiong Yu Reviewed-by: Jan Kara Reviewed-by: Christian Brauner --- fs/dcache.c | 21 +++++++++++++++++++-- include/linux/dcache.h | 7 +------ kernel/sysctl.c | 9 --------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 1af75fa68638..8717d5026cda 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -73,8 +73,13 @@ * If no ancestor relationship: * arbitrary, since it's serialized on rename_lock */ -int sysctl_vfs_cache_pressure __read_mostly = 100; -EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure); +static int sysctl_vfs_cache_pressure __read_mostly = 100; + +unsigned long vfs_pressure_ratio(unsigned long val) +{ + return mult_frac(val, sysctl_vfs_cache_pressure, 100); +} +EXPORT_SYMBOL_GPL(vfs_pressure_ratio); __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock); @@ -196,8 +201,20 @@ static struct ctl_table fs_dcache_sysctls[] = { }, }; +static struct ctl_table vm_dcache_sysctls[] = { + { + .procname = "vfs_cache_pressure", + .data = &sysctl_vfs_cache_pressure, + .maxlen = sizeof(sysctl_vfs_cache_pressure), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + }, +}; + static int __init init_fs_dcache_sysctls(void) { + register_sysctl_init("vm", vm_dcache_sysctls); register_sysctl_init("fs", fs_dcache_sysctls); return 0; } diff --git a/include/linux/dcache.h b/include/linux/dcache.h index bff956f7b2b9..c81c2e9e13df 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -508,12 +508,7 @@ static inline int simple_positive(const struct dentry *dentry) return d_really_is_positive(dentry) && !d_unhashed(dentry); } -extern int sysctl_vfs_cache_pressure; - -static inline unsigned long vfs_pressure_ratio(unsigned long val) -{ - return mult_frac(val, sysctl_vfs_cache_pressure, 100); -} +unsigned long vfs_pressure_ratio(unsigned long val); /** * d_inode - Get the actual inode of this dentry diff --git a/kernel/sysctl.c b/kernel/sysctl.c index d638a1bac9af..6f03fc749794 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -2024,14 +2023,6 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { - { - .procname = "vfs_cache_pressure", - .data = &sysctl_vfs_cache_pressure, - .maxlen = sizeof(sysctl_vfs_cache_pressure), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) {