From: "Jürgen Groß" <jgross@suse.com>
To: Yury Norov <yury.norov@gmail.com>
Cc: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kvm: x86: simplify kvm_vector_to_index()
Date: Wed, 20 Aug 2025 16:19:47 +0200 [thread overview]
Message-ID: <e2fc8158-6f73-48a9-85ad-b636fe01d0fb@suse.com> (raw)
In-Reply-To: <aKXX1ITCwcVPrKNM@yury>
[-- Attachment #1.1.1: Type: text/plain, Size: 1436 bytes --]
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
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
prev parent reply other threads:[~2025-08-20 14:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-20 1:58 [PATCH] kvm: x86: simplify kvm_vector_to_index() Yury Norov
2025-08-19 23:12 ` Sean Christopherson
2025-08-20 13:42 ` Yury Norov
2025-08-20 14:01 ` Juergen Gross
2025-08-20 14:12 ` Yury Norov
2025-08-20 14:19 ` Jürgen Groß [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2fc8158-6f73-48a9-85ad-b636fe01d0fb@suse.com \
--to=jgross@suse.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox