diff options
author | attilio <attilio@FreeBSD.org> | 2011-11-21 12:59:52 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2011-11-21 12:59:52 +0000 |
commit | b95134ea01e46b282074a03ea01be1fc9d95a328 (patch) | |
tree | 40b25c5a1fa8695b73e18ea776cf41e1418873fd /sys/sys | |
parent | 3aadfef0044607b2474ae1bba0c2fca2b37e18e3 (diff) | |
download | FreeBSD-src-b95134ea01e46b282074a03ea01be1fc9d95a328.zip FreeBSD-src-b95134ea01e46b282074a03ea01be1fc9d95a328.tar.gz |
Introduce the same mutex-wise fix in r227758 for sx locks.
The functions that offer file and line specifications are:
- sx_assert_
- sx_downgrade_
- sx_slock_
- sx_slock_sig_
- sx_sunlock_
- sx_try_slock_
- sx_try_xlock_
- sx_try_upgrade_
- sx_unlock_
- sx_xlock_
- sx_xlock_sig_
- sx_xunlock_
Now vm_map locking is fully converted and can avoid to know specifics
about locking procedures.
Reviewed by: kib
MFC after: 1 month
Diffstat (limited to 'sys/sys')
-rw-r--r-- | sys/sys/sx.h | 86 |
1 files changed, 51 insertions, 35 deletions
diff --git a/sys/sys/sx.h b/sys/sys/sx.h index 3bef1c5..8c76a50 100644 --- a/sys/sys/sx.h +++ b/sys/sys/sx.h @@ -94,14 +94,14 @@ void sx_sysinit(void *arg); #define sx_init(sx, desc) sx_init_flags((sx), (desc), 0) void sx_init_flags(struct sx *sx, const char *description, int opts); void sx_destroy(struct sx *sx); +int sx_try_slock_(struct sx *sx, const char *file, int line); +int sx_try_xlock_(struct sx *sx, const char *file, int line); +int sx_try_upgrade_(struct sx *sx, const char *file, int line); +void sx_downgrade_(struct sx *sx, const char *file, int line); int _sx_slock(struct sx *sx, int opts, const char *file, int line); int _sx_xlock(struct sx *sx, int opts, const char *file, int line); -int _sx_try_slock(struct sx *sx, const char *file, int line); -int _sx_try_xlock(struct sx *sx, const char *file, int line); void _sx_sunlock(struct sx *sx, const char *file, int line); void _sx_xunlock(struct sx *sx, const char *file, int line); -int _sx_try_upgrade(struct sx *sx, const char *file, int line); -void _sx_downgrade(struct sx *sx, const char *file, int line); int _sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts, const char *file, int line); int _sx_slock_hard(struct sx *sx, int opts, const char *file, int line); @@ -208,30 +208,50 @@ __sx_sunlock(struct sx *sx, const char *file, int line) #error "LOCK_DEBUG not defined, include <sys/lock.h> before <sys/sx.h>" #endif #if (LOCK_DEBUG > 0) || defined(SX_NOINLINE) -#define sx_xlock(sx) (void)_sx_xlock((sx), 0, LOCK_FILE, LOCK_LINE) -#define sx_xlock_sig(sx) \ - _sx_xlock((sx), SX_INTERRUPTIBLE, LOCK_FILE, LOCK_LINE) -#define sx_xunlock(sx) _sx_xunlock((sx), LOCK_FILE, LOCK_LINE) -#define sx_slock(sx) (void)_sx_slock((sx), 0, LOCK_FILE, LOCK_LINE) -#define sx_slock_sig(sx) \ - _sx_slock((sx), SX_INTERRUPTIBLE, LOCK_FILE, LOCK_LINE) -#define sx_sunlock(sx) _sx_sunlock((sx), LOCK_FILE, LOCK_LINE) +#define sx_xlock_(sx, file, line) \ + (void)_sx_xlock((sx), 0, (file), (line)) +#define sx_xlock_sig_(sx, file, line) \ + _sx_xlock((sx), SX_INTERRUPTIBLE, (file), (line)) +#define sx_xunlock_(sx, file, line) \ + _sx_xunlock((sx), (file), (line)) +#define sx_slock_(sx, file, line) \ + (void)_sx_slock((sx), 0, (file), (line)) +#define sx_slock_sig_(sx, file, line) \ + _sx_slock((sx), SX_INTERRUPTIBLE, (file) , (line)) +#define sx_sunlock_(sx, file, line) \ + _sx_sunlock((sx), (file), (line)) #else -#define sx_xlock(sx) \ - (void)__sx_xlock((sx), curthread, 0, LOCK_FILE, LOCK_LINE) -#define sx_xlock_sig(sx) \ - __sx_xlock((sx), curthread, SX_INTERRUPTIBLE, LOCK_FILE, LOCK_LINE) -#define sx_xunlock(sx) \ - __sx_xunlock((sx), curthread, LOCK_FILE, LOCK_LINE) -#define sx_slock(sx) (void)__sx_slock((sx), 0, LOCK_FILE, LOCK_LINE) -#define sx_slock_sig(sx) \ - __sx_slock((sx), SX_INTERRUPTIBLE, LOCK_FILE, LOCK_LINE) -#define sx_sunlock(sx) __sx_sunlock((sx), LOCK_FILE, LOCK_LINE) +#define sx_xlock_(sx, file, line) \ + (void)__sx_xlock((sx), curthread, 0, (file), (line)) +#define sx_xlock_sig_(sx, file, line) \ + __sx_xlock((sx), curthread, SX_INTERRUPTIBLE, (file), (line)) +#define sx_xunlock_(sx, file, line) \ + __sx_xunlock((sx), curthread, (file), (line)) +#define sx_slock_(sx, file, line) \ + (void)__sx_slock((sx), 0, (file), (line)) +#define sx_slock_sig_(sx, file, line) \ + __sx_slock((sx), SX_INTERRUPTIBLE, (file), (line)) +#define sx_sunlock_(sx, file, line) \ + __sx_sunlock((sx), (file), (line)) #endif /* LOCK_DEBUG > 0 || SX_NOINLINE */ -#define sx_try_slock(sx) _sx_try_slock((sx), LOCK_FILE, LOCK_LINE) -#define sx_try_xlock(sx) _sx_try_xlock((sx), LOCK_FILE, LOCK_LINE) -#define sx_try_upgrade(sx) _sx_try_upgrade((sx), LOCK_FILE, LOCK_LINE) -#define sx_downgrade(sx) _sx_downgrade((sx), LOCK_FILE, LOCK_LINE) +#define sx_try_slock(sx) sx_try_slock_((sx), LOCK_FILE, LOCK_LINE) +#define sx_try_xlock(sx) sx_try_xlock_((sx), LOCK_FILE, LOCK_LINE) +#define sx_try_upgrade(sx) sx_try_upgrade_((sx), LOCK_FILE, LOCK_LINE) +#define sx_downgrade(sx) sx_downgrade_((sx), LOCK_FILE, LOCK_LINE) +#ifdef INVARIANTS +#define sx_assert_(sx, what, file, line) \ + _sx_assert((sx), (what), (file), (line)) +#else +#define sx_assert_(sx, what, file, line) (void)0 +#endif + +#define sx_xlock(sx) sx_xlock_((sx), LOCK_FILE, LOCK_LINE) +#define sx_xlock_sig(sx) sx_xlock_sig_((sx), LOCK_FILE, LOCK_LINE) +#define sx_xunlock(sx) sx_xunlock_((sx), LOCK_FILE, LOCK_LINE) +#define sx_slock(sx) sx_slock_((sx), LOCK_FILE, LOCK_LINE) +#define sx_slock_sig(sx) sx_slock_sig_((sx), LOCK_FILE, LOCK_LINE) +#define sx_sunlock(sx) sx_sunlock_((sx), LOCK_FILE, LOCK_LINE) +#define sx_assert(sx, what) sx_assert_((sx), (what), __FILE__, __LINE__) /* * Return a pointer to the owning thread if the lock is exclusively @@ -245,13 +265,15 @@ __sx_sunlock(struct sx *sx, const char *file, int line) (((sx)->sx_lock & ~(SX_LOCK_FLAGMASK & ~SX_LOCK_SHARED)) == \ (uintptr_t)curthread) -#define sx_unlock(sx) do { \ +#define sx_unlock_(sx, file, line) do { \ if (sx_xlocked(sx)) \ - sx_xunlock(sx); \ + sx_xunlock_(sx, file, line); \ else \ - sx_sunlock(sx); \ + sx_sunlock_(sx, file, line); \ } while (0) +#define sx_unlock(sx) sx_unlock_((sx), LOCK_FILE, LOCK_LINE) + #define sx_sleep(chan, sx, pri, wmesg, timo) \ _sleep((chan), &(sx)->lock_object, (pri), (wmesg), (timo)) @@ -287,12 +309,6 @@ __sx_sunlock(struct sx *sx, const char *file, int line) #define SX_NOTRECURSED LA_NOTRECURSED #endif -#ifdef INVARIANTS -#define sx_assert(sx, what) _sx_assert((sx), (what), LOCK_FILE, LOCK_LINE) -#else -#define sx_assert(sx, what) (void)0 -#endif - #endif /* _KERNEL */ #endif /* !_SYS_SX_H_ */ |