Re: [PATCH 5/5] locking/percpu-rwsem: Remove the embedded rwsem
From: Waiman Long
Date: Mon Nov 18 2019 - 16:52:39 EST
On 11/13/19 5:21 AM, Peter Zijlstra wrote:
> @@ -130,20 +131,12 @@ static inline void percpu_rwsem_release(
> bool read, unsigned long ip)
> {
> lock_release(&sem->dep_map, ip);
> -#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
> - if (!read)
> - atomic_long_set(&sem->rw_sem.owner, RWSEM_OWNER_UNKNOWN);
> -#endif
> }
>
This is the only place that set RWSEM_OWNER_UNKNOWN. So you may as well
remove all references to it:
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 00d6054687dd..8a418d9eeb7a 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -53,12 +53,6 @@ struct rw_semaphore {
Â#endif
Â};
Â
-/*
- * Setting all bits of the owner field except bit 0 will indicate
- * that the rwsem is writer-owned with an unknown owner.
- */
-#define RWSEM_OWNER_UNKNOWNÂÂÂ (-2L)
-
Â/* In all implementations count != 0 means locked */
Âstatic inline int rwsem_is_locked(struct rw_semaphore *sem)
Â{
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index eef04551eae7..622842754c73 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -660,8 +660,6 @@ static inline bool rwsem_can_spin_on_owner(struct
rw_semapho
ÂÂÂÂÂÂÂ unsigned long flags;
ÂÂÂÂÂÂÂ bool ret = true;
Â
-ÂÂÂÂÂÂ BUILD_BUG_ON(!(RWSEM_OWNER_UNKNOWN & RWSEM_NONSPINNABLE));
-
ÂÂÂÂÂÂÂ if (need_resched()) {
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ lockevent_inc(rwsem_opt_fail);
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return false;
Cheers,
Longman