[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e2fc8158-6f73-48a9-85ad-b636fe01d0fb@suse.com>
Date: Wed, 20 Aug 2025 16:19:47 +0200
From: Jürgen Groß <jgross@...e.com>
To: Yury Norov <yury.norov@...il.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com>,
x86@...nel.org, kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kvm: x86: simplify kvm_vector_to_index()
On 20.08.25 16:12, Yury Norov wrote:
> On Wed, Aug 20, 2025 at 04:01:22PM +0200, Juergen Gross wrote:
>> On 20.08.25 15:42, Yury Norov wrote:
>>> On Tue, Aug 19, 2025 at 04:12:11PM -0700, Sean Christopherson wrote:
>>>> On Sat, 19 Jul 2025 21:58:45 -0400, Yury Norov wrote:
>>>>> Use find_nth_bit() and make the function almost a one-liner.
>>>>
>>>> Applied to kvm-x86 misc, thanks!
>>>>
>>>> P.S. I'm amazed you could decipher the intent of the code. Even with your
>>>> patch, it took me 10+ minutes to understand the "logic".
>>>
>>> Thanks Sean. :)
>>>
>>>> [1/1] kvm: x86: simplify kvm_vector_to_index()
>>>> https://github.com/kvm-x86/linux/commit/cc63f918a215
>>
>> Is this really correct?
>>
>> The original code has:
>>
>> for (i = 0; i <= mod; i++)
>>
>> (note the "<=").
>>
>> So it will find the (mod + 1)th bit set, so shouldn't it use
>>
>> idx = find_nth_bit(bitmap, bitmap_size, (vector % dest_vcpus) + 1);
>>
>> instead?
>>
>> My remark assumes that find_nth_bit(bitmap, bitmap_size, 1) will return the
>> same value as find_first_bit(bitmap, bitmap_size).
>
> find_nth_bit indexes those bits starting from 0, so
Ah, okay. That was the part I wasn't sure about, hence the addition of
my assumption regarding the semantics of find_nth_bit() (looking into the
__find_nth_bit() code didn't make that obvious at once).
Thanks for the clarification.
Juergen
Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3684 bytes)
Download attachment "OpenPGP_signature.asc" of type "application/pgp-signature" (496 bytes)
Powered by blists - more mailing lists