Re: [PATCH -v2 5/7] locking/percpu-rwsem: Remove the embedded rwsem
From: Peter Zijlstra
Date: Mon Feb 03 2020 - 10:09:44 EST
On Mon, Feb 03, 2020 at 06:20:50AM -0800, Christoph Hellwig wrote:
> On Fri, Jan 31, 2020 at 04:07:08PM +0100, Peter Zijlstra wrote:
> > @@ -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)
>
> Can you split the removal of the non-owned resem support into a separate
> patch? I still think keeping this one and moving aio to that scheme is
> a better idea than the current ad-hoc locking scheme that has all kinds
> of issues.
That's basically 2 lines of code and a comment, surely we can ressurect
that if/when it's needed again?
---
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 44e68761f432..5449ab33f89e 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -660,8 +659,6 @@ static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem,
unsigned long flags;
bool ret = true;
- BUILD_BUG_ON(!(RWSEM_OWNER_UNKNOWN & RWSEM_NONSPINNABLE));
-
if (need_resched()) {
lockevent_inc(rwsem_opt_fail);
return false;