From 503916a7c1d38ccdfbc10aa3e2e68f95b03727c8 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 21 Mar 2007 20:46:26 +0000 Subject: [PATCH] Don't use cv_wait_unlock() to implement cv_wait(). Instead, implement cv_wait() fully and add missing KTRACE context switch traces. --- sys/kern/kern_condvar.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c index e7410e63f717..62e4f04de618 100644 --- a/sys/kern/kern_condvar.c +++ b/sys/kern/kern_condvar.c @@ -96,7 +96,16 @@ void cv_wait(struct cv *cvp, struct mtx *mp) { WITNESS_SAVE_DECL(mp); + struct thread *td; + td = curthread; +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(1, 0); +#endif + CV_ASSERT(cvp, mp, td); + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &mp->mtx_object, + "Waiting on \"%s\"", cvp->cv_description); WITNESS_SAVE(&mp->mtx_object, mp); if (cold || panicstr) { @@ -109,7 +118,21 @@ cv_wait(struct cv *cvp, struct mtx *mp) return; } - cv_wait_unlock(cvp, mp); + sleepq_lock(cvp); + + cvp->cv_waiters++; + DROP_GIANT(); + mtx_unlock(mp); + + sleepq_add(cvp, &mp->mtx_object, cvp->cv_description, SLEEPQ_CONDVAR, + 0); + sleepq_wait(cvp); + +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(0, 0); +#endif + PICKUP_GIANT(); mtx_lock(mp); WITNESS_RESTORE(&mp->mtx_object, mp); } @@ -153,6 +176,10 @@ cv_wait_unlock(struct cv *cvp, struct mtx *mp) 0); sleepq_wait(cvp); +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(0, 0); +#endif PICKUP_GIANT(); }