kvm: x86: simplify kvm_vector_to_index()

Use find_nth_bit() and make the function almost a one-liner.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
Yury Norov 2025-07-19 21:58:45 -04:00 committed by Sean Christopherson
parent 1f0654dc75
commit cc63f918a2

View File

@ -1064,16 +1064,9 @@ EXPORT_SYMBOL_GPL(kvm_apic_match_dest);
int kvm_vector_to_index(u32 vector, u32 dest_vcpus,
const unsigned long *bitmap, u32 bitmap_size)
{
u32 mod;
int i, idx = -1;
mod = vector % dest_vcpus;
for (i = 0; i <= mod; i++) {
idx = find_next_bit(bitmap, bitmap_size, idx + 1);
BUG_ON(idx == bitmap_size);
}
int idx = find_nth_bit(bitmap, bitmap_size, vector % dest_vcpus);
BUG_ON(idx >= bitmap_size);
return idx;
}