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 8A62BC282DD for ; Mon, 10 Jun 2019 09:09:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64D90206E0 for ; Mon, 10 Jun 2019 09:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388836AbfFJJJZ (ORCPT ); Mon, 10 Jun 2019 05:09:25 -0400 Received: from foss.arm.com ([217.140.110.172]:38544 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388190AbfFJJJZ (ORCPT ); Mon, 10 Jun 2019 05:09:25 -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 AFFF7344; Mon, 10 Jun 2019 02:09:24 -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 3F8D03F246; Mon, 10 Jun 2019 02:09:23 -0700 (PDT) Date: Mon, 10 Jun 2019 10:09:21 +0100 From: Dave Martin To: Viresh Kumar Cc: Marc Zyngier , James Morse , Julien Thierry , Suzuki K Pouloze , Catalin Marinas , Will Deacon , Vincent Guittot , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2] KVM: arm64: Implement vq_present() as a macro Message-ID: <20190610090917.GK28398@e103592.cambridge.arm.com> References: <7c2590c4d8cc95cd40bbb05c0d0c5e2b0735a16b.1560145715.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7c2590c4d8cc95cd40bbb05c0d0c5e2b0735a16b.1560145715.git.viresh.kumar@linaro.org> 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 11:36:33AM +0530, Viresh Kumar wrote: > This routine is a one-liner and doesn't really need to be function and > should be rather implemented as a macro. > > Suggested-by: Dave Martin > Signed-off-by: Viresh Kumar > --- > V1->V2: > - The previous implementation was fixing a compilation error that > occurred only with old compilers (from 2015) due to a bug in the > compiler itself. > > - Dave suggested to rather implement this as a macro which made more > sense. > > arch/arm64/kvm/guest.c | 8 +------- > 1 file changed, 1 insertion(+), 7 deletions(-) > > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index 3ae2f82fca46..a429ed36a6a0 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)) 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. Cheers ---Dave