rwlock: perform the typically false td_rw_rlocks check later

Check if the lock is available first instead.

MFC after:	1 week
This commit is contained in:
Mateusz Guzik 2017-07-02 01:05:16 +00:00
parent 201f03b8e7
commit 3f7830a31e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=320561

View File

@ -372,9 +372,8 @@ _rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line)
* prioritizes writers before readers.
*/
#define RW_CAN_READ(td, _rw) \
(((td)->td_rw_rlocks && (_rw) & RW_LOCK_READ) || ((_rw) & \
(RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | RW_LOCK_WRITE_SPINNER)) == \
RW_LOCK_READ)
(((_rw) & (RW_LOCK_READ | RW_LOCK_WRITE_WAITERS | RW_LOCK_WRITE_SPINNER)) ==\
RW_LOCK_READ || ((td)->td_rw_rlocks && (_rw) & RW_LOCK_READ))
static bool __always_inline
__rw_rlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp,