From: "Nadav Har'El" Subject: Re: [PATCH v3 2/3] KVM: send IPI to vcpu only when it's in guest mode Date: Wed, 12 Jan 2011 11:54:28 +0200 Message-ID: <20110112095428.GA15835@fermat.math.technion.ac.il> References: <4D2D5AA6.9080804@cn.fujitsu.com> <4D2D5AEF.1070006@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , Marcelo Tosatti , LKML , KVM To: Xiao Guangrong Return-path: Received: from mailgw12.technion.ac.il ([132.68.225.12]:63670 "EHLO mailgw12.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942Ab1ALJyg (ORCPT ); Wed, 12 Jan 2011 04:54:36 -0500 Content-Disposition: inline In-Reply-To: <4D2D5AEF.1070006@cn.fujitsu.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jan 12, 2011, Xiao Guangrong wrote about "[PATCH v3 2/3] KVM: send IPI to vcpu only when it's in guest mode": > We can interrupt the vcpu only when it's running in guest mode > to reduce IPI Hi, I am afraid there's a risk of confusion between the new vcpu->mode = IN_GUEST_MODE; and the existing is_guest_mode() (i.e., vcpu->arch.hflags & HF_GUEST_MASK) The latter says that the virtual cpu is in guest mode (i.e., the guest used VMLAUNCH and is runnning a nested guest), while the former says that the physical CPU that this vcpu is currently being run on, is in guest mode - or in other words, this vcpu is currently running. I'm not sure what is the best way to resolve this potential for confusion. Maybe on of them is better renamed (e.g., instead of vcpu->mode = IN_GUEST_MODE have something like vcpu->running = NOW_RUNNING). Or maybe some good comments need to to be written to explain the situation. Actually, I just noticed that there's already a vcpu->guest_mode which you are apparently replacing, so the potential for confusion is already in the current code... I.e., in the current code, is_guest_mode(vcpu) does NOT check vcpu->guest_mode... -- Nadav Har'El | Wednesday, Jan 12 2011, 7 Shevat 5771 nyh@math.technion.ac.il |----------------------------------------- Phone +972-523-790466, ICQ 13349191 |Hi! I'm a signature virus! Copy me into http://nadav.harel.org.il |your signature to help me spread!