[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANRm+CxFk2WPG7sYWME9vfry+14O=BVLyOtrgA8+3MvLM3zoaw@mail.gmail.com>
Date: Mon, 13 Mar 2017 15:44:02 +0800
From: Wanpeng Li <kernellwp@...il.com>
To: "Michael S. Tsirkin" <mst@...hat.com>
Cc: "Gabriel L. Somlo" <gsomlo@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
Jonathan Corbet <corbet@....net>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
"the arch/x86 maintainers" <x86@...nel.org>,
kvm <kvm@...r.kernel.org>, linux-doc@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH] kvm: better MWAIT emulation for guests
Cc Peterz,
2017-03-10 9:12 GMT+08:00 Michael S. Tsirkin <mst@...hat.com>:
> On Thu, Mar 09, 2017 at 07:51:27PM -0500, Gabriel L. Somlo wrote:
>> On Fri, Mar 10, 2017 at 12:29:31AM +0200, Michael S. Tsirkin wrote:
>> > Some guests call mwait without checking the cpu flags. We currently
>> > emulate that as a NOP but on VMX we can do better: let guest stop the
>> > CPU until timer or IPI. CPU will be busy but that isn't any worse than
>> > a NOP emulation.
>>
>> Are you getting an IPI if another VCPU writes to the MONITOR-ed memory
>> location?
>
> In my testing yes.
Why there is still an IPI if monitor/mwait is used in guest?
>
>> If not, you'd be waking up too late and fail to meet the
>> specified behavior of the MONITOR/MWAIT instruction pair.
>>
>> > Note that mwait within guests is not the same as on real hardware
>> > because you must halt if you want to go deep into sleep. Thus it isn't
>> > a good idea to use the regular MWAIT flag in CPUID for that. Add a flag
>> > in the hypervisor leaf instead.
>>
>> Is it a good idea to advertise MWAIT capability to guests?
>
> I think it isn't so this patch does not do it.
>
>> The
>> misbehaving ones will call it willy-nilly, true, but aren't compliant
>> ones better off falling back to some alternative method (typically
>> using a HLT-based idle loop instead of a MONITOR/MWAIT based one) ?
>>
>> Thanks,
>> --Gabriel
>>
[...]
>> > @@ -594,6 +594,9 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
>> > if (sched_info_on())
>> > entry->eax |= (1 << KVM_FEATURE_STEAL_TIME);
>> >
>> > + if (this_cpu_has(X86_FEATURE_MWAIT))
>> > + entry->eax = (1 << KVM_FEATURE_MWAIT);
s/"="/"|=", otherwise you almost kill other features.
Regards,
Wanpeng Li
Powered by blists - more mailing lists