From patchwork Fri Sep 3 04:12:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 152081 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 o8348caJ018508 for ; Fri, 3 Sep 2010 04:08:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750823Ab0ICEHu (ORCPT ); Fri, 3 Sep 2010 00:07:50 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:54722 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1750748Ab0ICEHt (ORCPT ); Fri, 3 Sep 2010 00:07:49 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 8515117013C; Fri, 3 Sep 2010 12:07:46 +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 o8344Khl022825; Fri, 3 Sep 2010 12:04:20 +0800 Received: from [10.167.141.99] (unknown [10.167.141.99]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 0102B14C035; Fri, 3 Sep 2010 12:09:08 +0800 (CST) Message-ID: <4C807593.1050903@cn.fujitsu.com> Date: Fri, 03 Sep 2010 12:12:03 +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] KVM: don't sent IPI if the vcpu is not online 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]); Fri, 03 Sep 2010 04:08:38 +0000 (UTC) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index f2ecdd5..a2682cf 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -86,6 +86,7 @@ struct kvm_vcpu { unsigned long requests; unsigned long guest_debug; int srcu_idx; + bool online; int fpu_active; int guest_fpu_loaded, guest_xcr0_loaded; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9a73b98..998cbc8 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -148,8 +148,9 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) raw_spin_lock(&kvm->requests_lock); me = smp_processor_id(); kvm_for_each_vcpu(i, vcpu, kvm) { - if (kvm_make_check_request(req, vcpu)) + if (kvm_make_check_request(req, vcpu) || !vcpu->online) continue; + cpu = vcpu->cpu; if (cpus != NULL && cpu != -1 && cpu != me) cpumask_set_cpu(cpu, cpus); @@ -2245,6 +2246,7 @@ static void kvm_sched_in(struct preempt_notifier *pn, int cpu) { struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn); + vcpu->online = true; kvm_arch_vcpu_load(vcpu, cpu); } @@ -2253,6 +2255,7 @@ static void kvm_sched_out(struct preempt_notifier *pn, { struct kvm_vcpu *vcpu = preempt_notifier_to_vcpu(pn); + vcpu->online = false; kvm_arch_vcpu_put(vcpu); }