summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-01-28 22:11:53 +0000
committerrwatson <rwatson@FreeBSD.org>2004-01-28 22:11:53 +0000
commit614c424e998726dec6600ec7a9c09adaf61777f6 (patch)
tree3dc37fc600f8279792670ee923c7b12e97a1f3ec /sys/kern
parente2d757c7c1da6f5614a8a01cd4f2791254cc855c (diff)
downloadFreeBSD-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.c27
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
/*
OpenPOWER on IntegriCloud