diff options
| -rw-r--r-- | arch/Kconfig | 3 | ||||
| -rw-r--r-- | arch/s390/Kconfig | 2 | ||||
| -rw-r--r-- | arch/s390/include/asm/mutex.h | 2 | ||||
| -rw-r--r-- | arch/s390/include/asm/processor.h | 2 | ||||
| -rw-r--r-- | arch/s390/include/asm/spinlock.h | 5 | ||||
| -rw-r--r-- | include/linux/mutex.h | 6 | ||||
| -rw-r--r-- | lib/lockref.c | 10 |
7 files changed, 20 insertions, 10 deletions
diff --git a/arch/Kconfig b/arch/Kconfig index 1feb169274fe..af2cc6eabcc7 100644 --- a/arch/Kconfig +++ b/arch/Kconfig | |||
| @@ -286,9 +286,6 @@ config HAVE_PERF_USER_STACK_DUMP | |||
| 286 | config HAVE_ARCH_JUMP_LABEL | 286 | config HAVE_ARCH_JUMP_LABEL |
| 287 | bool | 287 | bool |
| 288 | 288 | ||
| 289 | config HAVE_ARCH_MUTEX_CPU_RELAX | ||
| 290 | bool | ||
| 291 | |||
| 292 | config HAVE_RCU_TABLE_FREE | 289 | config HAVE_RCU_TABLE_FREE |
| 293 | bool | 290 | bool |
| 294 | 291 | ||
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index dcc6ac2d8026..7143793859fa 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig | |||
| @@ -93,6 +93,7 @@ config S390 | |||
| 93 | select ARCH_INLINE_WRITE_UNLOCK_IRQ | 93 | select ARCH_INLINE_WRITE_UNLOCK_IRQ |
| 94 | select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE | 94 | select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE |
| 95 | select ARCH_SAVE_PAGE_KEYS if HIBERNATION | 95 | select ARCH_SAVE_PAGE_KEYS if HIBERNATION |
| 96 | select ARCH_USE_CMPXCHG_LOCKREF | ||
| 96 | select ARCH_WANT_IPC_PARSE_VERSION | 97 | select ARCH_WANT_IPC_PARSE_VERSION |
| 97 | select BUILDTIME_EXTABLE_SORT | 98 | select BUILDTIME_EXTABLE_SORT |
| 98 | select CLONE_BACKWARDS2 | 99 | select CLONE_BACKWARDS2 |
| @@ -102,7 +103,6 @@ config S390 | |||
| 102 | select GENERIC_TIME_VSYSCALL_OLD | 103 | select GENERIC_TIME_VSYSCALL_OLD |
| 103 | select HAVE_ALIGNED_STRUCT_PAGE if SLUB | 104 | select HAVE_ALIGNED_STRUCT_PAGE if SLUB |
| 104 | select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 | 105 | select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 |
| 105 | select HAVE_ARCH_MUTEX_CPU_RELAX | ||
| 106 | select HAVE_ARCH_SECCOMP_FILTER | 106 | select HAVE_ARCH_SECCOMP_FILTER |
| 107 | select HAVE_ARCH_TRACEHOOK | 107 | select HAVE_ARCH_TRACEHOOK |
| 108 | select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT | 108 | select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT |
diff --git a/arch/s390/include/asm/mutex.h b/arch/s390/include/asm/mutex.h index 688271f5f2e4..458c1f7fbc18 100644 --- a/arch/s390/include/asm/mutex.h +++ b/arch/s390/include/asm/mutex.h | |||
| @@ -7,5 +7,3 @@ | |||
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <asm-generic/mutex-dec.h> | 9 | #include <asm-generic/mutex-dec.h> |
| 10 | |||
| 11 | #define arch_mutex_cpu_relax() barrier() | ||
diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h index 0eb37505cab1..ca7821f07260 100644 --- a/arch/s390/include/asm/processor.h +++ b/arch/s390/include/asm/processor.h | |||
| @@ -198,6 +198,8 @@ static inline void cpu_relax(void) | |||
| 198 | barrier(); | 198 | barrier(); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | #define arch_mutex_cpu_relax() barrier() | ||
| 202 | |||
| 201 | static inline void psw_set_key(unsigned int key) | 203 | static inline void psw_set_key(unsigned int key) |
| 202 | { | 204 | { |
| 203 | asm volatile("spka 0(%0)" : : "d" (key)); | 205 | asm volatile("spka 0(%0)" : : "d" (key)); |
diff --git a/arch/s390/include/asm/spinlock.h b/arch/s390/include/asm/spinlock.h index 701fe8c59e1f..83e5d216105e 100644 --- a/arch/s390/include/asm/spinlock.h +++ b/arch/s390/include/asm/spinlock.h | |||
| @@ -44,6 +44,11 @@ extern void arch_spin_lock_wait_flags(arch_spinlock_t *, unsigned long flags); | |||
| 44 | extern int arch_spin_trylock_retry(arch_spinlock_t *); | 44 | extern int arch_spin_trylock_retry(arch_spinlock_t *); |
| 45 | extern void arch_spin_relax(arch_spinlock_t *lock); | 45 | extern void arch_spin_relax(arch_spinlock_t *lock); |
| 46 | 46 | ||
| 47 | static inline int arch_spin_value_unlocked(arch_spinlock_t lock) | ||
| 48 | { | ||
| 49 | return lock.owner_cpu == 0; | ||
| 50 | } | ||
| 51 | |||
| 47 | static inline void arch_spin_lock(arch_spinlock_t *lp) | 52 | static inline void arch_spin_lock(arch_spinlock_t *lp) |
| 48 | { | 53 | { |
| 49 | int old; | 54 | int old; |
diff --git a/include/linux/mutex.h b/include/linux/mutex.h index ccd4260834c5..bab49da8a0f0 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h | |||
| @@ -15,8 +15,8 @@ | |||
| 15 | #include <linux/spinlock_types.h> | 15 | #include <linux/spinlock_types.h> |
| 16 | #include <linux/linkage.h> | 16 | #include <linux/linkage.h> |
| 17 | #include <linux/lockdep.h> | 17 | #include <linux/lockdep.h> |
| 18 | |||
| 19 | #include <linux/atomic.h> | 18 | #include <linux/atomic.h> |
| 19 | #include <asm/processor.h> | ||
| 20 | 20 | ||
| 21 | /* | 21 | /* |
| 22 | * Simple, straightforward mutexes with strict semantics: | 22 | * Simple, straightforward mutexes with strict semantics: |
| @@ -175,8 +175,8 @@ extern void mutex_unlock(struct mutex *lock); | |||
| 175 | 175 | ||
| 176 | extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock); | 176 | extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock); |
| 177 | 177 | ||
| 178 | #ifndef CONFIG_HAVE_ARCH_MUTEX_CPU_RELAX | 178 | #ifndef arch_mutex_cpu_relax |
| 179 | #define arch_mutex_cpu_relax() cpu_relax() | 179 | # define arch_mutex_cpu_relax() cpu_relax() |
| 180 | #endif | 180 | #endif |
| 181 | 181 | ||
| 182 | #endif | 182 | #endif |
diff --git a/lib/lockref.c b/lib/lockref.c index e294ae445c9a..6f9d434c1521 100644 --- a/lib/lockref.c +++ b/lib/lockref.c | |||
| @@ -12,6 +12,14 @@ | |||
| 12 | #endif | 12 | #endif |
| 13 | 13 | ||
| 14 | /* | 14 | /* |
| 15 | * Allow architectures to override the default cpu_relax() within CMPXCHG_LOOP. | ||
| 16 | * This is useful for architectures with an expensive cpu_relax(). | ||
| 17 | */ | ||
| 18 | #ifndef arch_mutex_cpu_relax | ||
| 19 | # define arch_mutex_cpu_relax() cpu_relax() | ||
| 20 | #endif | ||
| 21 | |||
| 22 | /* | ||
| 15 | * Note that the "cmpxchg()" reloads the "old" value for the | 23 | * Note that the "cmpxchg()" reloads the "old" value for the |
| 16 | * failure case. | 24 | * failure case. |
| 17 | */ | 25 | */ |
| @@ -28,7 +36,7 @@ | |||
| 28 | if (likely(old.lock_count == prev.lock_count)) { \ | 36 | if (likely(old.lock_count == prev.lock_count)) { \ |
| 29 | SUCCESS; \ | 37 | SUCCESS; \ |
| 30 | } \ | 38 | } \ |
| 31 | cpu_relax(); \ | 39 | arch_mutex_cpu_relax(); \ |
| 32 | } \ | 40 | } \ |
| 33 | } while (0) | 41 | } while (0) |
| 34 | 42 | ||
