From: John Garry <john.garry@huawei.com>
To: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>,
<linux-arm-kernel@lists.infradead.org>,
<iommu@lists.linux-foundation.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 1/1] iommu/arm-smmu-v3: Simplify useless instructions in arm_smmu_cmdq_build_cmd()
Date: Wed, 8 Dec 2021 18:17:45 +0000 [thread overview]
Message-ID: <4f296b55-a59a-49b4-ad4d-902bb83a203c@huawei.com> (raw)
In-Reply-To: <58e8e7c6-a47b-7816-ac74-aefa5b55dd17@huawei.com>
>> Did you notice any performance change with this change?
>
> Hi John:
> Thanks for the tip. I wrote a test case today, and I found that the
> performance did not go up but down.
I very quickly tested on a DMA mapping benchmark very similar to the
kernel DMA benchmark module - I got mixed results. For fewer CPUs (<8),
a small improvement, like 0.7%. For more CPUs, a dis-improvement -
that's surprising, I did expect just no change as any improvement would
get dwarfed from the slower unmap rates for more CPUs. I can check this
more tomorrow.
> It's so weird. So I decided not to
> change it, because it's also poorly readable. So I plan to make only
> the following modifications:
> @@ -237,7 +237,7 @@ static int queue_remove_raw(struct arm_smmu_queue *q, u64 *ent)
> static int arm_smmu_cmdq_build_cmd(u64 *cmd, struct arm_smmu_cmdq_ent *ent)
> {
> memset(cmd, 0, 1 << CMDQ_ENT_SZ_SHIFT);
> - cmd[0] |= FIELD_PREP(CMDQ_0_OP, ent->opcode);
> + cmd[0] = FIELD_PREP(CMDQ_0_OP, ent->opcode);
>
> switch (ent->opcode) {
> case CMDQ_OP_TLBI_EL2_ALL:
>
> This prevents the compiler from generating the following two inefficient
> instructions:
> 394: f9400002 ldr x2, [x0] //x2 = cmd[0]
> 398: aa020062 orr x2, x3, x2 //x3 = FIELD_PREP(CMDQ_0_OP, ent->opcode)
>
> Maybe it's not worth changing because I've only seen a 0.x nanosecond reduction
> in performance. But one thing is, it only comes with benefits, no side effects.
>
I just think that with the original code that cmd[] is on the stack and
cached, so if we have write-back attribute (which I think we do) then
there would not necessarily a write to external memory per write to cmd[].
So, apart from this approach, I think that if we can just reduce the
instructions through other efficiencies in the function then that would
be good.
Thanks,
John
next prev parent reply other threads:[~2021-12-08 18:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 9:41 [PATCH v3 0/1] iommu/arm-smmu-v3: Simplify useless instructions in arm_smmu_cmdq_build_cmd() Zhen Lei
2021-12-07 9:41 ` [PATCH v3 1/1] " Zhen Lei
2021-12-07 16:17 ` John Garry
2021-12-08 13:40 ` Leizhen (ThunderTown)
2021-12-08 18:17 ` John Garry [this message]
2021-12-08 18:40 ` Robin Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f296b55-a59a-49b4-ad4d-902bb83a203c@huawei.com \
--to=john.garry@huawei.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=thunder.leizhen@huawei.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).