Skip to content

Commit

Permalink
Merge branch 'lockref' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/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 d472d9d ("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
  • Loading branch information
Linus Torvalds committed Sep 28, 2013
2 parents 3a126f8 + efc1d23 commit aeebc26
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
3 changes: 0 additions & 3 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ config HAVE_PERF_USER_STACK_DUMP
config HAVE_ARCH_JUMP_LABEL
bool

config HAVE_ARCH_MUTEX_CPU_RELAX
bool

config HAVE_RCU_TABLE_FREE
bool

Expand Down
2 changes: 1 addition & 1 deletion arch/s390/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ config S390
select ARCH_INLINE_WRITE_UNLOCK_IRQ
select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
select ARCH_SAVE_PAGE_KEYS if HIBERNATION
select ARCH_USE_CMPXCHG_LOCKREF
select ARCH_WANT_IPC_PARSE_VERSION
select BUILDTIME_EXTABLE_SORT
select CLONE_BACKWARDS2
Expand All @@ -102,7 +103,6 @@ config S390
select GENERIC_TIME_VSYSCALL_OLD
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
select HAVE_ARCH_JUMP_LABEL if !MARCH_G5
select HAVE_ARCH_MUTEX_CPU_RELAX
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ARCH_TRACEHOOK
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT
Expand Down
2 changes: 0 additions & 2 deletions arch/s390/include/asm/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
*/

#include <asm-generic/mutex-dec.h>

#define arch_mutex_cpu_relax() barrier()
2 changes: 2 additions & 0 deletions arch/s390/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ static inline void cpu_relax(void)
barrier();
}

#define arch_mutex_cpu_relax() barrier()

static inline void psw_set_key(unsigned int key)
{
asm volatile("spka 0(%0)" : : "d" (key));
Expand Down
5 changes: 5 additions & 0 deletions arch/s390/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ extern void arch_spin_lock_wait_flags(arch_spinlock_t *, unsigned long flags);
extern int arch_spin_trylock_retry(arch_spinlock_t *);
extern void arch_spin_relax(arch_spinlock_t *lock);

static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
{
return lock.owner_cpu == 0;
}

static inline void arch_spin_lock(arch_spinlock_t *lp)
{
int old;
Expand Down
6 changes: 3 additions & 3 deletions include/linux/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include <linux/spinlock_types.h>
#include <linux/linkage.h>
#include <linux/lockdep.h>

#include <linux/atomic.h>
#include <asm/processor.h>

/*
* Simple, straightforward mutexes with strict semantics:
Expand Down Expand Up @@ -175,8 +175,8 @@ extern void mutex_unlock(struct mutex *lock);

extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);

#ifndef CONFIG_HAVE_ARCH_MUTEX_CPU_RELAX
#define arch_mutex_cpu_relax() cpu_relax()
#ifndef arch_mutex_cpu_relax
# define arch_mutex_cpu_relax() cpu_relax()
#endif

#endif
10 changes: 9 additions & 1 deletion lib/lockref.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
# define cmpxchg64_relaxed cmpxchg64
#endif

/*
* Allow architectures to override the default cpu_relax() within CMPXCHG_LOOP.
* This is useful for architectures with an expensive cpu_relax().
*/
#ifndef arch_mutex_cpu_relax
# define arch_mutex_cpu_relax() cpu_relax()
#endif

/*
* Note that the "cmpxchg()" reloads the "old" value for the
* failure case.
Expand All @@ -28,7 +36,7 @@
if (likely(old.lock_count == prev.lock_count)) { \
SUCCESS; \
} \
cpu_relax(); \
arch_mutex_cpu_relax(); \
} \
} while (0)

Expand Down

0 comments on commit aeebc26

Please sign in to comment.