locking/arch: Move qrwlock.h include after qspinlock.h
authorWaiman Long <longman@redhat.com>
Wed, 10 Feb 2021 18:16:31 +0000 (13:16 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 11 Feb 2021 12:59:54 +0000 (07:59 -0500)
include/asm-generic/qrwlock.h was trying to get arch_spin_is_locked via
asm-generic/qspinlock.h.  However, this does not work because architectures
might be using queued rwlocks but not queued spinlocks (csky), or because they
might be defining their own queued_* macros before including asm/qspinlock.h.

To fix this, ensure that asm/spinlock.h always includes qrwlock.h after
defining arch_spin_is_locked (either directly for csky, or via
asm/qspinlock.h for other architectures).  The only inclusion elsewhere
is in kernel/locking/qrwlock.c.  That one is really unnecessary because
the file is only compiled in SMP configurations (config QUEUED_RWLOCKS
depends on SMP) and in that case linux/spinlock.h already includes
asm/qrwlock.h if needed, via asm/spinlock.h.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Waiman Long <longman@redhat.com>
Fixes: 26128cb6c7e6 ("locking/rwlocks: Add contention detection for rwlocks")
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Ben Gardon <bgardon@google.com>
[Add arch/sparc and kernel/locking parts per discussion with Waiman. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/arm64/include/asm/spinlock.h
arch/mips/include/asm/spinlock.h
arch/sparc/include/asm/spinlock_64.h
arch/xtensa/include/asm/spinlock.h
include/asm-generic/qrwlock.h
kernel/locking/qrwlock.c

index 9083d6992603e6e26aa3ad120bf3fd6f9cc4720a..0525c0b089edf7b1551bc1e4a47f167c969727e9 100644 (file)
@@ -5,8 +5,8 @@
 #ifndef __ASM_SPINLOCK_H
 #define __ASM_SPINLOCK_H
 
-#include <asm/qrwlock.h>
 #include <asm/qspinlock.h>
+#include <asm/qrwlock.h>
 
 /* See include/linux/spinlock.h */
 #define smp_mb__after_spinlock()       smp_mb()
index 8a88eb2655160da1a5055af4249825046026ab4b..6ce2117e49f6f91b8e47f6b678f585796c80c9a9 100644 (file)
@@ -10,7 +10,6 @@
 #define _ASM_SPINLOCK_H
 
 #include <asm/processor.h>
-#include <asm/qrwlock.h>
 
 #include <asm-generic/qspinlock_types.h>
 
@@ -27,5 +26,6 @@ static inline void queued_spin_unlock(struct qspinlock *lock)
 }
 
 #include <asm/qspinlock.h>
+#include <asm/qrwlock.h>
 
 #endif /* _ASM_SPINLOCK_H */
index 7fc82a233f4957c97bf8f0913a43bacd04a7eefc..3a9a0b0c74654dc4e03361046c6a4f653b87c7ab 100644 (file)
@@ -11,8 +11,8 @@
 
 #include <asm/processor.h>
 #include <asm/barrier.h>
-#include <asm/qrwlock.h>
 #include <asm/qspinlock.h>
+#include <asm/qrwlock.h>
 
 #endif /* !(__ASSEMBLY__) */
 
index 584b0de6f2ca21fe1552eba57e0e73f226250208..41c449ece2d89a78313a95b73767b0f0a94d46cb 100644 (file)
@@ -12,8 +12,8 @@
 #define _XTENSA_SPINLOCK_H
 
 #include <asm/barrier.h>
-#include <asm/qrwlock.h>
 #include <asm/qspinlock.h>
+#include <asm/qrwlock.h>
 
 #define smp_mb__after_spinlock()       smp_mb()
 
index 0020d3b820a7b60fe7c0515804126f50892ecc03..7ae0ece07b4e4968158980a5ce71922e0cdd120c 100644 (file)
@@ -14,7 +14,8 @@
 #include <asm/processor.h>
 
 #include <asm-generic/qrwlock_types.h>
-#include <asm-generic/qspinlock.h>
+
+/* Must be included from asm/spinlock.h after defining arch_spin_is_locked.  */
 
 /*
  * Writer states & reader shift and bias.
index fe9ca92faa2a7a7b0915a6ae420f31b2e4fc4dd8..4786dd271b45afa4031c47d58f4c5b9a1679c7a2 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/percpu.h>
 #include <linux/hardirq.h>
 #include <linux/spinlock.h>
-#include <asm/qrwlock.h>
 
 /**
  * queued_read_lock_slowpath - acquire read lock of a queue rwlock