diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2024-07-08 17:57:39 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2024-07-10 22:06:15 +0000 |
commit | 8b5eb0cf6c4f586f891fef7fb067beb343826435 (patch) | |
tree | 56bb9b6a5b56455c68bfa61bed330ba05fc2139e | |
parent | 1f0f120183db12e680107a0553a8de2d854aa757 (diff) | |
download | src-8b5eb0cf6c4f586f891fef7fb067beb343826435.tar.gz src-8b5eb0cf6c4f586f891fef7fb067beb343826435.zip |
vfs cache: add sysctl vfs.cache.param.hitpct
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 0a487207227badcbfbec029103ac7e2d5291bd30)
-rw-r--r-- | sys/kern/vfs_cache.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 647d4573563c..aacbd43403e1 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -988,6 +988,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) { |