aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaiman Long <Waiman.Long@hp.com>2015-04-24 14:56:31 -0400
committerIngo Molnar <mingo@kernel.org>2015-05-08 06:36:26 -0400
commitd73a33973f16ab6703e75ea00edee857afa3406e (patch)
tree3aee6cd4a8b65ed6fa170a320e23ce39be013cb5
parenta33fda35e3a7655fb7df756ed67822afb5ed5e8d (diff)
locking/qspinlock, x86: Enable x86-64 to use queued spinlocks
This patch makes the necessary changes at the x86 architecture specific layer to enable the use of queued spinlocks for x86-64. As x86-32 machines are typically not multi-socket. The benefit of queue spinlock may not be apparent. So queued spinlocks are not enabled. Currently, there is some incompatibilities between the para-virtualized spinlock code (which hard-codes the use of ticket spinlock) and the queued spinlocks. Therefore, the use of queued spinlocks is disabled when the para-virtualized spinlock is enabled. The arch/x86/include/asm/qspinlock.h header file includes some x86 specific optimization which will make the queueds spinlock code perform better than the generic implementation. Signed-off-by: Waiman Long <Waiman.Long@hp.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Daniel J Blueman <daniel@numascale.com> Cc: David Vrabel <david.vrabel@citrix.com> Cc: Douglas Hatch <doug.hatch@hp.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Paolo Bonzini <paolo.bonzini@gmail.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> Cc: Rik van Riel <riel@redhat.com> Cc: Scott J Norton <scott.norton@hp.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: virtualization@lists.linux-foundation.org Cc: xen-devel@lists.xenproject.org Link: http://lkml.kernel.org/r/1429901803-29771-3-git-send-email-Waiman.Long@hp.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/include/asm/qspinlock.h20
-rw-r--r--arch/x86/include/asm/spinlock.h5
-rw-r--r--arch/x86/include/asm/spinlock_types.h4
4 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 226d5696e1d1..90b1b54f4f38 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -127,6 +127,7 @@ config X86
127 select MODULES_USE_ELF_RELA if X86_64 127 select MODULES_USE_ELF_RELA if X86_64
128 select CLONE_BACKWARDS if X86_32 128 select CLONE_BACKWARDS if X86_32
129 select ARCH_USE_BUILTIN_BSWAP 129 select ARCH_USE_BUILTIN_BSWAP
130 select ARCH_USE_QUEUED_SPINLOCK
130 select ARCH_USE_QUEUE_RWLOCK 131 select ARCH_USE_QUEUE_RWLOCK
131 select OLD_SIGSUSPEND3 if X86_32 || IA32_EMULATION 132 select OLD_SIGSUSPEND3 if X86_32 || IA32_EMULATION
132 select OLD_SIGACTION if X86_32 133 select OLD_SIGACTION if X86_32
diff --git a/arch/x86/include/asm/qspinlock.h b/arch/x86/include/asm/qspinlock.h
new file mode 100644
index 000000000000..e2aee8273664
--- /dev/null
+++ b/arch/x86/include/asm/qspinlock.h
@@ -0,0 +1,20 @@
1#ifndef _ASM_X86_QSPINLOCK_H
2#define _ASM_X86_QSPINLOCK_H
3
4#include <asm-generic/qspinlock_types.h>
5
6#define queued_spin_unlock queued_spin_unlock
7/**
8 * queued_spin_unlock - release a queued spinlock
9 * @lock : Pointer to queued spinlock structure
10 *
11 * A smp_store_release() on the least-significant byte.
12 */
13static inline void queued_spin_unlock(struct qspinlock *lock)
14{
15 smp_store_release((u8 *)lock, 0);
16}
17
18#include <asm-generic/qspinlock.h>
19
20#endif /* _ASM_X86_QSPINLOCK_H */
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index 64b611782ef0..4ec5413156ca 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -42,6 +42,10 @@
42extern struct static_key paravirt_ticketlocks_enabled; 42extern struct static_key paravirt_ticketlocks_enabled;
43static __always_inline bool static_key_false(struct static_key *key); 43static __always_inline bool static_key_false(struct static_key *key);
44 44
45#ifdef CONFIG_QUEUED_SPINLOCK
46#include <asm/qspinlock.h>
47#else
48
45#ifdef CONFIG_PARAVIRT_SPINLOCKS 49#ifdef CONFIG_PARAVIRT_SPINLOCKS
46 50
47static inline void __ticket_enter_slowpath(arch_spinlock_t *lock) 51static inline void __ticket_enter_slowpath(arch_spinlock_t *lock)
@@ -196,6 +200,7 @@ static inline void arch_spin_unlock_wait(arch_spinlock_t *lock)
196 cpu_relax(); 200 cpu_relax();
197 } 201 }
198} 202}
203#endif /* CONFIG_QUEUED_SPINLOCK */
199 204
200/* 205/*
201 * Read-write spinlocks, allowing multiple readers 206 * Read-write spinlocks, allowing multiple readers
diff --git a/arch/x86/include/asm/spinlock_types.h b/arch/x86/include/asm/spinlock_types.h
index 5f9d7572d82b..5df1f1b9a4b0 100644
--- a/arch/x86/include/asm/spinlock_types.h
+++ b/arch/x86/include/asm/spinlock_types.h
@@ -23,6 +23,9 @@ typedef u32 __ticketpair_t;
23 23
24#define TICKET_SHIFT (sizeof(__ticket_t) * 8) 24#define TICKET_SHIFT (sizeof(__ticket_t) * 8)
25 25
26#ifdef CONFIG_QUEUED_SPINLOCK
27#include <asm-generic/qspinlock_types.h>
28#else
26typedef struct arch_spinlock { 29typedef struct arch_spinlock {
27 union { 30 union {
28 __ticketpair_t head_tail; 31 __ticketpair_t head_tail;
@@ -33,6 +36,7 @@ typedef struct arch_spinlock {
33} arch_spinlock_t; 36} arch_spinlock_t;
34 37
35#define __ARCH_SPIN_LOCK_UNLOCKED { { 0 } } 38#define __ARCH_SPIN_LOCK_UNLOCKED { { 0 } }
39#endif /* CONFIG_QUEUED_SPINLOCK */
36 40
37#include <asm-generic/qrwlock_types.h> 41#include <asm-generic/qrwlock_types.h>
38 42