Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jul 2024 22:05:43 GMT
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 72f8b18b8d93 - stable/14 - vfs cache: add sysctl vfs.cache.param.hitpct
Message-ID:  <202407102205.46AM5hLO079946@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=72f8b18b8d93bee8f6ca6ed0dfa160db18424807

commit 72f8b18b8d93bee8f6ca6ed0dfa160db18424807
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2024-07-08 17:57:39 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2024-07-10 22:04:40 +0000

    vfs cache: add sysctl vfs.cache.param.hitpct
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit 0a487207227badcbfbec029103ac7e2d5291bd30)
---
 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 70c4dbc01c98..9ec0970628b4 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -984,6 +984,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)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407102205.46AM5hLO079946>