diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-01-28 22:11:53 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-01-28 22:11:53 +0000 |
commit | 614c424e998726dec6600ec7a9c09adaf61777f6 (patch) | |
tree | 3dc37fc600f8279792670ee923c7b12e97a1f3ec /sys/kern | |
parent | e2d757c7c1da6f5614a8a01cd4f2791254cc855c (diff) | |
download | FreeBSD-src-614c424e998726dec6600ec7a9c09adaf61777f6.zip FreeBSD-src-614c424e998726dec6600ec7a9c09adaf61777f6.tar.gz |
Add a reset sysctl for mutex profiling: zeros all of the mutex
profiling buffers and hash table. This makes it a lot easier to
do multiple profiling runs without rebooting or performing
gratuitous arithmetic. Sysctl is named debug.mutex.prof.reset.
Reviewed by: jake
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_mutex.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index df01eb6..e56c5b4 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -205,6 +205,33 @@ retry_sbufops: } SYSCTL_PROC(_debug_mutex_prof, OID_AUTO, stats, CTLTYPE_STRING | CTLFLAG_RD, NULL, 0, dump_mutex_prof_stats, "A", "Mutex profiling statistics"); + +static int +reset_mutex_prof_stats(SYSCTL_HANDLER_ARGS) +{ + int error, v; + + if (first_free_mprof_buf == 0) + return (0); + + v = 0; + error = sysctl_handle_int(oidp, &v, 0, req); + if (error) + return (error); + if (req->newptr == NULL) + return (error); + if (v == 0) + return (0); + + mtx_lock_spin(&mprof_mtx); + bzero(mprof_buf, sizeof(*mprof_buf) * first_free_mprof_buf); + bzero(mprof_hash, sizeof(struct mtx *) * MPROF_HASH_SIZE); + first_free_mprof_buf = 0; + mtx_unlock_spin(&mprof_mtx); + return (0); +} +SYSCTL_PROC(_debug_mutex_prof, OID_AUTO, reset, CTLTYPE_INT | CTLFLAG_RW, + NULL, 0, reset_mutex_prof_stats, "I", "Reset mutex profiling statistics"); #endif /* |