From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Wanpeng Li" <wanpeng.li@hotmail.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Yunhong Jiang" <yunhong.jiang@intel.com>,
"Jan Kiszka" <jan.kiszka@siemens.com>,
"Haozhong Zhang" <haozhong.zhang@intel.com>
Subject: Re: [PATCH v4 2/2] KVM: nVMX: Fix preemption timer bit set in vmcs02 even if L1 doesn't enable it
Date: Thu, 7 Jul 2016 14:29:33 +0200 [thread overview]
Message-ID: <a6c2ed1e-40aa-729f-b02e-a56d9cea55a0@redhat.com> (raw)
In-Reply-To: <1467893939-3335-2-git-send-email-wanpeng.li@hotmail.com>
On 07/07/2016 14:18, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> We will go to vcpu_run() loop after L0 emulates VMRESUME which maybe
> incur kvm_sched_out and kvm_sched_in operations since cond_resched()
> will be called once need resched. Preemption timer will be reprogrammed
> if vCPU is scheduled to a different pCPU. Then the preemption timer
> bit of vmcs02 will be set if L0 enable preemption timer to run L1 even
> if L1 doesn't enable preemption timer to run L2.
>
> This patch fix it by don't reprogram preemption timer of vmcs02 if L1's
> vCPU is scheduled on diffent pCPU when we are in the way to vmresume
> nested guest, and fallback to hrtimer based emulated method.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Cc: Yunhong Jiang <yunhong.jiang@intel.com>
> Cc: Jan Kiszka <jan.kiszka@siemens.com>
> Cc: Haozhong Zhang <haozhong.zhang@intel.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> v3 -> v4:
> * fallback to hrtimer based emulated method when in the way to vmresume nested guest
>
> arch/x86/kvm/x86.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 0cc6cf8..05137c0 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2743,8 +2743,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
> mark_tsc_unstable("KVM discovered backwards TSC");
>
> if (kvm_lapic_hv_timer_in_use(vcpu) &&
> + (is_guest_mode(vcpu) ||
> kvm_x86_ops->set_hv_timer(vcpu,
> - kvm_get_lapic_tscdeadline_msr(vcpu)))
> + kvm_get_lapic_tscdeadline_msr(vcpu))))
> kvm_lapic_switch_to_sw_timer(vcpu);
> if (check_tsc_unstable()) {
> u64 offset = kvm_compute_tsc_offset(vcpu,
>
Thanks, this is good as a fallback. I'll try to fix it by getting the
pin-based execution controls right but if I fail this patch is okay.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2016-07-07 12:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-07 12:18 [PATCH v4 1/2] KVM: nVMX: Fix incorrect preemption timer vmexit in nested guest Wanpeng Li
2016-07-07 12:18 ` [PATCH v4 2/2] KVM: nVMX: Fix preemption timer bit set in vmcs02 even if L1 doesn't enable it Wanpeng Li
2016-07-07 12:29 ` Paolo Bonzini [this message]
2016-07-07 13:23 ` Wanpeng Li
2016-07-07 14:11 ` Paolo Bonzini
2016-07-08 0:38 ` Wanpeng Li
2016-07-08 10:18 ` Paolo Bonzini
2016-07-08 13:58 ` Wanpeng Li
2016-07-08 14:08 ` Wanpeng Li
2016-07-08 15:47 ` Paolo Bonzini
2016-07-08 22:57 ` Wanpeng Li
2016-07-07 12:29 ` [PATCH v4 1/2] KVM: nVMX: Fix incorrect preemption timer vmexit in nested guest Paolo Bonzini
2016-07-07 22:12 ` yunhong jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a6c2ed1e-40aa-729f-b02e-a56d9cea55a0@redhat.com \
--to=pbonzini@redhat.com \
--cc=haozhong.zhang@intel.com \
--cc=jan.kiszka@siemens.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=wanpeng.li@hotmail.com \
--cc=yunhong.jiang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®