From: Vasant Hegde <vasant.hegde@amd.com>
To: Uros Bizjak <ubizjak@gmail.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Joerg Roedel <joro@8bytes.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>
Subject: Re: [PATCH 1/3] iommu/amd: Use try_cmpxchg64() in v2_alloc_pte()
Date: Thu, 23 May 2024 16:10:28 +0530 [thread overview]
Message-ID: <bf2ea452-75ea-4091-90fe-c83062729b76@amd.com> (raw)
In-Reply-To: <20240522082729.971123-1-ubizjak@gmail.com>
On 5/22/2024 1:56 PM, Uros Bizjak wrote:
> Use try_cmpxchg64() instead of cmpxchg64 (*ptr, old, new) != old in
> v2_alloc_pte(). cmpxchg returns success in ZF flag, so this change
> saves a compare after cmpxchg (and related move instruction
> in front of cmpxchg).
>
> This is the same improvement as implemented for alloc_pte() in:
>
> commit 0d10fe759117 ("iommu/amd: Use try_cmpxchg64 in alloc_pte and free_clear_pte")
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Robin Murphy <robin.murphy@arm.com>
Thanks for fixing it. Looks good to me.
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
> ---
> drivers/iommu/amd/io_pgtable_v2.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/amd/io_pgtable_v2.c b/drivers/iommu/amd/io_pgtable_v2.c
> index 78ac37c5ccc1..664e91c88748 100644
> --- a/drivers/iommu/amd/io_pgtable_v2.c
> +++ b/drivers/iommu/amd/io_pgtable_v2.c
> @@ -158,7 +158,7 @@ static u64 *v2_alloc_pte(int nid, u64 *pgd, unsigned long iova,
>
> __npte = set_pgtable_attr(page);
> /* pte could have been changed somewhere. */
> - if (cmpxchg64(pte, __pte, __npte) != __pte)
> + if (!try_cmpxchg64(pte, &__pte, __npte))
> iommu_free_page(page);
> else if (IOMMU_PTE_PRESENT(__pte))
> *updated = true;
prev parent reply other threads:[~2024-05-23 10:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 8:26 [PATCH 1/3] iommu/amd: Use try_cmpxchg64() in v2_alloc_pte() Uros Bizjak
2024-05-22 8:26 ` [PATCH 2/3] iommu/vt-d: Use try_cmpxchg64() in intel_pasid_get_entry() Uros Bizjak
2024-05-23 13:24 ` Baolu Lu
2024-05-23 13:34 ` Uros Bizjak
2024-05-23 13:44 ` Baolu Lu
2024-05-23 13:57 ` Uros Bizjak
2024-05-24 1:08 ` Baolu Lu
2024-05-24 1:09 ` Baolu Lu
2024-05-22 8:26 ` [PATCH 3/3] iommufd: Use atomic_long_try_cmpxchg() in incr_user_locked_vm() Uros Bizjak
2024-05-22 12:45 ` Jason Gunthorpe
2024-05-23 10:40 ` Vasant Hegde [this message]
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=bf2ea452-75ea-4091-90fe-c83062729b76@amd.com \
--to=vasant.hegde@amd.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=ubizjak@gmail.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