diff options
author | Alan Somers <asomers@FreeBSD.org> | 2019-06-27 16:30:25 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2019-06-27 16:30:25 +0000 |
commit | 560a55d094668823dc146287571c310366cdf737 (patch) | |
tree | 31025b4182fab9fcacf9ce37f114ec90084af8b9 /sys/fs/fuse/fuse_internal.c | |
parent | caeea8b4cc5a58dc22469a50e2ab5a0d0c8f8ae9 (diff) | |
download | src-560a55d094668823dc146287571c310366cdf737.tar.gz src-560a55d094668823dc146287571c310366cdf737.zip |
fusefs: convert statistical sysctls to use counter(9)
counter(9) is more performant than using atomic instructions to update
sysctls that just report statistics to userland.
Sponsored by: The FreeBSD Foundation
Notes
Notes:
svn path=/projects/fuse2/; revision=349462
Diffstat (limited to 'sys/fs/fuse/fuse_internal.c')
-rw-r--r-- | sys/fs/fuse/fuse_internal.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sys/fs/fuse/fuse_internal.c b/sys/fs/fuse/fuse_internal.c index 7923bff707e9..870c6e7eb538 100644 --- a/sys/fs/fuse/fuse_internal.c +++ b/sys/fs/fuse/fuse_internal.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> +#include <sys/counter.h> #include <sys/module.h> #include <sys/systm.h> #include <sys/errno.h> @@ -107,6 +108,15 @@ static int isbzero(void *buf, size_t len); #endif +counter_u64_t fuse_lookup_cache_hits = 0; +counter_u64_t fuse_lookup_cache_misses = 0; + +SYSCTL_COUNTER_U64(_vfs_fusefs_stats, OID_AUTO, lookup_cache_hits, CTLFLAG_RD, + &fuse_lookup_cache_hits, "number of positive cache hits in lookup"); + +SYSCTL_COUNTER_U64(_vfs_fusefs_stats, OID_AUTO, lookup_cache_misses, CTLFLAG_RD, + &fuse_lookup_cache_misses, "number of cache misses in lookup"); + int fuse_internal_get_cached_vnode(struct mount* mp, ino_t ino, int flags, struct vnode **vpp) @@ -130,11 +140,11 @@ fuse_internal_get_cached_vnode(struct mount* mp, ino_t ino, int flags, if (*vpp != NULL) { getbinuptime(&now); if (bintime_cmp(&(VTOFUD(*vpp)->entry_cache_timeout), &now, >)){ - atomic_add_acq_long(&fuse_lookup_cache_hits, 1); + counter_u64_add(fuse_lookup_cache_hits, 1); return 0; } else { /* Entry cache timeout */ - atomic_add_acq_long(&fuse_lookup_cache_misses, 1); + counter_u64_add(fuse_lookup_cache_misses, 1); cache_purge(*vpp); vput(*vpp); *vpp = NULL; @@ -1157,3 +1167,19 @@ isbzero(void *buf, size_t len) } #endif + +void +fuse_internal_init(void) +{ + fuse_lookup_cache_misses = counter_u64_alloc(M_WAITOK); + counter_u64_zero(fuse_lookup_cache_misses); + fuse_lookup_cache_hits = counter_u64_alloc(M_WAITOK); + counter_u64_zero(fuse_lookup_cache_hits); +} + +void +fuse_internal_destroy(void) +{ + counter_u64_free(fuse_lookup_cache_hits); + counter_u64_free(fuse_lookup_cache_misses); +} |