Re: [PATCH v2 06/28] locking/rwlocks: Add contention detection for rwlocks

From: Waiman Long
Date: Wed Feb 10 2021 - 10:18:07 EST


On 2/9/21 10:32 PM, Waiman Long wrote:
On 2/2/21 1:57 PM, Ben Gardon wrote:
rwlocks do not currently have any facility to detect contention
like spinlocks do. In order to allow users of rwlocks to better manage
latency, add contention detection for queued rwlocks.

CC: Ingo Molnar <mingo@xxxxxxxxxx>
CC: Will Deacon <will@xxxxxxxxxx>
Acked-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Acked-by: Davidlohr Bueso <dbueso@xxxxxxx>
Acked-by: Waiman Long <longman@xxxxxxxxxx>
Acked-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Signed-off-by: Ben Gardon <bgardon@xxxxxxxxxx>
---
  include/asm-generic/qrwlock.h | 24 ++++++++++++++++++------
  include/linux/rwlock.h        |  7 +++++++
  2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/include/asm-generic/qrwlock.h b/include/asm-generic/qrwlock.h
index 84ce841ce735..0020d3b820a7 100644
--- a/include/asm-generic/qrwlock.h
+++ b/include/asm-generic/qrwlock.h
@@ -14,6 +14,7 @@
  #include <asm/processor.h>
    #include <asm-generic/qrwlock_types.h>
+#include <asm-generic/qspinlock.h>

As said in another thread, qspinlock and qrwlock can be independently enabled for an architecture. So we shouldn't include qspinlock.h here. Instead, just include the regular linux/spinlock.h file to make sure that arch_spin_is_locked() is available.

The csky architecture uses qrwlock but not qspinlock. So this patch can be problematic when compiling for csky.

Cheers,
Longman