diff options
author | Mark Johnston <markj@FreeBSD.org> | 2015-08-02 00:03:08 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2015-08-02 00:03:08 +0000 |
commit | ce1c953ee0309526f0bcbbe4bb41df5aed86200b (patch) | |
tree | d10a3198e0dacd07d8cdeb2d9dd386d29dca28ff | |
parent | c3321180ec37fa49d1cc59139691a20b28ad5bf8 (diff) |
Notes
-rw-r--r-- | sys/kern/kern_lock.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_mutex.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_rmlock.c | 13 | ||||
-rw-r--r-- | sys/kern/kern_rwlock.c | 13 | ||||
-rw-r--r-- | sys/kern/kern_sx.c | 12 | ||||
-rw-r--r-- | sys/sys/proc.h | 8 |
6 files changed, 29 insertions, 31 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 36a8470d2971..aa671804afd6 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -69,12 +69,8 @@ CTASSERT(LK_UNLOCKED == (LK_UNLOCKED & #ifndef INVARIANTS #define _lockmgr_assert(lk, what, file, line) -#define TD_LOCKS_INC(td) -#define TD_LOCKS_DEC(td) -#else -#define TD_LOCKS_INC(td) ((td)->td_locks++) -#define TD_LOCKS_DEC(td) ((td)->td_locks--) #endif + #define TD_SLOCKS_INC(td) ((td)->td_lk_slocks++) #define TD_SLOCKS_DEC(td) ((td)->td_lk_slocks--) diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 97e198584ddb..bec8f6b0669b 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -224,7 +224,7 @@ __mtx_lock_flags(volatile uintptr_t *c, int opts, const char *file, int line) line); WITNESS_LOCK(&m->lock_object, (opts & ~MTX_RECURSE) | LOP_EXCLUSIVE, file, line); - curthread->td_locks++; + TD_LOCKS_INC(curthread); } void @@ -248,7 +248,7 @@ __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, int line) mtx_assert(m, MA_OWNED); __mtx_unlock(m, curthread, opts, file, line); - curthread->td_locks--; + TD_LOCKS_DEC(curthread); } void @@ -347,7 +347,7 @@ _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, int line) if (rval) { WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE | LOP_TRYLOCK, file, line); - curthread->td_locks++; + TD_LOCKS_INC(curthread); if (m->mtx_recurse == 0) LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(adaptive__acquire, m, contested, waittime, file, line); @@ -958,7 +958,7 @@ _mtx_destroy(volatile uintptr_t *c) if (LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin) spinlock_exit(); else - curthread->td_locks--; + TD_LOCKS_DEC(curthread); lock_profile_release_lock(&m->lock_object); /* Tell witness this isn't locked to make it happy. */ diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index 945608da2834..2667e6e3482c 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -608,11 +608,8 @@ _rm_wlock_debug(struct rmlock *rm, const char *file, int line) _rm_wlock(rm); LOCK_LOG_LOCK("RMWLOCK", &rm->lock_object, 0, 0, file, line); - WITNESS_LOCK(&rm->lock_object, LOP_EXCLUSIVE, file, line); - - curthread->td_locks++; - + TD_LOCKS_INC(curthread); } void @@ -628,7 +625,7 @@ _rm_wunlock_debug(struct rmlock *rm, const char *file, int line) WITNESS_UNLOCK(&rm->lock_object, LOP_EXCLUSIVE, file, line); LOCK_LOG_LOCK("RMWUNLOCK", &rm->lock_object, 0, 0, file, line); _rm_wunlock(rm); - curthread->td_locks--; + TD_LOCKS_DEC(curthread); } int @@ -670,9 +667,7 @@ _rm_rlock_debug(struct rmlock *rm, struct rm_priotracker *tracker, LOCK_LOG_LOCK("RMRLOCK", &rm->lock_object, 0, 0, file, line); WITNESS_LOCK(&rm->lock_object, 0, file, line); - - curthread->td_locks++; - + TD_LOCKS_INC(curthread); return (1); } else if (trylock) LOCK_LOG_TRY("RMRLOCK", &rm->lock_object, 0, 0, file, line); @@ -694,7 +689,7 @@ _rm_runlock_debug(struct rmlock *rm, struct rm_priotracker *tracker, WITNESS_UNLOCK(&rm->lock_object, 0, file, line); LOCK_LOG_LOCK("RMRUNLOCK", &rm->lock_object, 0, 0, file, line); _rm_runlock(rm, tracker); - curthread->td_locks--; + TD_LOCKS_DEC(curthread); } #else diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 370d0d6fca4b..6541724f5aef 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -268,7 +268,7 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line) __rw_wlock(rw, curthread, file, line); LOCK_LOG_LOCK("WLOCK", &rw->lock_object, 0, rw->rw_recurse, file, line); WITNESS_LOCK(&rw->lock_object, LOP_EXCLUSIVE, file, line); - curthread->td_locks++; + TD_LOCKS_INC(curthread); } int @@ -303,7 +303,7 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file, int line) if (!rw_recursed(rw)) LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(rw__acquire, rw, 0, 0, file, line, LOCKSTAT_WRITER); - curthread->td_locks++; + TD_LOCKS_INC(curthread); } return (rval); } @@ -325,8 +325,9 @@ _rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line) LOCK_LOG_LOCK("WUNLOCK", &rw->lock_object, 0, rw->rw_recurse, file, line); __rw_wunlock(rw, curthread, file, line); - curthread->td_locks--; + TD_LOCKS_DEC(curthread); } + /* * Determines whether a new reader can acquire a lock. Succeeds if the * reader already owns a read lock and the lock is locked for read to @@ -565,7 +566,7 @@ __rw_rlock(volatile uintptr_t *c, const char *file, int line) waittime, file, line, LOCKSTAT_READER); LOCK_LOG_LOCK("RLOCK", &rw->lock_object, 0, 0, file, line); WITNESS_LOCK(&rw->lock_object, 0, file, line); - curthread->td_locks++; + TD_LOCKS_INC(curthread); curthread->td_rw_rlocks++; } @@ -596,7 +597,7 @@ __rw_try_rlock(volatile uintptr_t *c, const char *file, int line) WITNESS_LOCK(&rw->lock_object, LOP_TRYLOCK, file, line); LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(rw__acquire, rw, 0, 0, file, line, LOCKSTAT_READER); - curthread->td_locks++; + TD_LOCKS_INC(curthread); curthread->td_rw_rlocks++; return (1); } @@ -714,7 +715,7 @@ _rw_runlock_cookie(volatile uintptr_t *c, const char *file, int line) break; } LOCKSTAT_PROFILE_RELEASE_RWLOCK(rw__release, rw, LOCKSTAT_READER); - curthread->td_locks--; + TD_LOCKS_DEC(curthread); curthread->td_rw_rlocks--; } diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c index 1ba1ab2aff53..96e117b429b5 100644 --- a/sys/kern/kern_sx.c +++ b/sys/kern/kern_sx.c @@ -261,7 +261,7 @@ _sx_slock(struct sx *sx, int opts, const char *file, int line) if (!error) { LOCK_LOG_LOCK("SLOCK", &sx->lock_object, 0, 0, file, line); WITNESS_LOCK(&sx->lock_object, 0, file, line); - curthread->td_locks++; + TD_LOCKS_INC(curthread); } return (error); @@ -290,7 +290,7 @@ sx_try_slock_(struct sx *sx, const char *file, int line) WITNESS_LOCK(&sx->lock_object, LOP_TRYLOCK, file, line); LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(sx__acquire, sx, 0, 0, file, line, LOCKSTAT_READER); - curthread->td_locks++; + TD_LOCKS_INC(curthread); return (1); } } @@ -318,7 +318,7 @@ _sx_xlock(struct sx *sx, int opts, const char *file, int line) LOCK_LOG_LOCK("XLOCK", &sx->lock_object, 0, sx->sx_recurse, file, line); WITNESS_LOCK(&sx->lock_object, LOP_EXCLUSIVE, file, line); - curthread->td_locks++; + TD_LOCKS_INC(curthread); } return (error); @@ -353,7 +353,7 @@ sx_try_xlock_(struct sx *sx, const char *file, int line) if (!sx_recursed(sx)) LOCKSTAT_PROFILE_OBTAIN_RWLOCK_SUCCESS(sx__acquire, sx, 0, 0, file, line, LOCKSTAT_WRITER); - curthread->td_locks++; + TD_LOCKS_INC(curthread); } return (rval); @@ -371,7 +371,7 @@ _sx_sunlock(struct sx *sx, const char *file, int line) WITNESS_UNLOCK(&sx->lock_object, 0, file, line); LOCK_LOG_LOCK("SUNLOCK", &sx->lock_object, 0, 0, file, line); __sx_sunlock(sx, file, line); - curthread->td_locks--; + TD_LOCKS_DEC(curthread); } void @@ -387,7 +387,7 @@ _sx_xunlock(struct sx *sx, const char *file, int line) LOCK_LOG_LOCK("XUNLOCK", &sx->lock_object, 0, sx->sx_recurse, file, line); __sx_xunlock(sx, curthread, file, line); - curthread->td_locks--; + TD_LOCKS_DEC(curthread); } /* diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 9689b17df0ea..62c4b05c0061 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -238,7 +238,7 @@ struct thread { int td_oncpu; /* (t) Which cpu we are on. */ volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */ u_char td_tsqueue; /* (t) Turnstile queue blocked on. */ - short td_locks; /* (k) Count of non-spin locks. */ + short td_locks; /* (k) Debug: count of non-spin locks */ short td_rw_rlocks; /* (k) Count of rwlock read locks. */ short td_lk_slocks; /* (k) Count of lockmgr shared locks. */ short td_stopsched; /* (k) Scheduler stopped. */ @@ -351,8 +351,14 @@ do { \ KASSERT((__m == &blocked_lock || __m == (lock)), \ ("Thread %p lock %p does not match %p", td, __m, (lock))); \ } while (0) + +#define TD_LOCKS_INC(td) ((td)->td_locks++) +#define TD_LOCKS_DEC(td) ((td)->td_locks--) #else #define THREAD_LOCKPTR_ASSERT(td, lock) + +#define TD_LOCKS_INC(td) +#define TD_LOCKS_DEC(td) #endif /* |