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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6744BC433F5 for ; Mon, 4 Oct 2021 12:09:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 356BB6128A for ; Mon, 4 Oct 2021 12:09:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 356BB6128A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jq85X9bhWuJmuljBnKdO7chVdMpDUdsvti+N9yyMbEU=; b=jacR5KbZuQK6ze i+WiDVoaHHV3M/LJ0EV1NbQJK074dKy1MQdG69WKWZepWDU2LzebU6JRHzgQRxYbeTS7qiUOVsjfq TV6h4KxBIETMPClzo4H+KxrdKD3V32oZqjIRUqXc7iQnwMNeolw8IDrIZEG6yhsKHzvncpQ0DU9ml O14nowCnMkb9Uk8lZF6+6pwiceuJlyIPBsGtp95EHPKH0D1ZIc7RZYpp9CjN3SK5kihUlLwe+E52X 8YDw1icnGqhuLQlmNwXwHcLJDRr4RiAF8+4EHn+p92vzAx5oNYWrUqhpkoUVFWcjVZvCThxR7RO8T rI2N9FtFEbfaH5eK7QYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXMkg-006Mzl-8u; Mon, 04 Oct 2021 12:07:26 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXMkZ-006Mtj-JY for linux-arm-kernel@lists.infradead.org; Mon, 04 Oct 2021 12:07:22 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id F24A960F9B; Mon, 4 Oct 2021 12:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633349239; bh=rCJYdr32dOl1E74PBWpYOr8BwKcZx05HK0ZRUpipNQ4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oKQjBWAnxcd/31GhQ0+bLFhoylKcEBeS3fcT6cHbp4QqE8BZDvJ0vXfy85uElZqHk mZqNoC9UaK2GU52qbBumDMWACYDr3P7VBcdV4jpnc7/ant6AZwpEWh1HE/RAmdgKHS uYPA8/TvcSFKCImvCsQ61FZC1Qu2U8J3xRM/ZSmIfO+y5q/UBTEM/yD7mJ1lTSQYJb FnRcNGQmg48BYP7b+1DMZdrn9Owx+r8iZ8+yaxBNpzbiBjOWrcYgTn6DYsaSX+xt5u 1f5nA91t8/HLEnztt0UX7X+WzXKlQu6zi5mF8//0PAPlnw3vfWK82zU1cX4EkFxgQk Kj1AklzDHqRRA== Date: Mon, 4 Oct 2021 13:07:15 +0100 From: Will Deacon To: Zhen Lei Cc: Robin Murphy , Joerg Roedel , linux-arm-kernel , iommu , linux-kernel@vger.kernel.org, John Garry Subject: Re: [PATCH v2 2/2] iommu/arm-smmu-v3: Simplify useless instructions in arm_smmu_cmdq_build_cmd() Message-ID: <20211004120714.GD27373@willie-the-truck> References: <20210818080452.2079-1-thunder.leizhen@huawei.com> <20210818080452.2079-3-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210818080452.2079-3-thunder.leizhen@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211004_050719_690235_873AF94F X-CRM114-Status: GOOD ( 22.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Aug 18, 2021 at 04:04:52PM +0800, Zhen Lei wrote: > Although the parameter 'cmd' is always passed by a local array variable, > and only this function modifies it, the compiler does not know this. The > compiler almost always reads the value of cmd[i] from memory rather than > directly using the value cached in the register. This generates many > useless instruction operations and affects the performance to some extent. > > To guide the compiler for proper optimization, 'cmd' is defined as a local > array variable, marked as register, and copied to the output parameter at > a time when the function is returned. > > The optimization effect can be viewed by running the "size arm-smmu-v3.o" > command. > > Before: > text data bss dec hex > 26954 1348 56 28358 6ec6 > > After: > text data bss dec hex > 26762 1348 56 28166 6e06 > > Signed-off-by: Zhen Lei > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 01e95b56ffa07d1..7cec0c967f71d86 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -234,10 +234,12 @@ static int queue_remove_raw(struct arm_smmu_queue *q, u64 *ent) > } > > /* High-level queue accessors */ > -static int arm_smmu_cmdq_build_cmd(u64 *cmd, struct arm_smmu_cmdq_ent *ent) > +static int arm_smmu_cmdq_build_cmd(u64 *out_cmd, struct arm_smmu_cmdq_ent *ent) > { > - memset(cmd, 0, 1 << CMDQ_ENT_SZ_SHIFT); > - cmd[0] |= FIELD_PREP(CMDQ_0_OP, ent->opcode); > + register u64 cmd[CMDQ_ENT_DWORDS]; 'register' is pretty badly specified outside of a handful of limited uses in conjunction with inline asm, so I really don't think we should be using it here. > + cmd[0] = FIELD_PREP(CMDQ_0_OP, ent->opcode); This generates a compiler warning about taking the address of a 'register' variable. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel