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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'lockref' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 lockref enablement from Heiko Carstens:
"Enabling the new lockless lockref variant on s390 would have been
trivial until Tony Luck added a cpu_relax() call into the
CMPXCHG_LOOP(), with commit d472d9d98b46 ("lockref: Relax in cmpxchg
loop")

As already mentioned cpu_relax() is very expensive on s390 since it
yields() the current virtual cpu. So we are talking of several
thousand cycles. Considering this enabling the lockless lockref
variant would contradict the intention of the new semantics. And also
some quick measurements show performance regressions of 50% and more.

Simply removing the cpu_relax() call again seems also not very
desireable since Waiman Long reported that for some workloads the call
improved performance by 5%."

* 'lockref' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390: enable ARCH_USE_CMPXCHG_LOCKREF
lockref: use arch_mutex_cpu_relax() in CMPXCHG_LOOP()
mutex: replace CONFIG_HAVE_ARCH_MUTEX_CPU_RELAX with simple ifdef

+20 -10
-3
arch/Kconfig
··· 286 286 config HAVE_ARCH_JUMP_LABEL 287 287 bool 288 288 289 - config HAVE_ARCH_MUTEX_CPU_RELAX 290 - bool 291 - 292 289 config HAVE_RCU_TABLE_FREE 293 290 bool 294 291
+1 -1
arch/s390/Kconfig
··· 93 93 select ARCH_INLINE_WRITE_UNLOCK_IRQ 94 94 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE 95 95 select ARCH_SAVE_PAGE_KEYS if HIBERNATION 96 + select ARCH_USE_CMPXCHG_LOCKREF 96 97 select ARCH_WANT_IPC_PARSE_VERSION 97 98 select BUILDTIME_EXTABLE_SORT 98 99 select CLONE_BACKWARDS2 ··· 103 102 select GENERIC_TIME_VSYSCALL_OLD 104 103 select HAVE_ALIGNED_STRUCT_PAGE if SLUB 105 104 select HAVE_ARCH_JUMP_LABEL if !MARCH_G5 106 - select HAVE_ARCH_MUTEX_CPU_RELAX 107 105 select HAVE_ARCH_SECCOMP_FILTER 108 106 select HAVE_ARCH_TRACEHOOK 109 107 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT
-2
arch/s390/include/asm/mutex.h
··· 7 7 */ 8 8 9 9 #include <asm-generic/mutex-dec.h> 10 - 11 - #define arch_mutex_cpu_relax() barrier()
+2
arch/s390/include/asm/processor.h
··· 198 198 barrier(); 199 199 } 200 200 201 + #define arch_mutex_cpu_relax() barrier() 202 + 201 203 static inline void psw_set_key(unsigned int key) 202 204 { 203 205 asm volatile("spka 0(%0)" : : "d" (key));
+5
arch/s390/include/asm/spinlock.h
··· 44 44 extern int arch_spin_trylock_retry(arch_spinlock_t *); 45 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 52 static inline void arch_spin_lock(arch_spinlock_t *lp) 48 53 { 49 54 int old;
+3 -3
include/linux/mutex.h
··· 15 15 #include <linux/spinlock_types.h> 16 16 #include <linux/linkage.h> 17 17 #include <linux/lockdep.h> 18 - 19 18 #include <linux/atomic.h> 19 + #include <asm/processor.h> 20 20 21 21 /* 22 22 * Simple, straightforward mutexes with strict semantics: ··· 175 175 176 176 extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock); 177 177 178 - #ifndef CONFIG_HAVE_ARCH_MUTEX_CPU_RELAX 179 - #define arch_mutex_cpu_relax() cpu_relax() 178 + #ifndef arch_mutex_cpu_relax 179 + # define arch_mutex_cpu_relax() cpu_relax() 180 180 #endif 181 181 182 182 #endif
+9 -1
lib/lockref.c
··· 12 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 23 * Note that the "cmpxchg()" reloads the "old" value for the 16 24 * failure case. 17 25 */ ··· 36 28 if (likely(old.lock_count == prev.lock_count)) { \ 37 29 SUCCESS; \ 38 30 } \ 39 - cpu_relax(); \ 31 + arch_mutex_cpu_relax(); \ 40 32 } \ 41 33 } while (0) 42 34