Re: [PATCHv3 1/1] locking/qspinlock/x86: Avoid test-and-set when PV_DEDICATED is set

From: Wanpeng Li
Date: Fri Nov 10 2017 - 01:07:38 EST


2017-11-10 0:00 GMT+08:00 Radim Krcmar <rkrcmar@xxxxxxxxxx>:
> 2017-11-09 20:43+0800, Wanpeng Li:
>> 2017-11-07 4:26 GMT+08:00 Eduardo Valentin <eduval@xxxxxxxxxx>:
>> > Currently, the existing qspinlock implementation will fallback to
>> > test-and-set if the hypervisor has not set the PV_UNHALT flag.
>> >
>> > This patch gives the opportunity to guest kernels to select
>> > between test-and-set and the regular queueu fair lock implementation
>> > based on the PV_DEDICATED KVM feature flag. When the PV_DEDICATED
>> > flag is not set, the code will still fall back to test-and-set,
>> > but when the PV_DEDICATED flag is set, the code will use
>> > the regular queue spinlock implementation.
>> >
>> > With this patch, when in autoselect mode, the guest will
>> > use the default spinlock implementation based on host feature
>> > flags as follows:
>> >
>> > PV_DEDICATED = 1, PV_UNHALT = anything: default is qspinlock
>> > PV_DEDICATED = 0, PV_UNHALT = 1: default is pvqspinlock
>> > PV_DEDICATED = 0, PV_UNHALT = 0: default is tas
>> >
>> > Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
>> > Cc: "Radim KrÄmÃÅ" <rkrcmar@xxxxxxxxxx>
>> > Cc: Jonathan Corbet <corbet@xxxxxxx>
>> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>> > Cc: Ingo Molnar <mingo@xxxxxxxxxx>
>> > Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
>> > Cc: x86@xxxxxxxxxx
>> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
>> > Cc: Waiman Long <longman@xxxxxxxxxx>
>> > Cc: kvm@xxxxxxxxxxxxxxx
>> > Cc: linux-doc@xxxxxxxxxxxxxxx
>> > Cc: linux-kernel@xxxxxxxxxxxxxxx
>> > Cc: Jan H. Schoenherr <jschoenh@xxxxxxxxx>
>> > Cc: Anthony Liguori <aliguori@xxxxxxxxxx>
>> > Suggested-by: Matt Wilson <msw@xxxxxxxxxx>
>> > Signed-off-by: Eduardo Valentin <eduval@xxxxxxxxxx>
>> > ---
>>
>> You should also add a cpuid flag in kvm part.
>
> It is better without that. The flag has no dependency on KVM (kernel
> hypervisor) code.

Do you mean -cpu host, +xxxxïI think it will result in "warning: host
doesn't support requested feature: CPUID.40000001H:eax.XXXXXX"

Regards,
Wanpeng Li