Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

locking/arch: Move qrwlock.h include after qspinlock.h

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>

authored by

Waiman Long and committed by
Paolo Bonzini
d8d0da4e 9294b8a1

+6 -6
+1 -1
arch/arm64/include/asm/spinlock.h
··· 5 5 #ifndef __ASM_SPINLOCK_H 6 6 #define __ASM_SPINLOCK_H 7 7 8 - #include <asm/qrwlock.h> 9 8 #include <asm/qspinlock.h> 9 + #include <asm/qrwlock.h> 10 10 11 11 /* See include/linux/spinlock.h */ 12 12 #define smp_mb__after_spinlock() smp_mb()
+1 -1
arch/mips/include/asm/spinlock.h
··· 10 10 #define _ASM_SPINLOCK_H 11 11 12 12 #include <asm/processor.h> 13 - #include <asm/qrwlock.h> 14 13 15 14 #include <asm-generic/qspinlock_types.h> 16 15 ··· 26 27 } 27 28 28 29 #include <asm/qspinlock.h> 30 + #include <asm/qrwlock.h> 29 31 30 32 #endif /* _ASM_SPINLOCK_H */
+1 -1
arch/sparc/include/asm/spinlock_64.h
··· 11 11 12 12 #include <asm/processor.h> 13 13 #include <asm/barrier.h> 14 - #include <asm/qrwlock.h> 15 14 #include <asm/qspinlock.h> 15 + #include <asm/qrwlock.h> 16 16 17 17 #endif /* !(__ASSEMBLY__) */ 18 18
+1 -1
arch/xtensa/include/asm/spinlock.h
··· 12 12 #define _XTENSA_SPINLOCK_H 13 13 14 14 #include <asm/barrier.h> 15 - #include <asm/qrwlock.h> 16 15 #include <asm/qspinlock.h> 16 + #include <asm/qrwlock.h> 17 17 18 18 #define smp_mb__after_spinlock() smp_mb() 19 19
+2 -1
include/asm-generic/qrwlock.h
··· 14 14 #include <asm/processor.h> 15 15 16 16 #include <asm-generic/qrwlock_types.h> 17 - #include <asm-generic/qspinlock.h> 17 + 18 + /* Must be included from asm/spinlock.h after defining arch_spin_is_locked. */ 18 19 19 20 /* 20 21 * Writer states & reader shift and bias.
-1
kernel/locking/qrwlock.c
··· 12 12 #include <linux/percpu.h> 13 13 #include <linux/hardirq.h> 14 14 #include <linux/spinlock.h> 15 - #include <asm/qrwlock.h> 16 15 17 16 /** 18 17 * queued_read_lock_slowpath - acquire read lock of a queue rwlock