[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87bmchtu2a.fsf@vitty.brq.redhat.com>
Date: Mon, 11 Jun 2018 13:57:01 +0200
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Radim Krčmář <rkrcmar@...hat.com>
Cc: kvm@...r.kernel.org, x86@...nel.org,
Paolo Bonzini <pbonzini@...hat.com>,
Roman Kagan <rkagan@...tuozzo.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
"Michael Kelley \(EOSG\)" <Michael.H.Kelley@...rosoft.com>,
Mohammed Gamal <mmorsy@...hat.com>,
Cathy Avery <cavery@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 5/8] KVM: introduce kvm_make_vcpus_request_mask() API
Radim Krčmář <rkrcmar@...hat.com> 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@...hat.com>
>> ---
>> 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
Powered by blists - more mailing lists