All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xen/spinlock: Don't use pvqspinlock if only 1 vCPU
@ 2018-07-19 21:39 Waiman Long
  2018-07-19 21:54 ` Davidlohr Bueso
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Waiman Long @ 2018-07-19 21:39 UTC (permalink / raw)
  To: Boris Ostrovsky, Juergen Gross, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin
  Cc: x86, xen-devel, linux-kernel, Konrad Rzeszutek Wilk, Waiman Long

On a VM with only 1 vCPU, the locking fast paths will always be
successful. In this case, there is no need to use the the PV qspinlock
code which has higher overhead on the unlock side than the native
qspinlock code.

The xen_pvspin veriable is also turned off in this 1 vCPU case to
eliminate unneeded pvqspinlock initialization in xen_init_lock_cpu()
which is run after xen_init_spinlocks().

Signed-off-by: Waiman Long <longman@redhat.com>
---
 arch/x86/xen/spinlock.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index cd97a62..973f10e 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -130,6 +130,10 @@ void xen_uninit_lock_cpu(int cpu)
 void __init xen_init_spinlocks(void)
 {
 
+	/*  Don't need to use pvqspinlock code if there is only 1 vCPU. */
+	if (num_possible_cpus() == 1)
+		xen_pvspin = false;
+
 	if (!xen_pvspin) {
 		printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
 		return;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread
* [PATCH v2] xen/spinlock: Don't use pvqspinlock if only 1 vCPU
@ 2018-07-19 21:39 Waiman Long
  0 siblings, 0 replies; 20+ messages in thread
From: Waiman Long @ 2018-07-19 21:39 UTC (permalink / raw)
  To: Boris Ostrovsky, Juergen Gross, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin
  Cc: Waiman Long, xen-devel, x86, linux-kernel

On a VM with only 1 vCPU, the locking fast paths will always be
successful. In this case, there is no need to use the the PV qspinlock
code which has higher overhead on the unlock side than the native
qspinlock code.

The xen_pvspin veriable is also turned off in this 1 vCPU case to
eliminate unneeded pvqspinlock initialization in xen_init_lock_cpu()
which is run after xen_init_spinlocks().

Signed-off-by: Waiman Long <longman@redhat.com>
---
 arch/x86/xen/spinlock.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index cd97a62..973f10e 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -130,6 +130,10 @@ void xen_uninit_lock_cpu(int cpu)
 void __init xen_init_spinlocks(void)
 {
 
+	/*  Don't need to use pvqspinlock code if there is only 1 vCPU. */
+	if (num_possible_cpus() == 1)
+		xen_pvspin = false;
+
 	if (!xen_pvspin) {
 		printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
 		return;
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2018-07-31 17:05 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-19 21:39 [PATCH v2] xen/spinlock: Don't use pvqspinlock if only 1 vCPU Waiman Long
2018-07-19 21:54 ` Davidlohr Bueso
2018-07-19 22:02   ` Waiman Long
2018-07-23  3:31     ` Wanpeng Li
2018-07-23  4:42       ` Davidlohr Bueso
2018-07-23  4:42       ` Davidlohr Bueso
2018-07-23  4:50         ` Davidlohr Bueso
2018-07-23  4:50         ` Davidlohr Bueso
2018-07-23 13:52         ` Waiman Long
2018-07-23 13:52         ` Waiman Long
2018-07-23 13:33       ` Waiman Long
2018-07-23 13:33       ` Waiman Long
2018-07-23  3:31     ` Wanpeng Li
2018-07-19 22:02   ` Waiman Long
2018-07-19 21:54 ` Davidlohr Bueso
2018-07-19 22:35 ` Boris Ostrovsky
2018-07-19 22:35 ` Boris Ostrovsky
2018-07-31 17:05 ` Boris Ostrovsky
2018-07-31 17:05 ` Boris Ostrovsky
  -- strict thread matches above, loose matches on Subject: below --
2018-07-19 21:39 Waiman Long

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.