git: bb84ee652edc - stable/13 - vfs cache: sanitize debug counters
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Oct 2023 23:53:48 UTC
The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=bb84ee652edc233b5796f07a8b44a6b2f9221b0a commit bb84ee652edc233b5796f07a8b44a6b2f9221b0a Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2023-10-05 12:16:18 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2023-10-13 23:48:12 +0000 vfs cache: sanitize debug counters They are very rarely triggered, so no need for per-cpu distribution. At the same time the non-cpu ones still should use atomics to not lose any updates. (cherry picked from commit 2749c222da8a6325d39c0571f72b1dbed2f7d583) --- sys/kern/vfs_cache.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 29f14fb931e6..1d52b2e63169 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -557,17 +557,14 @@ static SYSCTL_NODE(_vfs_cache, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "Name cache debugging"); #define DEBUGNODE_ULONG(name, varname, descr) \ SYSCTL_ULONG(_vfs_cache_debug, OID_AUTO, name, CTLFLAG_RD, &varname, 0, descr); -#define DEBUGNODE_COUNTER(name, varname, descr) \ - static COUNTER_U64_DEFINE_EARLY(varname); \ - SYSCTL_COUNTER_U64(_vfs_cache_debug, OID_AUTO, name, CTLFLAG_RD, &varname, \ - descr); -DEBUGNODE_COUNTER(zap_bucket_relock_success, zap_bucket_relock_success, +static u_long zap_bucket_relock_success; +DEBUGNODE_ULONG(zap_bucket_relock_success, zap_bucket_relock_success, "Number of successful removals after relocking"); -static long zap_bucket_fail; +static u_long zap_bucket_fail; DEBUGNODE_ULONG(zap_bucket_fail, zap_bucket_fail, ""); -static long zap_bucket_fail2; +static u_long zap_bucket_fail2; DEBUGNODE_ULONG(zap_bucket_fail2, zap_bucket_fail2, ""); -static long cache_lock_vnodes_cel_3_failures; +static u_long cache_lock_vnodes_cel_3_failures; DEBUGNODE_ULONG(vnodes_cel_3_failures, cache_lock_vnodes_cel_3_failures, "Number of times 3-way vnode locking failed"); @@ -1668,7 +1665,7 @@ cache_zap_unlocked_bucket(struct namecache *ncp, struct componentname *cnp, cache_zap_locked(rncp); mtx_unlock(blp); cache_unlock_vnodes(dvlp, vlp); - counter_u64_add(zap_bucket_relock_success, 1); + atomic_add_long(&zap_bucket_relock_success, 1); return (0); } @@ -1764,7 +1761,7 @@ retry: error = cache_zap_locked_bucket(ncp, cnp, hash, blp); if (__predict_false(error != 0)) { - zap_bucket_fail++; + atomic_add_long(&zap_bucket_fail, 1); goto retry; } counter_u64_add(numposzaps, 1); @@ -1990,7 +1987,7 @@ negative_success: counter_u64_add(numnegzaps, 1); error = cache_zap_locked_bucket(ncp, cnp, hash, blp); if (__predict_false(error != 0)) { - zap_bucket_fail2++; + atomic_add_long(&zap_bucket_fail2, 1); goto retry; } cache_free(ncp); @@ -2188,8 +2185,8 @@ cache_lock_vnodes_cel_3(struct celockstate *cel, struct vnode *vp) } else { if (mtx_trylock(vlp)) goto out; - cache_lock_vnodes_cel_3_failures++; cache_unlock_vnodes_cel(cel); + atomic_add_long(&cache_lock_vnodes_cel_3_failures, 1); if (vlp < cel->vlp[0]) { mtx_lock(vlp); mtx_lock(cel->vlp[0]);