Skip to content

Commit f84a15b

Browse files
fatherMatrixfbq
authored andcommitted
locking/rwsem: Use OWNER_NONSPINNABLE directly instead of OWNER_SPINNABLE
After commit 7d43f1c ("locking/rwsem: Enable time-based spinning on reader-owned rwsem"), OWNER_SPINNABLE contains all possible values except OWNER_NONSPINNABLE, namely OWNER_NULL | OWNER_WRITER | OWNER_READER. Therefore, it is better to use OWNER_NONSPINNABLE directly to determine whether to exit optimistic spin. And, remove useless OWNER_SPINNABLE to simplify the code. Signed-off-by: Jinliang Zheng <[email protected]> Acked-by: Waiman Long <[email protected]> Signed-off-by: Boqun Feng <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 99214ef commit f84a15b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

kernel/locking/rwsem.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,6 @@ static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem)
727727
return ret;
728728
}
729729

730-
#define OWNER_SPINNABLE (OWNER_NULL | OWNER_WRITER | OWNER_READER)
731-
732730
static inline enum owner_state
733731
rwsem_owner_state(struct task_struct *owner, unsigned long flags)
734732
{
@@ -835,7 +833,7 @@ static bool rwsem_optimistic_spin(struct rw_semaphore *sem)
835833
enum owner_state owner_state;
836834

837835
owner_state = rwsem_spin_on_owner(sem);
838-
if (!(owner_state & OWNER_SPINNABLE))
836+
if (owner_state == OWNER_NONSPINNABLE)
839837
break;
840838

841839
/*

0 commit comments

Comments
 (0)