From 614c424e998726dec6600ec7a9c09adaf61777f6 Mon Sep 17 00:00:00 2001 From: rwatson Date: Wed, 28 Jan 2004 22:11:53 +0000 Subject: 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 --- sys/kern/kern_mutex.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'sys/kern/kern_mutex.c') 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 /* -- cgit v1.1