Skip to content

Commit d603fd8

Browse files
committed
KVM: x86: hyper-v: replace bitmap_weight() with hweight64()
kvm_hv_flush_tlb() applies bitmap API to a u64 variable valid_bank_mask. Since valid_bank_mask has a fixed size, we can use hweight64() and avoid excessive bloating. CC: Borislav Petkov <[email protected]> CC: Dave Hansen <[email protected]> CC: H. Peter Anvin <[email protected]> CC: Ingo Molnar <[email protected]> CC: Jim Mattson <[email protected]> CC: Joerg Roedel <[email protected]> CC: Paolo Bonzini <[email protected]> CC: Sean Christopherson <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Vitaly Kuznetsov <[email protected]> CC: Wanpeng Li <[email protected]> CC: [email protected] CC: [email protected] CC: [email protected] Acked-by: Vitaly Kuznetsov <[email protected]> Signed-off-by: Yury Norov <[email protected]>
1 parent a7ef9b4 commit d603fd8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/kvm/hyperv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
18791879
all_cpus = flush_ex.hv_vp_set.format !=
18801880
HV_GENERIC_SET_SPARSE_4K;
18811881

1882-
if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
1882+
if (hc->var_cnt != hweight64(valid_bank_mask))
18831883
return HV_STATUS_INVALID_HYPERCALL_INPUT;
18841884

18851885
if (all_cpus)
@@ -1980,7 +1980,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
19801980
valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask;
19811981
all_cpus = send_ipi_ex.vp_set.format == HV_GENERIC_SET_ALL;
19821982

1983-
if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
1983+
if (hc->var_cnt != hweight64(valid_bank_mask))
19841984
return HV_STATUS_INVALID_HYPERCALL_INPUT;
19851985

19861986
if (all_cpus)

0 commit comments

Comments
 (0)