From patchwork Mon Dec 23 14:15:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918965 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 B7A4FE7718D for ; Mon, 23 Dec 2024 14:20:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBB6C6B00C8; Mon, 23 Dec 2024 09:20:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E68036B00C9; Mon, 23 Dec 2024 09:20:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB9EA6B00CA; Mon, 23 Dec 2024 09:20:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A2EA06B00C8 for ; Mon, 23 Dec 2024 09:20:19 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 45E5A44589 for ; Mon, 23 Dec 2024 14:20:19 +0000 (UTC) X-FDA: 82926432624.24.3934508 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf12.hostedemail.com (Postfix) with ESMTP id 2663B4000F for ; Mon, 23 Dec 2024 14:19:59 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1734963577; 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=ElCpcOtOF8C5tffGRRfsF8TFf4sMlWwEWJmYF79t/o1579pGHPvZzop2fzjyi8U/Fzim+e 83KlfQUDP9dn0Z1qcCGsoUQp9MEfTEX1SfVi0lhkZPwpPz3m/onU022cKK3jvB092w+NzW NeSVjLdRUi/bFt5A9HcBkrj+yDIwLDk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1734963577; a=rsa-sha256; cv=none; b=4VPGUf7+cnGYJsgJD3h+N/BGshi7ty6MlIE1NZZPMVLVVt1nLKCffxL0iF0r0DLsG3/7M5 d0SgS6NIAldyvyXRh1uf5KVlwrvX5D+xQ/ZaIpAjRQj9hfxlYlu2zxhkf9fBkPNJD/ARZ5 ZjGzGBERGeJhJ9drZ/BNxRk5gtWIB0U= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YH0Tl6qjgz2DjPQ; Mon, 23 Dec 2024 22:17:31 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 2DAFF1402E0; Mon, 23 Dec 2024 22:20:13 +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:20:09 +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:31 +0800 Message-ID: <20241223141550.638616-13-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-Server: rspam06 X-Rspamd-Queue-Id: 2663B4000F X-Rspam-User: X-Stat-Signature: spqppbgrp6fwgwrxmsofc6939zcnwobc X-HE-Tag: 1734963599-253223 X-HE-Meta: U2FsdGVkX1+fj6jr/K+645Rz5KIsgXpMKuIeIrKfUUnMTsWckbrmUrVKaX3Z+QCT4liBktok+E+rvfIyBkIMDHUg+mN19RKI1A3YvmAHyN34KhQTMuxwYBHtPNQj0/bK4AJFNXE2AQSo5mFObVCJFdmZCvqlzY8IhVIR04d+MKwJ0UhZfFzL8c4jo4vLEO6BLEtIDUf3x4QSdR71e1Dou9O2sgZA13g3O8Tor+LyN4b+SF42XdHS1jmFEIlUReWDhk3oNH5Hw0FfVxcdmT8H9kk5uHCsVXA/6mH6/Nzg9btRa2n4V44l5w0aaV1YZYg3KalE3tfUwzhnMuMIScTRX2dCaX5ohXd2MuWqP72oFyg7cyL++p1WHSWu83gfmoJQXDpoh2VLk5xBTdpoz2HxiJQaLszFayvxPFzzPqnlIyn6sTm5TQSP1Pg2PBzMmgrjvdKtZmhoN5NWVIJG8JveGH0xHCoa9cqp7I1Nda0//L4whLtYl5/ewoldY0Y39nqT7eJoXBJoYvqQ3A90gmMWxbSED4tBAT80ZevOMZb8DHf/KyFzrL+Y7Kr7ndLPaElvDB8G9UxHS0vh3F38sp7tbOxCg+TN8glhDlYm1QhS+glPovIi5bo4zWWJbug2afUbjfQMGhFf9uN1cXxZN6nYbJEniqydBrCKXeXr4R67IBkDEGOv8Z8BIwJAlrreKGm+QDaP2sbw+B56Deybf6adkWS0VSEppTMPHOZIUUCl511dOthKdGwLfyTykEJ7qZlIHJIiTxA84NdQ7G7zbq6IH2LL3hglTzPoEdjhiOCi+rEFaQ4MlTT2jrIeyAXTP/59rEnPETMOiLA+rCbOKpL9svbhV0vJGUtHkoXrSn22eq1KnJukGkrdht0H7cOHqyA7GJ4A7T/n4twdfRvh/IApcOF9gB2/DrwFNUII8GOuQmVu0EccGn3GBckX+yCz0JCucJ/Jkf88Q9pFXJmYQ5d lrFIpSJJ WCnA06aZpqcuTcirlXjxn4g85v5ST9GvF/nShs1M0mimQxxLsOUpL6wV9PgM/itRUHBpsLwc9bYO78Kj/8wsR5oD4UYpGGmm5NOgeXSpCi+SxhX9CHQeGXXNNtQDaCoBavcMT6Cp0Xn8s7ZasB3JSa6EC7+0/3rLgVitp0w5B6f6Gz5Y= 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)) {