From patchwork Sat Jan 11 07:07:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13935843 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 0C3E1E7719A for ; Sat, 11 Jan 2025 07:13:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 946746B00B3; Sat, 11 Jan 2025 02:13:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E21F6B00B4; Sat, 11 Jan 2025 02:13:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D3DD6B00B5; Sat, 11 Jan 2025 02:13:06 -0500 (EST) 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 4A44B6B00B3 for ; Sat, 11 Jan 2025 02:13:06 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 05F06810BB for ; Sat, 11 Jan 2025 07:13:06 +0000 (UTC) X-FDA: 82994304372.17.26A888E Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf16.hostedemail.com (Postfix) with ESMTP id 9E8B718000A for ; Sat, 11 Jan 2025 07:13:03 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.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=1736579584; 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=iG1btJ1mUTZm1Q/QXF8tiuwQRU5p8WJAy3Rzeg9lzIU=; b=ys4CWjQjTBgF0mnW34v7oGQrYSeQIwJEJhQb3xzVRpWvlcoe/7vpUDCIYzpb9z9I/beFIB EAK/dEEYRMd3K47/bubw4y8keEFuXml8Czl2gGFdblL0tBu69UiN+pjurMnnqcUmEKdODN 2COZo7MHFEBNf3LYgoaD0DJXO+btmFE= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736579584; a=rsa-sha256; cv=none; b=q0sEYOFqk/Iw7dkpaLcsQ3tYyarNg3/NpDt9Uavb2f1rPPAkF8BYH55Jkbq6hvw3gaH492 kToFx83hMeRMYDaHmU7P3S+xzQKj8WwvKqvQjXBba0ARBqjLg1BFn4mY9wEyWqjJKPsHjp cM7GWg4DIdR0Euh1jf7k9OBPHGg1+TE= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YVV6V3XMGz22knm; Sat, 11 Jan 2025 15:10:42 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 9869F1402DE; Sat, 11 Jan 2025 15:13:00 +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; Sat, 11 Jan 2025 15:12:57 +0800 From: Kaixiong Yu To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 -next 12/16] fs: dcache: move the sysctl to fs/dcache.c Date: Sat, 11 Jan 2025 15:07:47 +0800 Message-ID: <20250111070751.2588654-13-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111070751.2588654-1-yukaixiong@huawei.com> References: <20250111070751.2588654-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-Rspamd-Queue-Id: 9E8B718000A X-Stat-Signature: shipxzq1q9qgkyf71wc8ii46fhienc55 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1736579583-442338 X-HE-Meta: U2FsdGVkX19xbsYUWqfGPIpBSsniPvLfvNvtoUBEiFREAtZ1jR9uDuLt4MvZiJJ3GYp4SV3yl6L+W+lMihazsLaYpKKYZ+qH50BbbVGBuS9C82mz0ulpqDg7nui3PrUm1Obs+43q4N+wLKxGfZe+dkCx9z+ybSesT5w41Tr/qDsCdpuohCPDQHuW0xJeFEqKrWUVBrrDWuNuevVY9Z1JwfyzeM5X77XmiQ8gdpvfrM3aMTwwHPPW/CTdQZI98IOgCDwGsWYR5YVYLsVnzw4ImFJAI6BjlH2d9GgBsyjnYQy/85z0sdxCUstKmafDDNjHwzbS1Mmle+WqnF8Sv/P941yLVgx4Iuk2GXBjAeMCkLnmXxuGnR6x9QD7mQeK8lp6+KsuwmemlOUMxIE10fyZ8RHjOHTmDxjduIHZGv3ED1DLyIFBq05SrhXJjxgTfMZWlBxpObjXX59ycdfpQTIHUEd2V8vO5HNCeDMt8PrbyecFnsKcB92KSREO3sNbJY1E/GiIB6vxIR9QiVJ81AwpD6Urfc06snKFrrxcKXDX5+YUAMabWkhc+I+ej6BvoVoTxmBN90Xx/zxa0M6SQiy1SyQQGkb8YwCMWns/uNqDDC819IG8SX02f49RoNmaohBV2vQOiztAT434QbpZDlMkjPgpBMtfyGs7eIOVHtbrFbGQpVIvGARjvDxf+dLfmQKIT40FlFmN4ZKuzmCBkoULfYXer4D5MLJztHLH1GikIlVmwByA3GgF6BBBftLqnM8eGLmpvRjmcVNKNZOokXZa+FgqHfmKy8vWxpiFvrFOam3P4N/++HRVdlqA+C/37gD1iWBJJLSCtCHU3Xgfd2HhePHj+bEQbbbyvUeC3rWfY3jSsQzeeNLM6f3bY+LQiPg1Ikyoo7SQRFbYNUeRtHfc2w95Il5jbpqFb4roNwVVdroYqS9ZUseF+KHHR/B+6fE273Mc6K5P7LtPHQl5Nqv AEjQsq2m VEzfps4ffH0AGvt6f2EriDDRm//HxMmUgAV49oCmjijfCbqPKxV/nAnY9HrWHl2J2mCGaU2CtQcB8I/a2fkCECpcoi4F2ednBte1aJ0suvpIR+NfOp0P61lpqSvK1vueZ3jkIOEZUn/7ASNvuH26dx6K41FPe9yaX1NPmFGLdD0ZORpKTNiOTTMsPQq5ao1wvsTKJj3PJcx7YFS2x1D4wZinzL3lPIC6gCd9hM3dgaRxP2letb49UPAcn4bl+Bmnt2uUOMjUl+qqsJo7/hoMeANw5dTsUyIbfURdt2TTi8mU97E9UDA8zZ30PSA5UX/jg+dUTBlxkFNGguY4= 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 fs/dcache.c from kernel/sysctl.c. As a part of fs/dcache.c cleaning, sysctl_vfs_cache_pressure is changed to a static variable, and change the inline-type function vfs_pressure_ratio() to out-of-inline type, export vfs_pressure_ratio() with EXPORT_SYMBOL_GPL to be used by other files. Move the unneeded include(linux/dcache.h). Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook Reviewed-by: Jan Kara Reviewed-by: Christian Brauner --- v4: - const qualify struct ctl_table vm_dcache_sysctls v3: - change the title v2: - update the changelog to call out changing the inline-type function vfs_pressure_ratio() to out-of-inline type --- --- 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 b4d5e9e1e43d..77ca6e9bb71e 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); @@ -211,8 +216,20 @@ static struct ctl_table fs_dcache_sysctls[] = { }, }; +static const 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 7fb77cbcc24d..860dea8f1587 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -2014,14 +2013,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)) {