summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-06-25 18:29:32 +0000
committerjhb <jhb@FreeBSD.org>2001-06-25 18:29:32 +0000
commit2660b97507e58be771bd932c06af432819a16aea (patch)
treee6cd45594172cba6bb847805c2960bf291581107
parentfdfd5d01a716f63bcaf43182ffb35b88a505f1b7 (diff)
downloadFreeBSD-src-2660b97507e58be771bd932c06af432819a16aea.zip
FreeBSD-src-2660b97507e58be771bd932c06af432819a16aea.tar.gz
Count the context switch when blocking on a mutex as a voluntary context
switch. Count the context switch when preempting the current thread to let a higher priority thread blocked on a mutex we just released run as an involuntary context switch. Reported by: bde
-rw-r--r--sys/kern/kern_mutex.c3
-rw-r--r--sys/kern/subr_turnstile.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 0007a8b..f2740f6 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -64,6 +64,7 @@
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/resourcevar.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/vmmeter.h>
@@ -399,6 +400,7 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
"_mtx_lock_sleep: p %p blocked on [%p] %s", p, m,
m->mtx_object.lo_name);
+ p->p_stats->p_ru.ru_nvcsw++;
mi_switch();
if (LOCK_LOG_TEST(&m->mtx_object, opts))
@@ -536,6 +538,7 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line)
"_mtx_unlock_sleep: %p switching out lock=%p", m,
(void *)m->mtx_lock);
+ p->p_stats->p_ru.ru_nivcsw++;
mi_switch();
if (LOCK_LOG_TEST(&m->mtx_object, opts))
CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p resuming lock=%p",
diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c
index 0007a8b..f2740f6 100644
--- a/sys/kern/subr_turnstile.c
+++ b/sys/kern/subr_turnstile.c
@@ -64,6 +64,7 @@
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/resourcevar.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/vmmeter.h>
@@ -399,6 +400,7 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
"_mtx_lock_sleep: p %p blocked on [%p] %s", p, m,
m->mtx_object.lo_name);
+ p->p_stats->p_ru.ru_nvcsw++;
mi_switch();
if (LOCK_LOG_TEST(&m->mtx_object, opts))
@@ -536,6 +538,7 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line)
"_mtx_unlock_sleep: %p switching out lock=%p", m,
(void *)m->mtx_lock);
+ p->p_stats->p_ru.ru_nivcsw++;
mi_switch();
if (LOCK_LOG_TEST(&m->mtx_object, opts))
CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p resuming lock=%p",
OpenPOWER on IntegriCloud