From patchwork Sat Dec 28 14:57:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13922374 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 11C04E77188 for ; Sat, 28 Dec 2024 15:02:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 919A46B00A5; Sat, 28 Dec 2024 10:02:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C9D46B00A6; Sat, 28 Dec 2024 10:02:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76A386B00A7; Sat, 28 Dec 2024 10:02:30 -0500 (EST) 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 57E366B00A5 for ; Sat, 28 Dec 2024 10:02:30 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 184DD1616FD for ; Sat, 28 Dec 2024 15:02:30 +0000 (UTC) X-FDA: 82944682338.13.D070FCC Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf23.hostedemail.com (Postfix) with ESMTP id CC5B6140022 for ; Sat, 28 Dec 2024 15:01:57 +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.189 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=1735398096; 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=AcxUGuNcbJ06u2DZEYF4opemsFaq+gz20KNCRF4XqkKzMXAVz+WvI0r6MD62rU1NfP3QEF 85Pn5t3K4dSFO1ds0DjSmzH+t2eAjHNd54LH4euX0Zl1EVwsk5VS7h1BgTn3BAtqTzPZ5g 5XqYinZTPUdkNPVb00+W5CrTNFwVWDE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735398096; a=rsa-sha256; cv=none; b=ET2E7ZpST40XZNcj+5HJ0ixXg8UfS3/slfdlY3GYXM65FPP7KVoRa5pjZp82CpLDjwxOK8 edGiQCK9AVRqIQTwRLMUdvvSzDxHD7SC/A1N8tTtiDLs/AsN1OMt1GB4bjmVPkFxG4LmWV 4h7yoeP0n/B7Kzkq67OwUJ8Oj+1/Z4Y= 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.189 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4YL5Bq5G54zRkMd; Sat, 28 Dec 2024 23:00:19 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 500CA1400D1; Sat, 28 Dec 2024 23:02:23 +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, 28 Dec 2024 23:02:19 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 12/15] fs: dcache: move the sysctl to fs/dcache.c Date: Sat, 28 Dec 2024 22:57:43 +0800 Message-ID: <20241228145746.2783627-13-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241228145746.2783627-1-yukaixiong@huawei.com> References: <20241228145746.2783627-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Queue-Id: CC5B6140022 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: bfygzix7bynzwiask8pykwbqujztds1d X-HE-Tag: 1735398117-224187 X-HE-Meta: U2FsdGVkX18ioUqTc6WIe9TjE9SIufSSNxaR6y6vKxreJnQoD46xXKKe1CAj0aS/EHxV53sb51g29COzxJlSF/b/Bqax56w3ugJ9z7b6N1SsMcH2NkK/ccqSewPrHGAhzSWs0nsYKm+3AHng8gvSJrC907nKvM8lcuhp8nTCRYRW+Iv/Syynu/VeAeaSZRRNyPk1PuSACktBE3AKqkjyWnrM418lux5I1TxTzRE7168jxExzzw79epNCCRfrlM6twofxTE7YdQRL7emZ3FBBFEYMqKNL8KcRY72rGSWDyPGRHDmsgWo/FuRpcHgthI7O4cCojSQK83drwMeGH9TOsRA3GKIERKnuVWAC7829RAdTjLf83oJZoEOXn+V+OYvtG3VQqLj4DnjX8WAScwwzis7JSIkA0QIn5SEPV+J3TwjG2a2HOjS825QQkMJf+vEShtCBUU6Sj5E20vK1I+wUU760zxKzyzno3s7XQxUgivb7hcaWeXpRd6qiT7IcwhwS6XsHFNlr6PNl8rMMWSKyTD540CCnznviUf3yP20sf86WI8x6D4pqy2UU3BKZIDIi3QPDqQjnNo+cEx6e8AXp06OrIaTVv1DKl3UFnRpc9wZ157lyNL9uhyaFtqan2Jl8CEnpGqybEibDQJn1UqilGKRDudgUJUMbMeMe34f0W9quG9ubrgROOCrfwoZ5tmB+DzfHAsBsAfNDy6oLH1Y4fkOwEOeD8E4GCWnwQZGkiIVm+N1KZUrqn3bKxc1N74uT2+dyeDneDq+JOkmyBIp8r1lqP2e30Oi7gRCy1nMf8I8E4teKmJdF198q+R+yL4xdYj1NYFC+78rVJRBJ9lEGoKW+T5N+DQz0YQhzQe/yVZteF+LG/PSOUpxIMgRi2G6Ais6Z9PwtXRkvgMPN1cWsok2loZPJ34pW9kKHuTkoFEpi8I1UVsCZY8Q/1UYINtpf1BirzcHghfta5mXatsg 40dIAk0F ptFs7u1j9pu9PTkJp/2o8CvYrO9vHuID7CNDHQEPjRDuCb+kKk8F3UctFIPw0QGiBudoyDoJhVJeiCXZitgzHdbHg3ub5SNHQdLqPqbp2OkVOIy8pH7wL+xP5TaBErcfWXJ4KC2iIYGDfR+qOMgEf3KbeC9RjhIJcPTTuGrYDrUL5xEjbJd2kFIEYYW3RyUuRq+94itVTpw80+yBpYvnuQ4rUAXxteeTE4Tisw95tziXbfEfDFETbt27EUwcqj3AzC/fbYdb5RglUvCm3qnb5o+O0zZKsUy/AKT5xMDB7HH4CuefSpO02AMD1XBxGd0UIeL8bTFMtZPACZ0g= 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)) {