From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992675AbdE0BSj (ORCPT ); Fri, 26 May 2017 21:18:39 -0400 Received: from mail-oi0-f46.google.com ([209.85.218.46]:35182 "EHLO mail-oi0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1948781AbdEZWHO (ORCPT ); Fri, 26 May 2017 18:07:14 -0400 MIME-Version: 1.0 In-Reply-To: References: <1495337552-78885-1-git-send-email-wanpeng.li@hotmail.com> From: Wanpeng Li Date: Sat, 27 May 2017 06:07:13 +0800 Message-ID: Subject: Re: [PATCH] KVM: X86: Fix preempt the preemption timer cancel To: Paolo Bonzini Cc: "linux-kernel@vger.kernel.org" , kvm , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-05-26 23:57 GMT+08:00 Paolo Bonzini : > > > On 21/05/2017 05:32, Wanpeng Li wrote: >> CPU0 CPU1 >> >> vmx_cancel_hv_timer >> vCPU0's vmx->hv_deadline_tsc = -1 >> >> preempt occur >> >> clear preemption timer field in CPU1's active vmcs >> vCPU0's apic_timer.hv_timer_in_use = false >> vmx_vcpu_run(vCPU0) >> vmx_arm_hv_timer >> if (vmx->hv_deadline_tsc == -1) >> nothing change >> >> handle_preemption_timer(vCPU0) >> kvm_lapic_expired_hv_timer >> WARN_ON(!apic->lapic_timer.hv_timer_in_use); > > > I think it's more like this, what do you think? > > CPU0 CPU1 > > preemption timer vmexit > handle_preemption_timer(vCPU0) > kvm_lapic_expired_hv_timer > vmx_cancel_hv_timer > vmx->hv_deadline_tsc = -1 > vmcs_clear_bits > /* hv_timer_in_use still true */ > sched_out > sched_in > kvm_arch_vcpu_load > vmx_set_hv_timer > write vmx->hv_deadline_tsc > vmcs_set_bits > /* back in kvm_lapic_expired_hv_timer */ > hv_timer_in_use = false > ... > vmx_vcpu_run > vmx_arm_hv_run > write preemption timer deadline > spurious preemption timer vmexit > handle_preemption_timer(vCPU0) > kvm_lapic_expired_hv_timer > WARN_ON(!apic->lapic_timer.hv_timer_in_use); Looks good to me, thanks for your help, Paolo. :) Regards, Wanpeng Li