From nobody Mon Jul 08 18:17:58 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WHsml0wbBz5QK9f; Mon, 08 Jul 2024 18:17:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WHsmk6jF4z4V4k; Mon, 8 Jul 2024 18:17:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720462679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aQXvUsVrTD/MYSHYSvzS7E5+rayPU6+vnU4cowIWVFk=; b=Wnn2l/jsndd9mEvkQDJepejadmQdoe7pkTKo6+qrym7eGMkFH5oANEgxgtloObOw7wHl22 MlkfTtPUX8RaYPeXQ7vzy++n2qmCf47Ch9QuyPS0FmapzMubTa3bvzCLfk9bphTPM7T32z ULDi0VQ+krIIH1Qm5Ml6jnHJfX6e7halmYKiHjZHybwCauwj38zVjxOPumUCRusE2CWw4f 3h3fou5MZrvKDDKxz66j+sESafcO0dmrHW5POhjfATeuaD+ymY7dQFJZp2wdMWjx97LUPZ XOqqwYMOfWZ311wxZ+vcU13r31TIdXeT4C4AgMVJHB0xhG3DZoG56hHaV1I+JQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720462679; a=rsa-sha256; cv=none; b=mKh7uT55kurWmgx3CUpaA2mYfZLmjlj9JcSHGGK8yBsgwoHhNyGDu1iPoDLajx8pdRakiC Kr5lLNIIovzbhFsLk3ayNt8nt6os+N2zP8HqYd+/pKoCLfHc5th4Zgwc+7XKTekLfSy4x4 GWZZnIPfq4+G4wg/3AjXZT8lJKMwdDu0WdJiDQHu5XwrL366Iss7U+j0rtAzwLP+JMpS+j Zbw0bGF70RbOUyp6TR09qfoahgF7uK2e5UZczTgXD6JUtkh8zw9Obn20QKhTBmwx9RyA4V 1RajgB77cWs7fNxBHsH7dB319posh7eImQZKnvcBRGVCXde/ErxIhHAVxHLM8w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720462679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aQXvUsVrTD/MYSHYSvzS7E5+rayPU6+vnU4cowIWVFk=; b=vzuPXc4MMTclEkLdGyikbVbDhCPNDy1T2hr2g1TpbIGizE7s6feIY2o3KWigUkaX92yFXQ a+f7ABfaWFjLi+/JHVIkq/vGRKxQxBlXya0dkaoYt1JR90AQ6i+VYe66ztxDPR03nEMkx8 B1WlZi+u/3Ixdy0nZku0rLM9qln93AjPcaZKb58WfOja7h1nWLF7iatxBn4fAp1swKlyN5 Ym3G76xSRrXcSiE0ZvZvOiauos0gFuGdgLPddIpoXJCleS+vH7DSz/1xyXEPhxC9SkGM2s 1vzdUF3ScKaIcIeIqJTO/5DgPumXIti+D0YCA2jleEpeMPzKkgUhAgFLTByYkQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WHsmk69FPz12C1; Mon, 8 Jul 2024 18:17:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 468IHwqf092070; Mon, 8 Jul 2024 18:17:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 468IHwKr092067; Mon, 8 Jul 2024 18:17:58 GMT (envelope-from git) Date: Mon, 8 Jul 2024 18:17:58 GMT Message-Id: <202407081817.468IHwKr092067@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 0a487207227b - main - vfs cache: add sysctl vfs.cache.param.hitpct List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a487207227badcbfbec029103ac7e2d5291bd30 Auto-Submitted: auto-generated The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=0a487207227badcbfbec029103ac7e2d5291bd30 commit 0a487207227badcbfbec029103ac7e2d5291bd30 Author: Mateusz Guzik AuthorDate: 2024-07-08 17:57:39 +0000 Commit: Mateusz Guzik CommitDate: 2024-07-08 18:17:54 +0000 vfs cache: add sysctl vfs.cache.param.hitpct Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/kern/vfs_cache.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 375b682e1f3a..fa6b23fe3d6f 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -1071,6 +1071,26 @@ SYSCTL_PROC(_vfs_cache, OID_AUTO, nchstats, CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, sysctl_nchstats, "LU", "VFS cache effectiveness statistics"); +static int +sysctl_hitpct(SYSCTL_HANDLER_ARGS) +{ + long poshits, neghits, miss, total; + long pct; + + poshits = counter_u64_fetch(numposhits); + neghits = counter_u64_fetch(numneghits); + miss = counter_u64_fetch(nummiss); + total = poshits + neghits + miss; + + pct = 0; + if (total != 0) + pct = ((poshits + neghits) * 100) / total; + return (sysctl_handle_int(oidp, 0, pct, req)); +} +SYSCTL_PROC(_vfs_cache_stats, OID_AUTO, hitpct, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD, NULL, 0, sysctl_hitpct, + "I", "Percentage of hits"); + static void cache_recalc_neg_min(void) {