From patchwork Wed Oct 27 09:05:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 285082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9R922Xf015960 for ; Wed, 27 Oct 2010 09:02:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760675Ab0J0JBi (ORCPT ); Wed, 27 Oct 2010 05:01:38 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:58598 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1760620Ab0J0JBg (ORCPT ); Wed, 27 Oct 2010 05:01:36 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 1ABFD170E7B; Wed, 27 Oct 2010 17:01:30 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o9R8vLfB024490; Wed, 27 Oct 2010 16:57:21 +0800 Received: from [10.167.225.99] (unknown [10.167.225.99]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 928CD14C09D; Wed, 27 Oct 2010 17:03:12 +0800 (CST) Message-ID: <4CC7EB75.9030709@cn.fujitsu.com> Date: Wed, 27 Oct 2010 17:05:57 +0800 From: Xiao Guangrong User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6 MIME-Version: 1.0 To: Avi Kivity CC: Marcelo Tosatti , LKML , KVM Subject: [PATCH 5/8] KVM: don't touch vcpu stat after async pf is complete References: <4CC7EA7D.5020901@cn.fujitsu.com> In-Reply-To: <4CC7EA7D.5020901@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 27 Oct 2010 09:02:03 +0000 (UTC) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 1be0058..d01677b 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -822,6 +822,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, struct kvm_async_pf *work); void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, struct kvm_async_pf *work); +void kvm_arch_async_pf_completion(struct kvm_vcpu *vcpu); bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu); extern bool kvm_find_async_pf_gfn(struct kvm_vcpu *vcpu, gfn_t gfn); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0b2c420..c0e7ad0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6280,6 +6280,11 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, } } +void kvm_arch_async_pf_completion(struct kvm_vcpu *vcpu) +{ + vcpu->arch.apf.halted = false; +} + bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu) { if (!(vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED)) diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index e213ca4..5307a32 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -142,6 +142,7 @@ bool kvm_check_async_pf_completion(struct kvm_vcpu *vcpu) if (work->page) put_page(work->page); kmem_cache_free(async_pf_cache, work); + kvm_arch_async_pf_completion(vcpu); return true; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index d9aed28..23a8b06 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1347,11 +1347,14 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) for (;;) { prepare_to_wait(&vcpu->wq, &wait, TASK_INTERRUPTIBLE); - if (kvm_arch_vcpu_runnable(vcpu) || - kvm_check_async_pf_completion(vcpu)) { + if (kvm_arch_vcpu_runnable(vcpu)) { kvm_make_request(KVM_REQ_UNHALT, vcpu); break; } + + if (kvm_check_async_pf_completion(vcpu)) + break; + if (kvm_cpu_has_pending_timer(vcpu)) break; if (signal_pending(current))