From a24c8eb84703bdf9e197712d32af42e0e789444c Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 18 Feb 2017 01:52:10 +0000 Subject: [PATCH] mtx: plug the 'opts' argument when not used --- sys/kern/kern_mutex.c | 8 ++++++-- sys/sys/lock.h | 5 +++++ sys/sys/mutex.h | 9 ++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 8e3ea6d84ed..7ffacd95e90 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -429,7 +429,7 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, int opts, const char *file, int line) #else void -__mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, int opts) +__mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid) #endif { struct mtx *m; @@ -471,14 +471,18 @@ __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, int opts) (opts & MTX_RECURSE) != 0, ("_mtx_lock_sleep: recursed on non-recursive mutex %s @ %s:%d\n", m->lock_object.lo_name, file, line)); +#if LOCK_DEBUG > 0 opts &= ~MTX_RECURSE; +#endif m->mtx_recurse++; atomic_set_ptr(&m->mtx_lock, MTX_RECURSED); if (LOCK_LOG_TEST(&m->lock_object, opts)) CTR1(KTR_LOCK, "_mtx_lock_sleep: %p recursing", m); return; } +#if LOCK_DEBUG > 0 opts &= ~MTX_RECURSE; +#endif #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); @@ -873,7 +877,7 @@ void __mtx_unlock_sleep(volatile uintptr_t *c, int opts, const char *file, int line) #else void -__mtx_unlock_sleep(volatile uintptr_t *c, int opts) +__mtx_unlock_sleep(volatile uintptr_t *c) #endif { struct mtx *m; diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 89b61ab73dd..08ccaa5726f 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -154,8 +154,13 @@ struct lock_class { * file - file name * line - line number */ +#if LOCK_DEBUG > 0 #define LOCK_LOG_TEST(lo, flags) \ (((flags) & LOP_QUIET) == 0 && ((lo)->lo_flags & LO_QUIET) == 0) +#else +#define LOCK_LOG_TEST(lo, flags) 0 +#endif + #define LOCK_LOG_LOCK(opname, lo, flags, recurse, file, line) do { \ if (LOCK_LOG_TEST((lo), (flags))) \ diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index c0ac0c8c8a9..9d8ca4e467b 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -104,9 +104,8 @@ void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, void __mtx_unlock_sleep(volatile uintptr_t *c, int opts, const char *file, int line); #else -void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid, - int opts); -void __mtx_unlock_sleep(volatile uintptr_t *c, int opts); +void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t v, uintptr_t tid); +void __mtx_unlock_sleep(volatile uintptr_t *c); #endif #ifdef SMP @@ -154,9 +153,9 @@ void thread_lock_flags_(struct thread *, int, const char *, int); __mtx_unlock_sleep(&(m)->mtx_lock, o, f, l) #else #define _mtx_lock_sleep(m, v, t, o, f, l) \ - __mtx_lock_sleep(&(m)->mtx_lock, v, t, o) + __mtx_lock_sleep(&(m)->mtx_lock, v, t) #define _mtx_unlock_sleep(m, o, f, l) \ - __mtx_unlock_sleep(&(m)->mtx_lock, o) + __mtx_unlock_sleep(&(m)->mtx_lock) #endif #ifdef SMP #define _mtx_lock_spin(m, v, t, o, f, l) \