Date: Mon, 8 Jul 2002 17:59:43 -0700 (PDT) From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 13939 for review Message-ID: <200207090059.g690xhXe041732@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=13939 Change 13939 by jhb@jhb_laptop on 2002/07/08 17:58:53 - Add some KASSERT()'s to prevent foot-shooting from mismatching mutexes and mutex operations. - Do all the assertions in _mtx_unlock_flags() before we run the mutex profiling code so we only perform calculations when we actually have a valid locked mutex that we are releasing. Affected files ... .. //depot/projects/smpng/sys/kern/kern_mutex.c#40 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_mutex.c#40 (text+ko) ==== @@ -313,6 +313,9 @@ { MPASS(curthread != NULL); + KASSERT(m->mtx_object->lo_class == &lock_class_mtx_sleep, + "mtx_lock() of spin mutex %s @ %s:%d", m->mtx_object->lo_name, + file, line); _get_sleep_lock(m, curthread, opts, file, line); LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); @@ -333,6 +336,13 @@ { MPASS(curthread != NULL); + KASSERT(m->mtx_object->lo_class == &lock_class_mtx_sleep, + "mtx_unlock() of spin mutex %s @ %s:%d", m->mtx_object->lo_name, + file, line); + WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); + LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + mtx_assert(m, MA_OWNED); #ifdef MUTEX_PROFILING if (m->acqtime != 0) { static const char *unknown = "(unknown)"; @@ -387,10 +397,6 @@ } out: #endif - WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); - LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, - line); - mtx_assert(m, MA_OWNED); _rel_sleep_lock(m, curthread, opts, file, line); } @@ -399,6 +405,9 @@ { MPASS(curthread != NULL); + KASSERT(m->mtx_object->lo_class == &lock_class_mtx_sleep, + "mtx_lock_spin() of sleep mutex %s @ %s:%d", m->mtx_object->lo_name, + file, line); #if defined(SMP) || LOCK_DEBUG > 0 _get_spin_lock(m, curthread, opts, file, line); #else @@ -414,6 +423,9 @@ { MPASS(curthread != NULL); + KASSERT(m->mtx_object->lo_class == &lock_class_mtx_sleep, + "mtx_unlock_spin() of sleep mutex %s @ %s:%d", + m->mtx_object->lo_name, file, line); WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207090059.g690xhXe041732>