Re: [PATCH v4 5/8] KVM: introduce kvm_make_vcpus_request_mask() API

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

 



Radim Krčmář <rkrcmar@xxxxxxxxxx> writes:

> 2018-05-16 17:21+0200, Vitaly Kuznetsov:
>> Hyper-V style PV TLB flush hypercalls inmplementation will use this API.
>> To avoid memory allocation in CONFIG_CPUMASK_OFFSTACK case add
>> cpumask_var_t argument.
>> 
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
>> ---
>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>> -bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
>> +bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
>> +				 unsigned long *vcpu_bitmap, cpumask_var_t tmp)
>>  {
>>  	int i, cpu, me;
>> -	cpumask_var_t cpus;
>> -	bool called;
>>  	struct kvm_vcpu *vcpu;
>> -
>> -	zalloc_cpumask_var(&cpus, GFP_ATOMIC);
>> +	bool called;
>>  
>>  	me = get_cpu();
>> +
>
> Two optimizations come to mind: First is to use for_each_set_bit instead
> of kvm_for_each_vcpu to improve the sparse case.
>

I think I had such version at some point but then for some reason I
decided I'm re-implementing kvm_for_each_vcpu for no particular
reason.

>>  	kvm_for_each_vcpu(i, vcpu, kvm) {
>> +		if (!test_bit(i, vcpu_bitmap))
>
> And the second is to pass vcpu_bitmap = NULL instead of building the
> bitmap with all VCPUs.  Doesn't looks too good in the end, though:
>
> #define kvm_for_each_vcpu_bitmap(idx, vcpup, kvm, bitmap, len) \
> 	for (idx = (bitmap ? find_first_bit(bitmap, len) : 0); \
> 	     idx < len && (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
> 	     bitmap ? find_next_bit(bitmap, len, idx + 1) : idx++)

I'll take a try, thanks!

-- 
  Vitaly



[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