[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y1BahCzO4jxFC9Ey@google.com>
Date: Wed, 19 Oct 2022 20:13:56 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Vitaly Kuznetsov <vkuznets@...hat.com>
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Michael Kelley <mikelley@...rosoft.com>,
Siddharth Chandrasekaran <sidcha@...zon.de>,
Yuan Yao <yuan.yao@...ux.intel.com>,
Maxim Levitsky <mlevitsk@...hat.com>,
linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v11 16/46] KVM: x86: hyper-v: Don't use
sparse_set_to_vcpu_mask() in kvm_hv_send_ipi()
On Tue, Oct 04, 2022, Vitaly Kuznetsov wrote:
> @@ -2034,7 +2056,10 @@ static void kvm_send_ipi_to_many(struct kvm *kvm, u32 vector,
> unsigned long i;
>
> kvm_for_each_vcpu(i, vcpu, kvm) {
> - if (vcpu_bitmap && !test_bit(i, vcpu_bitmap))
> + if (sparse_banks &&
> + !hv_is_vp_in_sparse_set(kvm_hv_get_vpindex(vcpu),
> + valid_bank_mask,
> + sparse_banks))
Nit, this fits on two lines and IMO is slightly easier on the eyes:
if (sparse_banks &&
!hv_is_vp_in_sparse_set(kvm_hv_get_vpindex(vcpu),
valid_bank_mask, sparse_banks))
continue;
> continue;
>
> /* We fail only when APIC is disabled */
> @@ -2047,7 +2072,6 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
> struct kvm *kvm = vcpu->kvm;
> struct hv_send_ipi_ex send_ipi_ex;
> struct hv_send_ipi send_ipi;
> - DECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);
> u64 valid_bank_mask;
> u64 sparse_banks[KVM_HV_MAX_SPARSE_VCPU_SET_BITS];
> u32 vector;
> @@ -2109,13 +2133,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
> if ((vector < HV_IPI_LOW_VECTOR) || (vector > HV_IPI_HIGH_VECTOR))
> return HV_STATUS_INVALID_HYPERCALL_INPUT;
>
> - if (all_cpus) {
> - kvm_send_ipi_to_many(kvm, vector, NULL);
> - } else {
> - sparse_set_to_vcpu_mask(kvm, sparse_banks, valid_bank_mask, vcpu_mask);
> -
> - kvm_send_ipi_to_many(kvm, vector, vcpu_mask);
> - }
> + kvm_hv_send_ipi_to_many(kvm, vector, all_cpus ? NULL : sparse_banks, valid_bank_mask);
Any objection to not using a ternary operator?
if (all_cpus)
kvm_hv_send_ipi_to_many(kvm, vector, NULL, 0);
else
kvm_hv_send_ipi_to_many(kvm, vector, sparse_banks, valid_bank_mask);
Mostly because it's somewhat arbitrary that earlier code ensures valid_bank_mask
is set in the all_cpus=true case, e.g. arguably KVM doesn't need to do the var_cnt
sanity check in the all_cpus case:
all_cpus = send_ipi_ex.vp_set.format == HV_GENERIC_SET_ALL;
if (all_cpus)
goto check_and_send_ipi;
valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask;
if (hc->var_cnt != hweight64(valid_bank_mask))
return HV_STATUS_INVALID_HYPERCALL_INPUT;
if (!hc->var_cnt)
goto ret_success;
Powered by blists - more mailing lists