From owner-p4-projects Mon Jul 8 17:59:52 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E8DAD37B401; Mon, 8 Jul 2002 17:59:44 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6C5F937B400 for ; Mon, 8 Jul 2002 17:59:44 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1085343E31 for ; Mon, 8 Jul 2002 17:59:44 -0700 (PDT) (envelope-from jhb@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g690xhJU041735 for ; Mon, 8 Jul 2002 17:59:43 -0700 (PDT) (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g690xhXe041732 for perforce@freebsd.org; Mon, 8 Jul 2002 17:59:43 -0700 (PDT) Date: Mon, 8 Jul 2002 17:59:43 -0700 (PDT) Message-Id: <200207090059.g690xhXe041732@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin Subject: PERFORCE change 13939 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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