Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1707015rwi; Wed, 19 Oct 2022 14:23:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4PF098snLftkERwmeHyzTA37n0gufBkZVPif07xr797WdNS6MGoSFLtNOfSY6vqy71TWik X-Received: by 2002:a17:903:234f:b0:17f:6711:1f9f with SMTP id c15-20020a170903234f00b0017f67111f9fmr10142125plh.32.1666214609374; Wed, 19 Oct 2022 14:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666214609; cv=none; d=google.com; s=arc-20160816; b=OsahWWIa3yH+NDjcynTPZuxOOGKlRvvevVCGCDg0P6TiHghN5tP+6WOdmp/XNPlV2G K5lfdJMIb8eDH3+ZOUT+ZGWF/ojJLjGqIPOp5LBUXmuv9NhgT57qsf699Xjr/BPyiqhO +f+tgxD2qGAD8LE3f2SGaMIApgk05zzu9W8Vd3bLqR6nwWHl2yeuE6F7vC6jxQLXGpZU EcZ2bp9tfsMONr+98RrIecvrwip7EO879k+vZNHCTbRVyebfghLf9JdIuprkHgIUgBOG tpYjrsguXT0dkz5Tawu2MQvsHwqVu88GqgSTxlDgO5bjCScE1H/bQ9PlRQV5iQdwAEBH LPkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kqJOFlfwNgCDzAUg+3GKgd5GjZJIWzZ3Ope902HuuIc=; b=JQj4QS4iuKiyURx5GjQoTKrK1xX92e0nyU/m48naDpuxktUfhCG4UbDc/h2vvmmhqo q9jnSLWamEgnczfzI8cDJJp5FzKNCQhy1AkKNkY65e/SYUOHq53zf8H1Jg4P8ILNNycz HK1Idjgfrne0kWMIHXiKnND+cDnQDhNYs3bt2fQpe8nrKLKVsqEIMNl+I/y68JzC+JhD TVaO5+QTzRADhNOO6yByjIzibT0HXZvbhxpIwmyJCz+Qo8DHAZBPm2sLfXJ5mO7vMIOC vVLUIRCoHQ2C6jSq/JpOseCgBmLPUxpakD/94V2mOXG+IGii4s0icZtbHq2J2EZ3Yd4q a9SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aamPcz5c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a63930f000000b0042f6352ba2csi19661377pge.745.2022.10.19.14.23.17; Wed, 19 Oct 2022 14:23:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aamPcz5c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230235AbiJSUOP (ORCPT + 99 others); Wed, 19 Oct 2022 16:14:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbiJSUOM (ORCPT ); Wed, 19 Oct 2022 16:14:12 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3671C73ED for ; Wed, 19 Oct 2022 13:14:12 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id n130so20533512oia.6 for ; Wed, 19 Oct 2022 13:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=kqJOFlfwNgCDzAUg+3GKgd5GjZJIWzZ3Ope902HuuIc=; b=aamPcz5cH2f8vrWESZ8tn5FtLYZ0e2DUYmpGuRUSftaqxaK1qlNpUlih4yCfZesLbY k0GC/vrRRBwmINiUlgmBYLEoi54Rw1e61DBNjVJ3m1zIZqV5DlC0sj43HJPpaprwDQFF gtom64pXNAd5XfaKkKu8OfnRqwFcsGO59fopaEzxI+Ap7brT85i96IbVXUMNhS/1fYf3 HQlTdAojQumAEuhFodP9w5LLXb7y33T4FKd9OcDEjDPXwPXKJ44Jpz94UUXC3PwQVjMl QA9RGuLFUuKtd1T2IrpyBNFCweBnL8MQXxLPcdSKwTw76yFEOuexU0IjNjvN+I5dIKJ0 Skcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kqJOFlfwNgCDzAUg+3GKgd5GjZJIWzZ3Ope902HuuIc=; b=TmDj6ooXERcfa1SmMriJHfoECpJY6e7kNbMZCFYtnn592+qIeh+gU5y1hTOKKY284K W+pG0AD4Zc2PD/aUIZGntGAc9Y4NRcNgIj9iKFTgWTOLTa6GCoenx2qJbYn4yQsyzkpY yq1V8nejuCd2nljD5uhcjtUxM+Sou67lFByAuH5Htxrv0rL/WxOoylizIqDAoYBAeeUn 8gprpQY1ygXLCckwa0fK+0zhim6qpD3++U3xMqohj879AaMHm1tr9tZXwhELUH4m7NP8 TERbsW5nQe5nrWB3vXSeO529L1gAZQQjsOkh0gltii52A+ey00K3rFYVQqnRLDOLCwWh xbyA== X-Gm-Message-State: ACrzQf3M3IEjmG7ayH38Po1J03DHwDMtQxoypmBEgSOjoiYAk0IAySQ1 UaRKf6bsENh4Kr/lu4T0G7vyUznL8gYV4w== X-Received: by 2002:a17:90b:278c:b0:20a:e1e6:5340 with SMTP id pw12-20020a17090b278c00b0020ae1e65340mr47245894pjb.239.1666210440194; Wed, 19 Oct 2022 13:14:00 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id q6-20020a170902dac600b0018542a1b553sm10954895plx.127.2022.10.19.13.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 13:13:59 -0700 (PDT) Date: Wed, 19 Oct 2022 20:13:56 +0000 From: Sean Christopherson To: Vitaly Kuznetsov Cc: kvm@vger.kernel.org, Paolo Bonzini , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.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() Message-ID: References: <20221004123956.188909-1-vkuznets@redhat.com> <20221004123956.188909-17-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221004123956.188909-17-vkuznets@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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;