* [PATCH] xen/spinlock: Don't use pvqspinlock if only 1 vCPU
@ 2018-07-19 13:48 Waiman Long
2018-07-19 19:18 ` Boris Ostrovsky
0 siblings, 1 reply; 3+ messages in thread
From: Waiman Long @ 2018-07-19 13:48 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.
Signed-off-by: Waiman Long <longman@redhat.com>
---
arch/x86/xen/spinlock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index cd97a62..38f47ae 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -130,7 +130,8 @@ void xen_uninit_lock_cpu(int cpu)
void __init xen_init_spinlocks(void)
{
- if (!xen_pvspin) {
+ /* Don't need to use pvqspinlock code if there is only 1 vCPU. */
+ if (!xen_pvspin || num_possible_cpus() == 1) {
printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
return;
}
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xen/spinlock: Don't use pvqspinlock if only 1 vCPU
2018-07-19 13:48 [PATCH] xen/spinlock: Don't use pvqspinlock if only 1 vCPU Waiman Long
@ 2018-07-19 19:18 ` Boris Ostrovsky
2018-07-19 19:59 ` Waiman Long
0 siblings, 1 reply; 3+ messages in thread
From: Boris Ostrovsky @ 2018-07-19 19:18 UTC (permalink / raw)
To: Waiman Long, Juergen Gross, Thomas Gleixner, Ingo Molnar, H. Peter Anvin
Cc: x86, xen-devel, linux-kernel, Konrad Rzeszutek Wilk
On 07/19/2018 09:48 AM, Waiman Long wrote:
> 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.
>
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
> arch/x86/xen/spinlock.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
> index cd97a62..38f47ae 100644
> --- a/arch/x86/xen/spinlock.c
> +++ b/arch/x86/xen/spinlock.c
> @@ -130,7 +130,8 @@ void xen_uninit_lock_cpu(int cpu)
> void __init xen_init_spinlocks(void)
> {
>
> - if (!xen_pvspin) {
> + /* Don't need to use pvqspinlock code if there is only 1 vCPU. */
> + if (!xen_pvspin || num_possible_cpus() == 1) {
> printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
> return;
> }
I think we need to set xen_pvspin to false for such configurations.
Notice that xen_init_lock_cpu() will try to perform some additional
pvspinlock initializations.
-boris
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xen/spinlock: Don't use pvqspinlock if only 1 vCPU
2018-07-19 19:18 ` Boris Ostrovsky
@ 2018-07-19 19:59 ` Waiman Long
0 siblings, 0 replies; 3+ messages in thread
From: Waiman Long @ 2018-07-19 19:59 UTC (permalink / raw)
To: Boris Ostrovsky, Juergen Gross, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin
Cc: x86, xen-devel, linux-kernel, Konrad Rzeszutek Wilk
On 07/19/2018 03:18 PM, Boris Ostrovsky wrote:
> On 07/19/2018 09:48 AM, Waiman Long wrote:
>> 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.
>>
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>> arch/x86/xen/spinlock.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
>> index cd97a62..38f47ae 100644
>> --- a/arch/x86/xen/spinlock.c
>> +++ b/arch/x86/xen/spinlock.c
>> @@ -130,7 +130,8 @@ void xen_uninit_lock_cpu(int cpu)
>> void __init xen_init_spinlocks(void)
>> {
>>
>> - if (!xen_pvspin) {
>> + /* Don't need to use pvqspinlock code if there is only 1 vCPU. */
>> + if (!xen_pvspin || num_possible_cpus() == 1) {
>> printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
>> return;
>> }
>
> I think we need to set xen_pvspin to false for such configurations.
> Notice that xen_init_lock_cpu() will try to perform some additional
> pvspinlock initializations.
>
>
> -boris
The other pvqspinlock initialization has no runtime impact other than
allocating a bit of extra memory. Anyway, I will revise the patch to
disable xen_pvspin under such condition.
-Longman
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-19 19:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19 13:48 [PATCH] xen/spinlock: Don't use pvqspinlock if only 1 vCPU Waiman Long
2018-07-19 19:18 ` Boris Ostrovsky
2018-07-19 19:59 ` Waiman Long
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®