Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4067591pxt; Tue, 10 Aug 2021 19:17:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXqRnHdROIjUzq5Za4mV57M6cUzEEEx/SNeUZPpnokUh2pbYLqrV1mFe7Q1t/XxV0SyKSG X-Received: by 2002:a05:6e02:1bcb:: with SMTP id x11mr191156ilv.168.1628648256811; Tue, 10 Aug 2021 19:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628648256; cv=none; d=google.com; s=arc-20160816; b=hpivnoFOU1iuMpHZRMIV4zKoYXApynKa4g/zxhjoJZ9mrkwvuNJRYws3xpzHr39Sxf HwJEPKkY0u6VxESg6YGH3NW3VMC3JDsCltaMWc0saQ6oFqF7h8ptkOgH700eOKDxWaXU vhAHLpFjhF7LcREnUkhYHPTGgVjVbUfZPyBuL32PGJIn2+UeXh8Vt3737e3tSog91cY8 sPnrsa2GLiCyxPoJbJwR2BTo9lZIlvUEuS60gaqjZwvw8g4T3znUtpNZXZHfmM1XWe7l LyuOnm8ePyN0anlNWEHEYZk1tDBUQ8386j38A/2FEMzj06/boi/NEDNcDfpBeRyL9hsV D5Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ELKsBqPJCwsr0PBkrO3wUnTm/B9XqElS9ozZU/Sfczs=; b=d8Sk18QOS/T95hfapahFpXSKHT98wYUKx+cO3cD38GO/UzN2nvBGgjJxbwsOAuJy16 6Nu1IRQ3orYPCHUQlxeizLwDPh0L/aA5dgLlKqavAj1Z7W5dz7sjfr7QAotxhBz3ILCh OdmXbLRXE+T3oexZs9N3u1lXJu5r/LWzTq5fOhdIgOBrveydqe0H6Vj68Q30mxN1UYUr wrqKiP2u6TV7TPA69y0Bx1FNPsl1B2Fia/k+fV/BxuJHnWaPP3C5626rFIPBcx1cLcFV o/nUuUMRyCuCPgDpoM+YqX6A534pdGfvdxZejx+erKvSuC/UQWmh8Ay6WkEuqkR/CesA bUVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c18si17626515ioh.78.2021.08.10.19.17.24; Tue, 10 Aug 2021 19:17:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbhHKCRF (ORCPT + 99 others); Tue, 10 Aug 2021 22:17:05 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:17004 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbhHKCRF (ORCPT ); Tue, 10 Aug 2021 22:17:05 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GktdT5F3Nzb0kW; Wed, 11 Aug 2021 10:13:01 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 11 Aug 2021 10:16:40 +0800 Received: from [10.174.179.0] (10.174.179.0) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 11 Aug 2021 10:16:40 +0800 Subject: Re: [PATCH RFC 2/8] iommu/arm-smmu-v3: Add and use static helper function arm_smmu_cmdq_issue_cmd_with_sync() To: Will Deacon CC: Robin Murphy , Joerg Roedel , linux-arm-kernel , iommu , linux-kernel References: <20210626110130.2416-1-thunder.leizhen@huawei.com> <20210626110130.2416-3-thunder.leizhen@huawei.com> <20210810182454.GB3296@willie-the-truck> From: "Leizhen (ThunderTown)" Message-ID: Date: Wed, 11 Aug 2021 10:16:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20210810182454.GB3296@willie-the-truck> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.0] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/8/11 2:24, Will Deacon wrote: > On Sat, Jun 26, 2021 at 07:01:24PM +0800, Zhen Lei wrote: >> The obvious key to the performance optimization of commit 587e6c10a7ce >> ("iommu/arm-smmu-v3: Reduce contention during command-queue insertion") is >> to allow multiple cores to insert commands in parallel after a brief mutex >> contention. >> >> Obviously, inserting as many commands at a time as possible can reduce the >> number of times the mutex contention participates, thereby improving the >> overall performance. At least it reduces the number of calls to function >> arm_smmu_cmdq_issue_cmdlist(). >> >> Therefore, function arm_smmu_cmdq_issue_cmd_with_sync() is added to insert >> the 'cmd+sync' commands at a time. >> >> Signed-off-by: Zhen Lei >> --- >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 33 +++++++++++++-------- >> 1 file changed, 21 insertions(+), 12 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 2433d3c29b49ff2..a5361153ca1d6a4 100644 >> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >> @@ -858,11 +858,25 @@ static int arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu, >> return arm_smmu_cmdq_issue_cmdlist(smmu, cmd, 1, false); >> } >> >> -static int arm_smmu_cmdq_issue_sync(struct arm_smmu_device *smmu) >> +static int __maybe_unused arm_smmu_cmdq_issue_sync(struct arm_smmu_device *smmu) >> { >> return arm_smmu_cmdq_issue_cmdlist(smmu, NULL, 0, true); >> } >> >> +static int arm_smmu_cmdq_issue_cmd_with_sync(struct arm_smmu_device *smmu, >> + struct arm_smmu_cmdq_ent *ent) >> +{ >> + u64 cmd[CMDQ_ENT_DWORDS]; >> + >> + if (arm_smmu_cmdq_build_cmd(cmd, ent)) { >> + dev_warn(smmu->dev, "ignoring unknown CMDQ opcode 0x%x\n", >> + ent->opcode); >> + return -EINVAL; >> + } >> + >> + return arm_smmu_cmdq_issue_cmdlist(smmu, cmd, 1, true); >> +} > > This function is almost identical to arm_smmu_cmdq_issue_cmd(). How about > moving the guts out into a helper: > > static int __arm_smmu_cmdq_issue_cmd(struct arm_smmu_device *smmu, > struct arm_smmu_cmdq_ent *ent, > bool sync); > > and then having arm_smmu_cmdq_issue_cmd_with_sync() and > arm_smmu_cmdq_issue_cmd() wrap that? OK, I will do it. How about remove arm_smmu_cmdq_issue_sync()? It's unused now. > > Will > . >