From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch 2/5] KVM: reintroduce guest mode bit and unify remote request code Date: Thu, 27 Aug 2009 11:25:17 +0300 Message-ID: <4A9642ED.9090104@redhat.com> References: <20090827012000.762063112@localhost.localdomain> <20090827012955.208915957@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42816 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750761AbZH0IZR (ORCPT ); Thu, 27 Aug 2009 04:25:17 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7R8PJ1c007073 for ; Thu, 27 Aug 2009 04:25:19 -0400 In-Reply-To: <20090827012955.208915957@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: On 08/27/2009 04:20 AM, Marcelo Tosatti wrote: > +} > + > +void kvm_vcpu_ipi(struct kvm_vcpu *vcpu) > +{ > + int me; > + int cpu = vcpu->cpu; > > me = get_cpu(); > - if (cpu != me&& (unsigned)cpu< nr_cpu_ids&& cpu_online(cpu)) > - if (!test_and_set_bit(KVM_REQ_KICK,&vcpu->requests)) > - smp_send_reschedule(cpu); > + if (cpu != me&& (unsigned)cpu< nr_cpu_ids&& cpu_online(cpu)) { > + if (test_bit(KVM_VCPU_GUEST_MODE,&vcpu->vcpu_state)) { > + if (!test_and_set_bit(KVM_VCPU_KICKED, > + &vcpu->vcpu_state)) > + smp_send_reschedule(cpu); > + } > + } > put_cpu(); > } > > @@ -168,6 +176,30 @@ static bool make_all_cpus_request(struct > return called; > } > > +static int kvm_req_wait(void *unused) > +{ > + cpu_relax(); > + return 0; > +} > + > +static void kvm_vcpu_request(struct kvm_vcpu *vcpu, unsigned int req) > +{ > + set_bit(req,&vcpu->requests); > + barrier(); > + kvm_vcpu_ipi(vcpu); > + wait_on_bit(&vcpu->vcpu_state, KVM_VCPU_GUEST_MODE, kvm_req_wait, > + TASK_UNINTERRUPTIBLE); > +} > + > +static void kvm_vcpus_request(struct kvm *kvm, unsigned int req) > +{ > + int i; > + struct kvm_vcpu *vcpu; > + > + kvm_for_each_vcpu(i, vcpu, kvm) > + kvm_vcpu_request(vcpu, req); > +} > Gleb notes there are two problems here: instead of using a multicast IPI, you're sending multiple unicast IPIs. Second, you're serializing the waiting. It would be better to batch-send the IPIs, then batch-wait for results. -- error compiling committee.c: too many arguments to function