diff options
author | jhb <jhb@FreeBSD.org> | 2001-05-04 17:15:16 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-05-04 17:15:16 +0000 |
commit | 21bc7f9fa7d25856003d9cf4871355c90b602c23 (patch) | |
tree | d86819558c830db5611e6cc1b273ac3a9e546272 /sys/kern/subr_turnstile.c | |
parent | d803e7dbf81e212591b59daaf7f91211e786d329 (diff) | |
download | FreeBSD-src-21bc7f9fa7d25856003d9cf4871355c90b602c23.zip FreeBSD-src-21bc7f9fa7d25856003d9cf4871355c90b602c23.tar.gz |
- Move state about lock objects out of struct lock_object and into a new
struct lock_instance that is stored in the per-process and per-CPU lock
lists. Previously, the lock lists just kept a pointer to each lock held.
That pointer is now replaced by a lock instance which contains a pointer
to the lock object, the file and line of the last acquisition of a lock,
and various flags about a lock including its recursion count.
- If we sleep while holding a sleepable lock, then mark that lock instance
as having slept and ignore any lock order violations that occur while
acquiring Giant when we wake up with slept locks. This is ok because of
Giant's special nature.
- Allow witness to differentiate between shared and exclusive locks and
unlocks of a lock. Witness will now detect the case when a lock is
acquired first in one mode and then in another. Mutexes are always
locked and unlocked exclusively. Witness will also now detect the case
where a process attempts to unlock a shared lock while holding an
exclusive lock and vice versa.
- Fix a bug in the lock list implementation where we used the wrong
constant to detect the case where a lock list entry was full.
Diffstat (limited to 'sys/kern/subr_turnstile.c')
-rw-r--r-- | sys/kern/subr_turnstile.c | 43 |
1 files changed, 4 insertions, 39 deletions
diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index 72d4815..0007a8b 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.c @@ -274,8 +274,8 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line) */ KASSERT(!mtx_recursed(m), ("mtx_trylock() called on a recursed mutex")); - mtx_update_flags(m, 1); - WITNESS_LOCK(&m->mtx_object, opts | LOP_TRYLOCK, file, line); + WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE | LOP_TRYLOCK, + file, line); } return (rval); @@ -552,40 +552,6 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) * See the _rel_spin_lock() macro for the details. */ -#ifdef WITNESS -/* - * Update the lock object flags before calling witness. Note that when we - * lock a mutex, this is called after getting the lock, but when unlocking - * a mutex, this function is called before releasing the lock. - */ -void -_mtx_update_flags(struct mtx *m, int locking) -{ - - mtx_assert(m, MA_OWNED); - if (locking) { - m->mtx_object.lo_flags |= LO_LOCKED; - if (mtx_recursed(m)) - m->mtx_object.lo_flags |= LO_RECURSED; - else - /* XXX: we shouldn't need this in theory. */ - m->mtx_object.lo_flags &= ~LO_RECURSED; - } else { - switch (m->mtx_recurse) { - case 0: - /* XXX: we shouldn't need the LO_RECURSED in theory. */ - m->mtx_object.lo_flags &= ~(LO_LOCKED | LO_RECURSED); - break; - case 1: - m->mtx_object.lo_flags &= ~(LO_RECURSED); - break; - default: - break; - } - } -} -#endif - /* * The backing function for the INVARIANTS-enabled mtx_assert() */ @@ -704,9 +670,8 @@ mtx_destroy(struct mtx *m) MPASS((m->mtx_lock & (MTX_RECURSED|MTX_CONTESTED)) == 0); /* Tell witness this isn't locked to make it happy. */ - m->mtx_object.lo_flags &= ~LO_LOCKED; - WITNESS_UNLOCK(&m->mtx_object, MTX_NOSWITCH, __FILE__, - __LINE__); + WITNESS_UNLOCK(&m->mtx_object, LOP_EXCLUSIVE | LOP_NOSWITCH, + __FILE__, __LINE__); } WITNESS_DESTROY(&m->mtx_object); |