From patchwork Thu Oct 10 15:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830203 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 12474CF11F8 for ; Thu, 10 Oct 2024 14:12:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 918086B00A4; Thu, 10 Oct 2024 10:12:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89CF06B00A5; Thu, 10 Oct 2024 10:12:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A13F6B00A6; Thu, 10 Oct 2024 10:12:15 -0400 (EDT) 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 451EB6B00A4 for ; Thu, 10 Oct 2024 10:12:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 830271604AF for ; Thu, 10 Oct 2024 14:12:11 +0000 (UTC) X-FDA: 82657882188.02.1285C79 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf23.hostedemail.com (Postfix) with ESMTP id C503A140006 for ; Thu, 10 Oct 2024 14:12:11 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1728569381; 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=m+aqCBGqG1LLcsWoa/sFnsKwtSGT9ES7SdGk4tfUnsk=; b=F5/WmJQy5JC2P4HVEBJz88SZRzN61R4TYSL2QARbBLXbo31x9i7+bExGQOjhp9YxXxmnIZ M4ydVcUaaX/N0/JzQh5F+jm2hZneN6WyMeUUMCN8XKK9b2OJZ7cqaR/ILZkKB1GlQcfH5p dSR8Mt51GKQWi/l6joOmP+I7E3lUDh0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569381; a=rsa-sha256; cv=none; b=dB16iGH7SJEzEyi8z8WHhqZ719lBRrp4EWUIDnncpXUhnmQtquE11Dg8PhnNsUPvRJA1uk RWBTSmsdzv7491KQ7mm+UqY70M0G5sgF28Jg2gQuJqmcX4wh2/0ACZ50mZaCEdS3BEkQOB 4p3qvqkcJu+jgZRQjA+HuPagqc99Hbg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XPWqP4l4qzpWhQ; Thu, 10 Oct 2024 22:10:09 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 342941402CA; Thu, 10 Oct 2024 22:12:09 +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:12:05 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 12/15] fs: dcache: move the sysctl to fs/dcache.c Date: Thu, 10 Oct 2024 23:22:12 +0800 Message-ID: <20241010152215.3025842-13-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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C503A140006 X-Stat-Signature: dsai1q6gyh36c7kfomh9k1gkhxp7myqf X-Rspam-User: X-HE-Tag: 1728569531-415642 X-HE-Meta: U2FsdGVkX1+rAGhTsP4Kr5Fas7gvMXo7xQgK9pgrwBdehgHGrpUm2OZ4pVJaRpJ5ADphz/Sf85QmSR216qHPhuSsKi2rhnLddWgki8s02eY/pP6daY1vPzpewA5rSIxIdNwcfMGqjHV8ojapyZtUobqTja7EwJKcc0s/S3LO169g7BFmUD8LtVRIORNt2aj3REZyAt5OwobR3MUdKbZ3dK2kJSwWV1DcOFc2Oc5hTfNIP0AZucOzaT/yiEesmmDQmmYo+UM9iG73PFUrJw/8DMusygu3wO/0LFpjaKH/cIimyR5Q6WgC6IgriONaqTYjzSbe2UnrMbs/VM0mejbhWzZ8CmLimv24MCLAmjgLh3V4yk0qqzPTcW+CAq8Wzr4pdBGzjUSL2wYpAeF19Ui1DgHoAzg2FQINDk55d7nEy0seEhLBmhDa1UpfgDPNT+csqvgICo/+1/k7AcLKlCfjzTAl9FxTyK1EhH/0kDey8YEUUBsk9yxikFyZq+ciZPFWGWOv22EctVqb5a+f27zXwXwYP7FTm7TapxSAGWB7iZBf2gRrAF9y41EUpjSV+bL0kesaoTgWlWe3mfJqqmJGbCXeQEfXLfc0AuezPzFTJvtsVrR+LZS3nzsIVjoiVATwRTMR2s4bNMbdLpMoiUNTrRik88Y4QjbOBYaZu69BrsamlOOxxJsnK56GvEHFDPYiOYOIi0c21s4nqCwtbp4uvco2SmIkdyez+ZHPSz7s6XKubNrMrp6KCL2n9EiiNjb6q/6WWdRB+jE1vT2FdEF4J2vOR2nEqYX6Ta9/v49PS2njvZuqbvLjTw3VT93ikN4eDaZluMp+jgsLgXr0nzbLPMtHrEaTi8K4CQfm7TQ/c3oiKDqjhiQKieOqJinjzEwae6hWssP+9JmyLfKBiSdIrwhKnrY7TRidNx3Qh5B3GK7loo0m/XMI3ZwodiPHKC2cSoyFtkRJVF0UtwFWRnx RTvWJ1YE SXUy34ruHbGys1U6tVtQuNss8A/jTM9t+qwuNMOq/DjnkuxBHt1DyzAK5sFpxmpWiJ6h5ahxxETWSRDltVgFD+xfGpjyW9L5DXdz4uFcMN7Rh4xNX3vnYgQsoYI/bf2XLy0TCbcDkIk/Ieci1UFQvL/TNlnWS+7NWx/BgNZFzIg0WubOCYRFSd4m78+KM4KawsBNdfK2RFqunexI= 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 --- 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..de240b7f6c47 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 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)) {