Skip to content

Commit

Permalink
locking/rwsem: Remove rwsem-spinlock.c & use rwsem-xadd.c for all archs
Browse files Browse the repository at this point in the history
Currently, we have two different implementation of rwsem:

 1) CONFIG_RWSEM_GENERIC_SPINLOCK (rwsem-spinlock.c)
 2) CONFIG_RWSEM_XCHGADD_ALGORITHM (rwsem-xadd.c)

As we are going to use a single generic implementation for rwsem-xadd.c
and no architecture-specific code will be needed, there is no point
in keeping two different implementations of rwsem. In most cases, the
performance of rwsem-spinlock.c will be worse. It also doesn't get all
the performance tuning and optimizations that had been implemented in
rwsem-xadd.c over the years.

For simplication, we are going to remove rwsem-spinlock.c and make all
architectures use a single implementation of rwsem - rwsem-xadd.c.

All references to RWSEM_GENERIC_SPINLOCK and RWSEM_XCHGADD_ALGORITHM
in the code are removed.

Suggested-by: Peter Zijlstra <[email protected]>
Signed-off-by: Waiman Long <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Linus Torvalds <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Tim Chen <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Waiman-Long authored and Ingo Molnar committed Apr 3, 2019
1 parent 46ad084 commit 390a0c6
Show file tree
Hide file tree
Showing 31 changed files with 2 additions and 520 deletions.
7 changes: 0 additions & 7 deletions arch/alpha/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ config MMU
bool
default y

config RWSEM_GENERIC_SPINLOCK
bool

config RWSEM_XCHGADD_ALGORITHM
bool
default y

config ARCH_HAS_ILOG2_U32
bool
default n
Expand Down
3 changes: 0 additions & 3 deletions arch/arc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ config SCHED_OMIT_FRAME_POINTER
config GENERIC_CSUM
def_bool y

config RWSEM_GENERIC_SPINLOCK
def_bool y

config ARCH_DISCONTIGMEM_ENABLE
def_bool n

Expand Down
4 changes: 0 additions & 4 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ config TRACE_IRQFLAGS_SUPPORT
bool
default !CPU_V7M

config RWSEM_XCHGADD_ALGORITHM
bool
default y

config ARCH_HAS_ILOG2_U32
bool

Expand Down
3 changes: 0 additions & 3 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ config LOCKDEP_SUPPORT
config TRACE_IRQFLAGS_SUPPORT
def_bool y

config RWSEM_XCHGADD_ALGORITHM
def_bool y

config GENERIC_BUG
def_bool y
depends on BUG
Expand Down
3 changes: 0 additions & 3 deletions arch/c6x/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ config MMU
config FPU
def_bool n

config RWSEM_GENERIC_SPINLOCK
def_bool y

config GENERIC_CALIBRATE_DELAY
def_bool y

Expand Down
3 changes: 0 additions & 3 deletions arch/csky/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ config GENERIC_HWEIGHT
config MMU
def_bool y

config RWSEM_GENERIC_SPINLOCK
def_bool y

config STACKTRACE_SUPPORT
def_bool y

Expand Down
3 changes: 0 additions & 3 deletions arch/h8300/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ config H8300
config CPU_BIG_ENDIAN
def_bool y

config RWSEM_GENERIC_SPINLOCK
def_bool y

config GENERIC_HWEIGHT
def_bool y

Expand Down
6 changes: 0 additions & 6 deletions arch/hexagon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ config GENERIC_CSUM
config GENERIC_IRQ_PROBE
def_bool y

config RWSEM_GENERIC_SPINLOCK
def_bool n

config RWSEM_XCHGADD_ALGORITHM
def_bool y

config GENERIC_HWEIGHT
def_bool y

Expand Down
4 changes: 0 additions & 4 deletions arch/ia64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ config STACKTRACE_SUPPORT
config GENERIC_LOCKBREAK
def_bool n

config RWSEM_XCHGADD_ALGORITHM
bool
default y

config HUGETLB_PAGE_SIZE_VARIABLE
bool
depends on HUGETLB_PAGE
Expand Down
7 changes: 0 additions & 7 deletions arch/m68k/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ config M68K
config CPU_BIG_ENDIAN
def_bool y

config RWSEM_GENERIC_SPINLOCK
bool
default y

config RWSEM_XCHGADD_ALGORITHM
bool

config ARCH_HAS_ILOG2_U32
bool

Expand Down
6 changes: 0 additions & 6 deletions arch/microblaze/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,9 @@ config CPU_LITTLE_ENDIAN

endchoice

config RWSEM_GENERIC_SPINLOCK
def_bool y

config ZONE_DMA
def_bool y

config RWSEM_XCHGADD_ALGORITHM
bool

config ARCH_HAS_ILOG2_U32
def_bool n

Expand Down
7 changes: 0 additions & 7 deletions arch/mips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1037,13 +1037,6 @@ source "arch/mips/paravirt/Kconfig"

endmenu

config RWSEM_GENERIC_SPINLOCK
bool
default y

config RWSEM_XCHGADD_ALGORITHM
bool

config GENERIC_HWEIGHT
bool
default y
Expand Down
3 changes: 0 additions & 3 deletions arch/nds32/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ config GENERIC_LOCKBREAK
def_bool y
depends on PREEMPT

config RWSEM_GENERIC_SPINLOCK
def_bool y

config TRACE_IRQFLAGS_SUPPORT
def_bool y

Expand Down
3 changes: 0 additions & 3 deletions arch/nios2/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ config NO_IOPORT_MAP
config FPU
def_bool n

config RWSEM_GENERIC_SPINLOCK
def_bool y

config TRACE_IRQFLAGS_SUPPORT
def_bool n

Expand Down
6 changes: 0 additions & 6 deletions arch/openrisc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ config CPU_BIG_ENDIAN
config MMU
def_bool y

config RWSEM_GENERIC_SPINLOCK
def_bool y

config RWSEM_XCHGADD_ALGORITHM
def_bool n

config GENERIC_HWEIGHT
def_bool y

Expand Down
6 changes: 0 additions & 6 deletions arch/parisc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ config GENERIC_LOCKBREAK
default y
depends on SMP && PREEMPT

config RWSEM_GENERIC_SPINLOCK
def_bool y

config RWSEM_XCHGADD_ALGORITHM
bool

config ARCH_HAS_ILOG2_U32
bool
default n
Expand Down
7 changes: 0 additions & 7 deletions arch/powerpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ config LOCKDEP_SUPPORT
bool
default y

config RWSEM_GENERIC_SPINLOCK
bool

config RWSEM_XCHGADD_ALGORITHM
bool
default y

config GENERIC_LOCKBREAK
bool
default y
Expand Down
3 changes: 0 additions & 3 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ config STACKTRACE_SUPPORT
config TRACE_IRQFLAGS_SUPPORT
def_bool y

config RWSEM_GENERIC_SPINLOCK
def_bool y

config GENERIC_BUG
def_bool y
depends on BUG
Expand Down
6 changes: 0 additions & 6 deletions arch/s390/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ config LOCKDEP_SUPPORT
config STACKTRACE_SUPPORT
def_bool y

config RWSEM_GENERIC_SPINLOCK
bool

config RWSEM_XCHGADD_ALGORITHM
def_bool y

config ARCH_HAS_ILOG2_U32
def_bool n

Expand Down
6 changes: 0 additions & 6 deletions arch/sh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ config ARCH_DEFCONFIG
default "arch/sh/configs/shx3_defconfig" if SUPERH32
default "arch/sh/configs/cayman_defconfig" if SUPERH64

config RWSEM_GENERIC_SPINLOCK
def_bool y

config RWSEM_XCHGADD_ALGORITHM
bool

config GENERIC_BUG
def_bool y
depends on BUG && SUPERH32
Expand Down
8 changes: 0 additions & 8 deletions arch/sparc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,6 @@ config NR_CPUS

source "kernel/Kconfig.hz"

config RWSEM_GENERIC_SPINLOCK
bool
default y if SPARC32

config RWSEM_XCHGADD_ALGORITHM
bool
default y if SPARC64

config GENERIC_HWEIGHT
bool
default y
Expand Down
6 changes: 0 additions & 6 deletions arch/unicore32/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ config STACKTRACE_SUPPORT
config LOCKDEP_SUPPORT
def_bool y

config RWSEM_GENERIC_SPINLOCK
def_bool y

config RWSEM_XCHGADD_ALGORITHM
bool

config ARCH_HAS_ILOG2_U32
bool

Expand Down
3 changes: 0 additions & 3 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ config ARCH_MAY_HAVE_PC_FDC
def_bool y
depends on ISA_DMA_API

config RWSEM_XCHGADD_ALGORITHM
def_bool y

config GENERIC_CALIBRATE_DELAY
def_bool y

Expand Down
6 changes: 0 additions & 6 deletions arch/x86/um/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ config ARCH_DEFCONFIG
default "arch/um/configs/i386_defconfig" if X86_32
default "arch/um/configs/x86_64_defconfig" if X86_64

config RWSEM_XCHGADD_ALGORITHM
def_bool 64BIT

config RWSEM_GENERIC_SPINLOCK
def_bool !RWSEM_XCHGADD_ALGORITHM

config 3_LEVEL_PGTABLES
bool "Three-level pagetables" if !64BIT
default 64BIT
Expand Down
3 changes: 0 additions & 3 deletions arch/xtensa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ config XTENSA
with reasonable minimum requirements. The Xtensa Linux project has
a home page at <http://www.linux-xtensa.org/>.

config RWSEM_XCHGADD_ALGORITHM
def_bool y

config GENERIC_HWEIGHT
def_bool y

Expand Down
47 changes: 0 additions & 47 deletions include/linux/rwsem-spinlock.h

This file was deleted.

5 changes: 0 additions & 5 deletions include/linux/rwsem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@

struct rw_semaphore;

#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
#include <linux/rwsem-spinlock.h> /* use a generic implementation */
#define __RWSEM_INIT_COUNT(name) .count = RWSEM_UNLOCKED_VALUE
#else
/* All arch specific implementations share the same struct */
struct rw_semaphore {
atomic_long_t count;
Expand Down Expand Up @@ -65,7 +61,6 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)

#define RWSEM_UNLOCKED_VALUE 0L
#define __RWSEM_INIT_COUNT(name) .count = ATOMIC_LONG_INIT(RWSEM_UNLOCKED_VALUE)
#endif

/* Common initializer macros and functions */

Expand Down
2 changes: 1 addition & 1 deletion kernel/Kconfig.locks
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ config MUTEX_SPIN_ON_OWNER

config RWSEM_SPIN_ON_OWNER
def_bool y
depends on SMP && RWSEM_XCHGADD_ALGORITHM && ARCH_SUPPORTS_ATOMIC_RMW
depends on SMP && ARCH_SUPPORTS_ATOMIC_RMW

config LOCK_SPIN_ON_OWNER
def_bool y
Expand Down
4 changes: 1 addition & 3 deletions kernel/locking/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# and is generally not a function of system call inputs.
KCOV_INSTRUMENT := n

obj-y += mutex.o semaphore.o rwsem.o percpu-rwsem.o
obj-y += mutex.o semaphore.o rwsem.o percpu-rwsem.o rwsem-xadd.o

ifdef CONFIG_FUNCTION_TRACER
CFLAGS_REMOVE_lockdep.o = $(CC_FLAGS_FTRACE)
Expand All @@ -25,8 +25,6 @@ obj-$(CONFIG_RT_MUTEXES) += rtmutex.o
obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o
obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
obj-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
obj-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem-xadd.o
obj-$(CONFIG_QUEUED_RWLOCKS) += qrwlock.o
obj-$(CONFIG_LOCK_TORTURE_TEST) += locktorture.o
obj-$(CONFIG_WW_MUTEX_SELFTEST) += test-ww_mutex.o
Loading

0 comments on commit 390a0c6

Please sign in to comment.