Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4313762pxt; Wed, 11 Aug 2021 03:11:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAXRlNwwGzuVOFYPNQiQdFcpDFi9mzIrx7pqxfypyFpBoq8KGMrLmMH0gHtB/H4RIsmVpg X-Received: by 2002:a05:6e02:1d95:: with SMTP id h21mr149547ila.23.1628676671612; Wed, 11 Aug 2021 03:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628676671; cv=none; d=google.com; s=arc-20160816; b=U4zZtz+sq+IOln8t3fV6AkeMMd/SxVFW2E7d714m2+/K0C4t7u2in1gNfiHjtU7++A i8Dmm4Tr9A8o0hbW4d3lHikMJRh89uOh5sFZ99Is0TizoQFfNNvR+cGFbsI58G/rtfyb oqOrE7v5FScibaKq6OBOoRpPg7k2UYHQla+ti8VY/OlfRv2Ob1y6tXvna6zJSY8zNDwh 9VQT9dFSm4RsC3SE+V/qNvXpo1eCQngnHLGB3NQg3l0Zwja0xzBLAGR/LuBEfM52/upM Nir0Jh4sW008mylVNsxRqF5CknrQTMrueX0xtVHgg1Jy5Mlag6e18lf6bJNi9ENnkj60 IGpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ClCuxkk/WfcXXUp3iD/Vc8Y1Dt53sdUh5rlG9UzvUB4=; b=TpPpzhjo8EJ+3tnR9tiAJhk9k2iWVgUBZ5JVWs5sA0703LpGhkevVRvCxu/l84R//m x1YmydFDmFxTd/XYwntnPKqHCiCMdjKq+WyTxqMaJx9LbjNznhYjaiLzAsgVDYQLQfRz JkYfQPEGmFSLIko2zvfY4POvphlcpnA5JNV4AQko75Bs3Q9xpp9yZNwwjv9CjqXuCdpm ZleiSCjaYUn9kINFhPASLM4DLpEPvQSvb0PX/ODC54UtocTBgr+fOQFH8am4oEIs91wc 3oKY5TAqk0cF5Nc5JoqdBMS3g5NtNDGkFx1dsrBbwJyRiZdLN3Y/0cq3C1q2oYvdfKRo IsFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vAuQbY91; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j18si949636iow.66.2021.08.11.03.11.00; Wed, 11 Aug 2021 03:11:11 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vAuQbY91; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236807AbhHKKJf (ORCPT + 99 others); Wed, 11 Aug 2021 06:09:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:53396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236690AbhHKKJd (ORCPT ); Wed, 11 Aug 2021 06:09:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 20E5A601FD; Wed, 11 Aug 2021 10:09:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628676550; bh=WFdcMDOdwT6iqhf90eKghlHbPA/yHhanICAd1+UlmRM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vAuQbY91bb67oIRwclNTdMUX+7hGHLmfOVBobsNUxT24P57KeqHCdpi20UnTatwot OZTwRCmKEHFSunGGfYDgTE4fvaSJFZSFMq9eR4Vj+Mq7MkOs0tQGNsscLUOj5Vs3LI fi6VUbSxohmzU3VdJiV4LVrxqFwDx+djRZUBmkqB5Nw8ogI/nwRutVaqUWWic9Q+DV XcXffrF9Gzgc7UVsNls69LOLZ/rgVhMuQEvqM7u6l6pJI6unO60/779Am1YIu7Ah+7 oxEOBtNDLKDCD61Gii2bw60MtIHfAyuFvv9rv9XqZRGmgsDTvTYd77MPiKiw1TLOow H1fZODrUX+eyg== Date: Wed, 11 Aug 2021 11:09:06 +0100 From: Will Deacon To: "Leizhen (ThunderTown)" Cc: Robin Murphy , Joerg Roedel , linux-arm-kernel , iommu , linux-kernel Subject: Re: [PATCH RFC 2/8] iommu/arm-smmu-v3: Add and use static helper function arm_smmu_cmdq_issue_cmd_with_sync() Message-ID: <20210811100905.GB4426@willie-the-truck> References: <20210626110130.2416-1-thunder.leizhen@huawei.com> <20210626110130.2416-3-thunder.leizhen@huawei.com> <20210810182454.GB3296@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 11, 2021 at 10:16:39AM +0800, Leizhen (ThunderTown) wrote: > > > 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. Sure. Will