From owner-p4-projects@FreeBSD.ORG Mon Jul 24 19:15:48 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 87FBC16A4DF; Mon, 24 Jul 2006 19:15:48 +0000 (UTC) X-Original-To: perforce@freebsd.org 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 1E91716A4E1 for ; Mon, 24 Jul 2006 19:15:48 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1B67643D5A for ; Mon, 24 Jul 2006 19:15:47 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6OJFkvC026906 for ; Mon, 24 Jul 2006 19:15:46 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6OJFkJk026903 for perforce@freebsd.org; Mon, 24 Jul 2006 19:15:46 GMT (envelope-from jhb@freebsd.org) Date: Mon, 24 Jul 2006 19:15:46 GMT Message-Id: <200607241915.k6OJFkJk026903@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 102308 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jul 2006 19:15:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=102308 Change 102308 by jhb@jhb_mutex on 2006/07/24 19:14:57 Update td_locks for mtx, rw, and sx locks so we always have a running count of how many non-spin locks we hold. Affected files ... .. //depot/projects/smpng/sys/kern/kern_mutex.c#130 edit .. //depot/projects/smpng/sys/kern/kern_rwlock.c#7 edit .. //depot/projects/smpng/sys/kern/kern_sx.c#34 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_mutex.c#130 (text+ko) ==== @@ -285,6 +285,7 @@ LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); + curthread->td_locks++; #ifdef MUTEX_PROFILING /* don't reset the timer when/if recursing */ if (m->mtx_acqtime == 0) { @@ -304,6 +305,7 @@ KASSERT(LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_sleep, ("mtx_unlock() of spin mutex %s @ %s:%d", m->mtx_object.lo_name, file, line)); + curthread->td_locks--; WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); @@ -429,9 +431,11 @@ rval = _obtain_lock(m, (uintptr_t)curthread); LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line); - if (rval) + if (rval) { WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE | LOP_TRYLOCK, file, line); + curthread->td_locks++; + } return (rval); } ==== //depot/projects/smpng/sys/kern/kern_rwlock.c#7 (text+ko) ==== @@ -119,6 +119,7 @@ __rw_wlock(rw, curthread, file, line); LOCK_LOG_LOCK("WLOCK", &rw->rw_object, 0, 0, file, line); WITNESS_LOCK(&rw->rw_object, LOP_EXCLUSIVE, file, line); + curthread->td_locks++; } void @@ -127,6 +128,7 @@ MPASS(curthread != NULL); _rw_assert(rw, RA_WLOCKED, file, line); + curthread->td_locks--; WITNESS_UNLOCK(&rw->rw_object, LOP_EXCLUSIVE, file, line); LOCK_LOG_LOCK("WUNLOCK", &rw->rw_object, 0, 0, file, line); __rw_wunlock(rw, curthread, file, line); @@ -266,6 +268,7 @@ LOCK_LOG_LOCK("RLOCK", &rw->rw_object, 0, 0, file, line); WITNESS_LOCK(&rw->rw_object, 0, file, line); + curthread->td_locks++; } void @@ -275,6 +278,7 @@ uintptr_t x; _rw_assert(rw, RA_RLOCKED, file, line); + curthread->td_locks--; WITNESS_UNLOCK(&rw->rw_object, 0, file, line); LOCK_LOG_LOCK("RUNLOCK", &rw->rw_object, 0, 0, file, line); ==== //depot/projects/smpng/sys/kern/kern_sx.c#34 (text+ko) ==== @@ -128,6 +128,7 @@ LOCK_LOG_LOCK("SLOCK", &sx->sx_object, 0, 0, file, line); WITNESS_LOCK(&sx->sx_object, 0, file, line); + curthread->td_locks++; mtx_unlock(sx->sx_lock); } @@ -141,6 +142,7 @@ sx->sx_cnt++; LOCK_LOG_TRY("SLOCK", &sx->sx_object, 0, 1, file, line); WITNESS_LOCK(&sx->sx_object, LOP_TRYLOCK, file, line); + curthread->td_locks++; mtx_unlock(sx->sx_lock); return (1); } else { @@ -184,6 +186,7 @@ LOCK_LOG_LOCK("XLOCK", &sx->sx_object, 0, 0, file, line); WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line); + curthread->td_locks++; mtx_unlock(sx->sx_lock); } @@ -199,6 +202,7 @@ LOCK_LOG_TRY("XLOCK", &sx->sx_object, 0, 1, file, line); WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE | LOP_TRYLOCK, file, line); + curthread->td_locks++; mtx_unlock(sx->sx_lock); return (1); } else { @@ -215,6 +219,7 @@ _sx_assert(sx, SX_SLOCKED, file, line); mtx_lock(sx->sx_lock); + curthread->td_locks--; WITNESS_UNLOCK(&sx->sx_object, 0, file, line); /* Release. */ @@ -245,6 +250,7 @@ mtx_lock(sx->sx_lock); MPASS(sx->sx_cnt == -1); + curthread->td_locks--; WITNESS_UNLOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line); /* Release. */