Re: [PATCH RFC v2 4/4] Use macro to iterate over vcpus.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 26, 2009 at 11:18:11AM +0300, Avi Kivity wrote:
> 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.
>
Sorry. Forgot to run checkpatch.pl

>> +
>> +#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.
>
That's the idea, there is no more empty slots in vcpus array. Otherwise
we always need to iterate over MAX_CPUS and not online_vcpus.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux