From patchwork Tue Sep 3 03:30:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13787961 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 7CF51CA101E for ; Tue, 3 Sep 2024 03:31:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7555C8D0132; Mon, 2 Sep 2024 23:31:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B7C68D0119; Mon, 2 Sep 2024 23:31:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57F408D0132; Mon, 2 Sep 2024 23:31:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 36BD78D0119 for ; Mon, 2 Sep 2024 23:31:37 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B1AA1401CD for ; Tue, 3 Sep 2024 03:31:36 +0000 (UTC) X-FDA: 82522002192.14.9183819 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 61ACC120004 for ; Tue, 3 Sep 2024 03:31:33 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1725334200; 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=JXWgL2fIsADO6hlayuZM6T9P5NxRk5ZKD6PY3Fe0TkQ=; b=t2KsYEjWLmIfBguOvV9ax7aesZ4i6K++vPJx+C4tpvIwAib9yXHByu28dwnxnpb74ltIKw uDLIBj5AQoFkBo0JTrUt6Ph85bu5hvzlELcS6aP70RhOzSBN0/T1xGuAGcgZeb+ZyAjS9a 0Af9/j3l2o5znKlnlRFH2Y4KeYZDP+w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725334200; a=rsa-sha256; cv=none; b=18LSdg/zZILrkqqPKiwKQ3PJQ/fZbSWzB6kR7kaJQs4R7sAh7e9DRRnxbThDLinXDQmB7B BreJ+b5UY5ReiqPBnd8uk4JqBxjtJUJznGgw8t9eGiCCQa1ayZW5znz06H5LMhqE3Cii0B +B/QdlZzarZhlyQWH91DMilpiLfEGx0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WyWM82cThzgYvk; Tue, 3 Sep 2024 11:29:24 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id EC29C1402D0; Tue, 3 Sep 2024 11:31:30 +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; Tue, 3 Sep 2024 11:31:28 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 -next 12/15] fs: dcache: move the sysctl into its own file Date: Tue, 3 Sep 2024 11:30:08 +0800 Message-ID: <20240903033011.2870608-13-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240903033011.2870608-1-yukaixiong@huawei.com> References: <20240903033011.2870608-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: 87ubfmnhpdjcek93j8jo46djhzd119i7 X-Rspamd-Queue-Id: 61ACC120004 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1725334293-985253 X-HE-Meta: U2FsdGVkX18eSumkHKffar4jMpV4MB/gVWaFlB+egqBHK5D1++WFzUsxo3PAjBU3kWsvB2iY34RAepZcjduzPIdMmPoaSKputMxMatkh4ztuOwO7TrFf0EttkTvf8wAhg8YDIvaq6h3uy9+73dkbK3a5lgkRcpcy31b9BT5Tir7RfK6douINpQmQAREJn12bon4S0fH+cHKDmS/Px4er6lh0px8dhsDcNd0AfhuFjA3BanbQQTEJo4aKqun+rrOAOR4/5hW60udqfWnlx+CkzlWaOHCCRH+RqnJP8a4Xt+/BJoYG+3UwFzEsK7RIP2Fc8Enpbi9CF6WKcW70xfRYkhAsRyefe/fwN83+7wQnnnGGo1BiKsMgywRaQghsNGRgfmNahoiMimt0S+1op4rKWVcfUn6/yTTYnsSsWR7wFP6xU8xYMDTuY9UVxE8x+mYVDCicIK2lQjEGFDGokGs+MXCwXoJ2HZaYW5vE01vNYeDTuRyLnXsTKacYrMGZPcdwdVBiiPbpGoXLf0WclQPpswrisc+/b3+yQTanvsUnZo+ibfsSrrYSZGJIPMnjBNc6mqhahzS5WDM8VDhDHvqifFxnJJizCMEdKs4Z3HH5i7pwBQbEJSiuPz+voOPxbdVwu/pi/+zv6FR8YBeoY7vqrI0gK7EWmIcpTVQTyqG/cbfDZpqKkL0m5fkHNN35j9PQ906iUUsgu//2FbmzIe32isLOUgw0SgGm0DCCHXZjN/6fB1jIY+E296/2fMqiGoqpw4E2PW5kSDXe3MiyhpT1KgKgJ0Qr4yhUhECoJku/j8KFjD0exjBYFkv4qRsueuxz+t6YI6og1x4RiDDijPjxOarqOGdqw6eks48wDu20v8mlQqG6sYV7YVYDSqSgbXxq6IiUdmr5cg91t4SOzE79iXBAicogAkQbg9fS0Y2OPNCRfp8jNdMB4PFuBsM11jOilnRZLfozE4p0cPlObvJ aivul+Qq MJQhBuh2q6o455sVyLdZH/mg6TX3StQNoQ/yb/CheznaIf7vj8vLs1VFaIwGR1097vOcgwpw2AQCaqe3iBziomfkMWvQZzENtTgIspJDYzXHk5BC3LP4bklfwGv5Gvi4EkjGBg+qIPpD/f+ERpyrduqO6H7vNSNQkfvUc93EbAOYmVDw= 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 its own file 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 --- 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 0f6b16ba30d0..17ea029fa9c9 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); @@ -201,8 +206,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)) {