From patchwork Mon Dec 23 14:15:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918980 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 87DD2E7718B for ; Mon, 23 Dec 2024 14:21:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 172CD6B00E6; Mon, 23 Dec 2024 09:21:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FD3A6B00E7; Mon, 23 Dec 2024 09:21:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB6B96B00E8; Mon, 23 Dec 2024 09:21:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C92836B00E6 for ; Mon, 23 Dec 2024 09:21:12 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8BDDF1A18ED for ; Mon, 23 Dec 2024 14:21:12 +0000 (UTC) X-FDA: 82926435228.11.06AB0B5 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf26.hostedemail.com (Postfix) with ESMTP id 324DE140002 for ; Mon, 23 Dec 2024 14:20:40 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 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=1734963641; 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=QUQ02bMysBGdHJmw0RHS8/Z/Oi7GfBG3WiJZ+D1BNXN6Vv1fQuvYEAwYqvO6mM1FkVumqr OeGvQGvrNXtunglqc4/TN7f/0eCJ6GmcNTE0Ux13zgJ56cSuzPElh9srdNXiE3qT22GCy5 vqDbpnfq3U0pmOUTZEUDgjx82YUMqw4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963641; a=rsa-sha256; cv=none; b=igOmTvCjE++6BrhH8KpIawb11tVArFyAF3sz5gegaqqQL3liQya2QaAoz0J13F8K+Uce6U eO/PvrRvCI75jbHPnNN9h8eFOGJbwTg3Q2zhJejA/w5LvsD5Eei9snfP2sNCXi+pkDDbJq O6HCWVCOsffhKL0rWwtaS3Jmsl6o5GI= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YH0Vn3knhz1kvwW; Mon, 23 Dec 2024 22:18:25 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 89A601402E0; Mon, 23 Dec 2024 22:21:06 +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, 23 Dec 2024 22:21:03 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 12/15] fs: dcache: move the sysctl to fs/dcache.c Date: Mon, 23 Dec 2024 22:15:47 +0800 Message-ID: <20241223141550.638616-29-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: 324DE140002 X-Rspamd-Server: rspam12 X-Stat-Signature: spqppbgrp6fwgwrxmsofc6939zcnwobc X-Rspam-User: X-HE-Tag: 1734963640-950822 X-HE-Meta: U2FsdGVkX18U1GkB/1IXD8wupupnNspaId4oNLg0e6pKgc7VbsW4xeld+2JWv429yYrZN7chzhWzBtP2x/lQoAM/Zj5aUuNqHezCwOiWxmkKrrueIusWkGfT3GetHlfamTuHtnG8RM3fNFSxfXvIFQfyYeGeBWjf7zImUba7LbfgxE7h+vLzPzLsnajZqvX6tkF/yTEHnfX9PMrPrNWACT6PQn7aYWpqM2BVJ1YeDC0/5Y1kzDvpEuOZ8AS2RG/ryQgB6CqGLwR1RHoPNLrtPUrTnTo/OOqdVPes5JAdbzYcXpn8IUN4fJEl7EEy9z+vXZH67jaJVZ8T29UBQCPk6cvWlZN8CDwoz26LaeU1bgj3dPTUrGI6UWJzZg7c3PulGIo9uXMizkfbB29n3joJYRC4N/y5lOWz4zwfC2dZjaFX03Y43xHfdO4EOi/P5jEawb4L+C2gIMUCgcEJ8+P360K3uQADbvrZFp5K5b7uIug+uiVCjnWM0XOHdyh6P5SzES1Mvf9SAcXglEWlvZy34spR3K99hiMgU9XBrpNGvpZCTMjFdDvEKTp+bgEpbETlj5wAABVB5LSNVfyLCktFlcoWcl8D4VB2lsRCiF99fJAjuVB2In+eMvieiARHA8uXXZA/iU8gGvfBhSwl+mf0V8LnOa3TY7g3vhSOzI8b024Jhl1JI6JKzLoAcucKBl7lvexK+c/zq69Ad0FkvjmgXwQ2gv/26SMpT/TPC66XrABysxpob0sG2pJWriN1UUL0aFaJ/399mnElbpStL13Azco+o6/sSgLWFUAOj8TnAla5DJHaTPxWvLJ3zmPkuS5WVrIk8nxkfgG88+KJhysfnwYZWZwJbGZmqru+rc8gjAxHcCAQ8MdZzwZKmiwG3pXcIPkROUJ1SaUV+GXFJ3Kg71C2/1GFTr6+KinlUHMHxQWqMpLyZ1Ou973WSM/6xdE8cbEZkEX8yPecx348CA6 a8LW9mMK uaUEL06qVL7mSHwiBeXalcYIMts9Wr4navLto+ClTE3ASQefHkRT/X0MGiLuYgqMYIrpt2b18L6iNuncbWlW6QxYtICfa3SKvYdkgzrWIi9cl5ceAuXlUNMyPaukgc50tDMUrhQO6MzEDsX3OQ9FyTZilBQ1DUu+PJpchvK7+9erLhxs= 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)) {