Skip to content

Commit

Permalink
locking/arch: Remove dummy arch_{read,spin,write}_lock_flags() implem…
Browse files Browse the repository at this point in the history
…entations

The arch_{read,spin,write}_lock_flags() macros are simply mapped to the
non-flags versions by the majority of architectures, so do this in core
code and remove the dummy implementations. Also remove the implementation
in spinlock_up.h, since all callers of do_raw_spin_lock_flags() call
local_irq_save(flags) anyway.

Signed-off-by: Will Deacon <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
wildea01 authored and Ingo Molnar committed Oct 10, 2017
1 parent 0160fb1 commit a4c1887
Show file tree
Hide file tree
Showing 27 changed files with 20 additions and 102 deletions.
4 changes: 0 additions & 4 deletions arch/alpha/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* We make no fairness assumptions. They have a cost.
*/

#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
#define arch_spin_is_locked(x) ((x)->lock != 0)

static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
Expand Down Expand Up @@ -160,7 +159,4 @@ static inline void arch_write_unlock(arch_rwlock_t * lock)
lock->lock = 0;
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* _ALPHA_SPINLOCK_H */
4 changes: 0 additions & 4 deletions arch/arc/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <asm/barrier.h>

#define arch_spin_is_locked(x) ((x)->slock != __ARCH_SPIN_LOCK_UNLOCKED__)
#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

#ifdef CONFIG_ARC_HAS_LLSC

Expand Down Expand Up @@ -410,7 +409,4 @@ static inline void arch_write_unlock(arch_rwlock_t *rw)

#endif

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* __ASM_SPINLOCK_H */
5 changes: 0 additions & 5 deletions arch/arm/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ static inline void dsb_sev(void)
* memory.
*/

#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

static inline void arch_spin_lock(arch_spinlock_t *lock)
{
unsigned long tmp;
Expand Down Expand Up @@ -270,7 +268,4 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
}
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* __ASM_SPINLOCK_H */
5 changes: 0 additions & 5 deletions arch/arm64/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* instructions.
*/

#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

static inline void arch_spin_lock(arch_spinlock_t *lock)
{
unsigned int tmp;
Expand Down Expand Up @@ -303,9 +301,6 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
/* read_can_lock - would read_trylock() succeed? */
#define arch_read_can_lock(x) ((x)->lock < 0x80000000)

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

/* See include/linux/spinlock.h */
#define smp_mb__after_spinlock() smp_mb()

Expand Down
6 changes: 0 additions & 6 deletions arch/blackfin/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ static inline void arch_spin_lock(arch_spinlock_t *lock)
__raw_spin_lock_asm(&lock->lock);
}

#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

static inline int arch_spin_trylock(arch_spinlock_t *lock)
{
return __raw_spin_trylock_asm(&lock->lock);
Expand All @@ -53,8 +51,6 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
__raw_read_lock_asm(&rw->lock);
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)

static inline int arch_read_trylock(arch_rwlock_t *rw)
{
return __raw_read_trylock_asm(&rw->lock);
Expand All @@ -70,8 +66,6 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
__raw_write_lock_asm(&rw->lock);
}

#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

static inline int arch_write_trylock(arch_rwlock_t *rw)
{
return __raw_write_trylock_asm(&rw->lock);
Expand Down
5 changes: 0 additions & 5 deletions arch/hexagon/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ static inline unsigned int arch_spin_trylock(arch_spinlock_t *lock)
/*
* SMP spinlocks are intended to allow only a single CPU at the lock
*/
#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

#define arch_spin_is_locked(x) ((x)->lock != 0)

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif
5 changes: 3 additions & 2 deletions arch/ia64/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static __always_inline void arch_spin_lock_flags(arch_spinlock_t *lock,
{
arch_spin_lock(lock);
}
#define arch_spin_lock_flags arch_spin_lock_flags

#ifdef ASM_SUPPORTED

Expand Down Expand Up @@ -153,6 +154,7 @@ arch_read_lock_flags(arch_rwlock_t *lock, unsigned long flags)
: "p6", "p7", "r2", "memory");
}

#define arch_read_lock_flags arch_read_lock_flags
#define arch_read_lock(lock) arch_read_lock_flags(lock, 0)

#else /* !ASM_SUPPORTED */
Expand Down Expand Up @@ -205,6 +207,7 @@ arch_write_lock_flags(arch_rwlock_t *lock, unsigned long flags)
: "ar.ccv", "p6", "p7", "r2", "r29", "memory");
}

#define arch_write_lock_flags arch_write_lock_flags
#define arch_write_lock(rw) arch_write_lock_flags(rw, 0)

#define arch_write_trylock(rw) \
Expand All @@ -228,8 +231,6 @@ static inline void arch_write_unlock(arch_rwlock_t *x)

#else /* !ASM_SUPPORTED */

#define arch_write_lock_flags(l, flags) arch_write_lock(l)

#define arch_write_lock(l) \
({ \
__u64 ia64_val, ia64_set_val = ia64_dep_mi(-1, 0, 31, 1); \
Expand Down
4 changes: 0 additions & 4 deletions arch/m32r/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/

#define arch_spin_is_locked(x) (*(volatile int *)(&(x)->slock) <= 0)
#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

/**
* arch_spin_trylock - Try spin lock and return a result
Expand Down Expand Up @@ -305,7 +304,4 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
return 0;
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* _ASM_M32R_SPINLOCK_H */
5 changes: 0 additions & 5 deletions arch/metag/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,4 @@
* locked.
*/

#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* __ASM_SPINLOCK_H */
3 changes: 0 additions & 3 deletions arch/metag/include/asm/spinlock_lnkget.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,4 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
return tmp;
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* __ASM_SPINLOCK_LNKGET_H */
3 changes: 0 additions & 3 deletions arch/mips/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@
#include <asm/qrwlock.h>
#include <asm/qspinlock.h>

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* _ASM_SPINLOCK_H */
4 changes: 1 addition & 3 deletions arch/mn10300/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock,
: "d" (flags), "a"(&lock->slock), "i"(EPSW_IE | MN10300_CLI_LEVEL)
: "memory", "cc");
}
#define arch_spin_lock_flags arch_spin_lock_flags

#ifdef __KERNEL__

Expand Down Expand Up @@ -171,9 +172,6 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
return 0;
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#define _raw_spin_relax(lock) cpu_relax()
#define _raw_read_relax(lock) cpu_relax()
#define _raw_write_relax(lock) cpu_relax()
Expand Down
4 changes: 1 addition & 3 deletions arch/parisc/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
cpu_relax();
mb();
}
#define arch_spin_lock_flags arch_spin_lock_flags

static inline void arch_spin_unlock(arch_spinlock_t *x)
{
Expand Down Expand Up @@ -168,7 +169,4 @@ static __inline__ int arch_write_trylock(arch_rwlock_t *rw)
return result;
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* __ASM_SPINLOCK_H */
4 changes: 1 addition & 3 deletions arch/powerpc/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
local_irq_restore(flags_dis);
}
}
#define arch_spin_lock_flags arch_spin_lock_flags

static inline void arch_spin_unlock(arch_spinlock_t *lock)
{
Expand Down Expand Up @@ -299,9 +300,6 @@ static inline void arch_write_unlock(arch_rwlock_t *rw)
rw->lock = 0;
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#define arch_spin_relax(lock) __spin_yield(lock)
#define arch_read_relax(lock) __rw_yield(lock)
#define arch_write_relax(lock) __rw_yield(lock)
Expand Down
4 changes: 1 addition & 3 deletions arch/s390/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lp,
if (!arch_spin_trylock_once(lp))
arch_spin_lock_wait_flags(lp, flags);
}
#define arch_spin_lock_flags arch_spin_lock_flags

static inline int arch_spin_trylock(arch_spinlock_t *lp)
{
Expand Down Expand Up @@ -114,9 +115,6 @@ static inline void arch_spin_unlock(arch_spinlock_t *lp)
extern int _raw_read_trylock_retry(arch_rwlock_t *lp);
extern int _raw_write_trylock_retry(arch_rwlock_t *lp);

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

static inline int arch_read_trylock_once(arch_rwlock_t *rw)
{
int old = ACCESS_ONCE(rw->lock);
Expand Down
4 changes: 0 additions & 4 deletions arch/sh/include/asm/spinlock-cas.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ static inline unsigned __sl_cas(volatile unsigned *p, unsigned old, unsigned new
*/

#define arch_spin_is_locked(x) ((x)->lock <= 0)
#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

static inline void arch_spin_lock(arch_spinlock_t *lock)
{
Expand Down Expand Up @@ -90,7 +89,4 @@ static inline int arch_write_trylock(arch_rwlock_t *rw)
return __sl_cas(&rw->lock, RW_LOCK_BIAS, 0) == RW_LOCK_BIAS;
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* __ASM_SH_SPINLOCK_CAS_H */
4 changes: 0 additions & 4 deletions arch/sh/include/asm/spinlock-llsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/

#define arch_spin_is_locked(x) ((x)->lock <= 0)
#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

/*
* Simple spin lock operations. There are two variants, one clears IRQ's
Expand Down Expand Up @@ -197,7 +196,4 @@ static inline int arch_write_trylock(arch_rwlock_t *rw)
return (oldval > (RW_LOCK_BIAS - 1));
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* __ASM_SH_SPINLOCK_LLSC_H */
4 changes: 0 additions & 4 deletions arch/sparc/include/asm/spinlock_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ static inline int __arch_read_trylock(arch_rwlock_t *rw)
res; \
})

#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
#define arch_read_lock_flags(rw, flags) arch_read_lock(rw)
#define arch_write_lock_flags(rw, flags) arch_write_lock(rw)

#endif /* !(__ASSEMBLY__) */

#endif /* __SPARC_SPINLOCK_H */
3 changes: 0 additions & 3 deletions arch/sparc/include/asm/spinlock_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#include <asm/qrwlock.h>
#include <asm/qspinlock.h>

#define arch_read_lock_flags(p, f) arch_read_lock(p)
#define arch_write_lock_flags(p, f) arch_write_lock(p)

#endif /* !(__ASSEMBLY__) */

#endif /* !(__SPARC64_SPINLOCK_H) */
6 changes: 0 additions & 6 deletions arch/tile/include/asm/spinlock_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ static inline int arch_spin_is_locked(arch_spinlock_t *lock)

void arch_spin_lock(arch_spinlock_t *lock);

/* We cannot take an interrupt after getting a ticket, so don't enable them. */
#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

int arch_spin_trylock(arch_spinlock_t *lock);

static inline void arch_spin_unlock(arch_spinlock_t *lock)
Expand Down Expand Up @@ -109,7 +106,4 @@ void arch_read_unlock(arch_rwlock_t *rwlock);
*/
void arch_write_unlock(arch_rwlock_t *rwlock);

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* _ASM_TILE_SPINLOCK_32_H */
6 changes: 0 additions & 6 deletions arch/tile/include/asm/spinlock_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ static inline void arch_spin_lock(arch_spinlock_t *lock)
/* Try to get the lock, and return whether we succeeded. */
int arch_spin_trylock(arch_spinlock_t *lock);

/* We cannot take an interrupt after getting a ticket, so don't enable them. */
#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

/*
* Read-write spinlocks, allowing multiple readers
* but only one writer.
Expand Down Expand Up @@ -138,7 +135,4 @@ static inline int arch_write_trylock(arch_rwlock_t *rw)
return 0;
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* _ASM_TILE_SPINLOCK_64_H */
3 changes: 0 additions & 3 deletions arch/x86/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,4 @@

#include <asm/qrwlock.h>

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* _ASM_X86_SPINLOCK_H */
5 changes: 0 additions & 5 deletions arch/xtensa/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

#define arch_spin_is_locked(x) ((x)->slock != 0)

#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)

static inline void arch_spin_lock(arch_spinlock_t *lock)
{
unsigned long tmp;
Expand Down Expand Up @@ -198,7 +196,4 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
: "memory");
}

#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)

#endif /* _XTENSA_SPINLOCK_H */
1 change: 0 additions & 1 deletion include/asm-generic/qspinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,5 @@ static __always_inline bool virt_spin_lock(struct qspinlock *lock)
#define arch_spin_lock(l) queued_spin_lock(l)
#define arch_spin_trylock(l) queued_spin_trylock(l)
#define arch_spin_unlock(l) queued_spin_unlock(l)
#define arch_spin_lock_flags(l, f) queued_spin_lock(l)

#endif /* __ASM_GENERIC_QSPINLOCK_H */
9 changes: 9 additions & 0 deletions include/linux/rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ do { \
extern int do_raw_write_trylock(rwlock_t *lock);
extern void do_raw_write_unlock(rwlock_t *lock) __releases(lock);
#else

#ifndef arch_read_lock_flags
# define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
#endif

#ifndef arch_write_lock_flags
# define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
#endif

# define do_raw_read_lock(rwlock) do {__acquire(lock); arch_read_lock(&(rwlock)->raw_lock); } while (0)
# define do_raw_read_lock_flags(lock, flags) \
do {__acquire(lock); arch_read_lock_flags(&(lock)->raw_lock, *(flags)); } while (0)
Expand Down
4 changes: 4 additions & 0 deletions include/linux/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ static inline void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock)
arch_spin_lock(&lock->raw_lock);
}

#ifndef arch_spin_lock_flags
#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
#endif

static inline void
do_raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long *flags) __acquires(lock)
{
Expand Down
Loading

0 comments on commit a4c1887

Please sign in to comment.