Skip to content

Commit

Permalink
locking/arch: Move qrwlock.h include after qspinlock.h
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Waiman Long <[email protected]>
Fixes: 26128cb ("locking/rwlocks: Add contention detection for rwlocks")
Tested-by: Guenter Roeck <[email protected]>
Reviewed-by: Ben Gardon <[email protected]>
[Add arch/sparc and kernel/locking parts per discussion with Waiman. - Paolo]
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Waiman-Long authored and bonzini committed Feb 11, 2021
1 parent 9294b8a commit d8d0da4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define _ASM_SPINLOCK_H

#include <asm/processor.h>
#include <asm/qrwlock.h>

#include <asm-generic/qspinlock_types.h>

Expand All @@ -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 */
2 changes: 1 addition & 1 deletion arch/sparc/include/asm/spinlock_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__) */

Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion include/asm-generic/qrwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion kernel/locking/qrwlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8d0da4

Please sign in to comment.