From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BB6AC468C1 for ; Mon, 10 Jun 2019 09:56:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4EAD22082E for ; Mon, 10 Jun 2019 09:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388743AbfFJJ4E (ORCPT ); Mon, 10 Jun 2019 05:56:04 -0400 Received: from foss.arm.com ([217.140.110.172]:39254 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388056AbfFJJ4E (ORCPT ); Mon, 10 Jun 2019 05:56:04 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 61DC7344; Mon, 10 Jun 2019 02:56:03 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 204573F246; Mon, 10 Jun 2019 02:57:44 -0700 (PDT) Date: Mon, 10 Jun 2019 10:56:00 +0100 From: Dave Martin To: Viresh Kumar Cc: Vincent Guittot , Marc Zyngier , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH V2] KVM: arm64: Implement vq_present() as a macro Message-ID: <20190610095559.GL28398@e103592.cambridge.arm.com> References: <7c2590c4d8cc95cd40bbb05c0d0c5e2b0735a16b.1560145715.git.viresh.kumar@linaro.org> <20190610090917.GK28398@e103592.cambridge.arm.com> <20190610095030.yurzajuyylyo57h2@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190610095030.yurzajuyylyo57h2@vireshk-i7> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 10, 2019 at 03:20:30PM +0530, Viresh Kumar wrote: > On 10-06-19, 10:09, Dave Martin wrote: > > You could drop the extra level of indirection on vqs now. The only > > thing it achieves is to enforce the size of the array via type- > > checkout, but the macro can't easily do that (unless you can think > > of another way to do it). > > > > Otherwise, looks good. > > Below is what I wrote initially this morning and then moved to the > current version as I wasn't sure if you would want that :) > > -- > viresh > > -------------------------8<------------------------- > > From be823e68faffc82a6f621c16ce1bd45990d92791 Mon Sep 17 00:00:00 2001 > Message-Id: > From: Viresh Kumar > Date: Mon, 10 Jun 2019 11:15:17 +0530 > Subject: [PATCH] KVM: arm64: Implement vq_present() as a macro > > This routine is a one-liner and doesn't really need to be function and > can be implemented as a macro. > > Suggested-by: Dave Martin > Signed-off-by: Viresh Kumar > --- > arch/arm64/kvm/guest.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index 3ae2f82fca46..ae734fcfd4ea 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -207,13 +207,7 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > > #define vq_word(vq) (((vq) - SVE_VQ_MIN) / 64) > #define vq_mask(vq) ((u64)1 << ((vq) - SVE_VQ_MIN) % 64) > - > -static bool vq_present( > - const u64 (*const vqs)[KVM_ARM64_SVE_VLS_WORDS], > - unsigned int vq) > -{ > - return (*vqs)[vq_word(vq)] & vq_mask(vq); > -} > +#define vq_present(vqs, vq) ((vqs)[vq_word(vq)] & vq_mask(vq)) > > static int get_sve_vls(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > { > @@ -258,7 +252,7 @@ static int set_sve_vls(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > > max_vq = 0; > for (vq = SVE_VQ_MIN; vq <= SVE_VQ_MAX; ++vq) > - if (vq_present(&vqs, vq)) > + if (vq_present(vqs, vq)) > max_vq = vq; > > if (max_vq > sve_vq_from_vl(kvm_sve_max_vl)) > @@ -272,7 +266,7 @@ static int set_sve_vls(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > * maximum: > */ > for (vq = SVE_VQ_MIN; vq <= max_vq; ++vq) > - if (vq_present(&vqs, vq) != sve_vq_available(vq)) > + if (vq_present(vqs, vq) != sve_vq_available(vq)) > return -EINVAL; I think I prefer this version: Reviewed-by: Dave Martin Cheers ---Dave