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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2C874C433FE for ; Mon, 14 Nov 2022 10:47:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KmCLfMfgoV3kINYBiulfL0qZabYKSzVhVQdnSfuK7JU=; b=GLo2DfqQ/d6aIX IOxTobpQN9/jcw7Qb+NBtjmU6oN0ciSw3APF810cBBaWY0/PPWIKuB4bK905+ZQk8iVF4rbywP8Ql NWkH2C4ZuiUMNpVnJZVB3xVAHQNuDhGXjo8r2Q/9x6GNJukrBeyTO/OXvSWttzwOhPFoWBXf8m8b8 n6Nvav0pDzMQFCceiZ9HJ3ORyPp/NbWf3urP/M3o7Xq81JAgRumGSzfXLiaN7LaaekyPpk9VC5CDj 8bXtxJJc8yAFztN5x0e6f5vIrYyY5Oh+9DYuvhoOvqnBU+3KnUTq2xX5jq2rb7MjVpCfQQD+EemVQ e0Ax9X2nGhlYu6c5Ytjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouWzV-0004ag-00; Mon, 14 Nov 2022 10:47:01 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouWzR-0004XH-Nh for linux-arm-kernel@lists.infradead.org; Mon, 14 Nov 2022 10:46:59 +0000 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 0A69223A; Mon, 14 Nov 2022 02:46:59 -0800 (PST) Received: from [10.57.70.90] (unknown [10.57.70.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 97DD83F73D; Mon, 14 Nov 2022 02:46:51 -0800 (PST) Message-ID: <93e31bd7-890b-abd9-a75b-44e86df5bb6d@arm.com> Date: Mon, 14 Nov 2022 10:46:47 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH] iommu/arm-smmu-v3: Optimize checking for invalid values To: Harry Song , will@kernel.org Cc: joro@8bytes.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20221113133855.6219-1-jundongsong1@gmail.com> Content-Language: en-GB From: Robin Murphy In-Reply-To: <20221113133855.6219-1-jundongsong1@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221114_024657_889730_9AAC6ADB X-CRM114-Status: GOOD ( 16.58 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2022-11-13 13:38, Harry Song wrote: > Move the check of invalid value (iotlb_gather->pgsize = 0) from > arm_smmu_iotlb_sync() to __arm_smmu_tlb_inv_range() for iotlb sync > to make the code clearer. How is this an optimisation? It adds a redundant check on paths that don't need it, and even the unmap error paths now have to do *more* work to figure out when there's nothing to sync. Furthermore, to me "clear code" means making decisions at the appropriate level of abstraction, not deliberately passing invalid arguments down through 3 more levels of callstack to eventually do nothing. If you think that the gather->pgsize logic is hard to follow and needs more explanation then by all means add a comment to call out how iommu_iotlb_gather_init() and iommu_iotlb_gather_add_page() join it up, but I don't agree with this patch as it is, sorry. Thanks, Robin. > Signed-off-by: Harry Song > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 5 +---- > 1 file changed, 1 insertion(+), 4 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 6d5df91c5..e51b9f506 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -1873,7 +1873,7 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd, > size_t inv_range = granule; > struct arm_smmu_cmdq_batch cmds; > > - if (!size) > + if (!size || !inv_range) > return; > > if (smmu->features & ARM_SMMU_FEAT_RANGE_INV) { > @@ -2507,9 +2507,6 @@ static void arm_smmu_iotlb_sync(struct iommu_domain *domain, > { > struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); > > - if (!gather->pgsize) > - return; > - > arm_smmu_tlb_inv_range_domain(gather->start, > gather->end - gather->start + 1, > gather->pgsize, true, smmu_domain); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel