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
This commit is contained in:
John Baldwin 2001-06-25 18:29:32 +00:00
parent 84bbc4dbda
commit c4f7a18726
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=78766
2 changed files with 6 additions and 0 deletions

View file

@ -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",

View file

@ -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",