[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87fsuwi3io.fsf@vitty.brq.redhat.com>
Date: Thu, 26 Aug 2021 18:17:51 +0200
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
"Dr. David Alan Gilbert" <dgilbert@...hat.com>,
Nitesh Narayan Lal <nitesh@...hat.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 3/4] KVM: Optimize kvm_make_vcpus_request_mask() a bit
Sean Christopherson <seanjc@...gle.com> writes:
> On Thu, Aug 26, 2021, Vitaly Kuznetsov wrote:
>> Iterating over set bits in 'vcpu_bitmap' should be faster than going
>> through all vCPUs, especially when just a few bits are set.
>>
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
>> ---
>
> ...
>
>> + if (vcpu_bitmap) {
>> + for_each_set_bit(i, vcpu_bitmap, KVM_MAX_VCPUS) {
>> + vcpu = kvm_get_vcpu(kvm, i);
>> + if (!vcpu || vcpu == except)
>> + continue;
>> + kvm_make_vcpu_request(kvm, vcpu, req, tmp, me);
>> + }
>> + } else {
>> + kvm_for_each_vcpu(i, vcpu, kvm) {
>> + if (vcpu == except)
>> + continue;
>> + kvm_make_vcpu_request(kvm, vcpu, req, tmp, me);
>> }
>> }
>
> Rather than feed kvm_make_all_cpus_request_except() into kvm_make_vcpus_request_mask(),
> I think it would be better to move the kvm_for_each_vcpu() path into
> kvm_make_all_cpus_request_except() (see bottom of the mail). That eliminates the
> silliness of calling a "mask" function without a mask, and also allows a follow-up
> patch to drop @except from kvm_make_vcpus_request_mask(), which is truly nonsensical
> as the caller can and should simply not set that vCPU in the mask.
Both make perfect sense, thanks! v4 is being prepared.
--
Vitaly
Powered by blists - more mailing lists