From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH RFC v2 4/4] Use macro to iterate over vcpus. Date: Tue, 26 May 2009 11:18:11 +0300 Message-ID: <4A1BA5C3.3000204@redhat.com> References: <1243266636-16914-1-git-send-email-gleb@redhat.com> <1243266636-16914-5-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx2.redhat.com ([66.187.237.31]:47180 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751626AbZEZISM (ORCPT ); Tue, 26 May 2009 04:18:12 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4Q8IEDF026302 for ; Tue, 26 May 2009 04:18:14 -0400 In-Reply-To: <1243266636-16914-5-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Gleb Natapov wrote: > void kvm_arch_sync_events(struct kvm *kvm) > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 0934df3..34634e0 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -170,6 +170,17 @@ struct kvm { > #define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt) > #define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt) > > +static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i) > +{ > + smp_rmb(); > + return kvm->vcpus[i]; > +} > Whitespace. > + > +#define kvm_for_each_vcpu(idx, vcpup, kvm) \ > + for (idx = 0, vcpup = kvm_get_vcpu(kvm, idx); \ > + idx < atomic_read(&kvm->online_vcpus) && vcpup; \ > + vcpup = kvm_get_vcpu(kvm, ++idx)) > + > This will stop when reaching the first empty vcpu slot, while current code skips over empty slots. Please preserve existing behaviour. -- error compiling committee.c: too many arguments to function