From: Paul Walmsley <pjw@kernel.org>
To: linux-riscv@lists.infradead.org
Subject: [PATCH 3/3] riscv: mm: use xchg() on non-atomic_long_t variables, not atomic_long_xchg()
Date: Wed, 19 Nov 2025 21:18:30 -0700 [thread overview]
Message-ID: <20251120042001.1766011-4-pjw@kernel.org> (raw)
In-Reply-To: <20251120042001.1766011-1-pjw@kernel.org>
Let's not call atomic_long_xchg() on something that's not an
atomic_long_t, and just use xchg() instead. Continues the cleanup
from commit 546e42c8c6d94 ("riscv: Use an atomic xchg in
pudp_huge_get_and_clear()"),
Cc: Alexandre Ghiti <alex@ghiti.fr>
Signed-off-by: Paul Walmsley <pjw@kernel.org>
---
arch/riscv/include/asm/pgtable.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index e1610d031199..a1ffa502739b 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -591,7 +591,7 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
unsigned long address, pte_t *ptep)
{
#ifdef CONFIG_SMP
- pte_t pte = __pte(atomic_long_xchg((atomic_long_t *)ptep, 0));
+ pte_t pte = __pte(xchg(&ptep->pte, 0));
#else
pte_t pte = *ptep;
@@ -868,7 +868,7 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
unsigned long address, pmd_t *pmdp)
{
#ifdef CONFIG_SMP
- pmd_t pmd = __pmd(atomic_long_xchg((atomic_long_t *)pmdp, 0));
+ pmd_t pmd = __pmd(xchg(&pmdp->pmd, 0));
#else
pmd_t pmd = *pmdp;
--
2.48.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-11-20 4:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 4:18 [PATCH 0/3] riscv: mm: clean up and optimize some page table get-and-clear functions Paul Walmsley
2025-11-20 4:18 ` [PATCH 1/3] riscv: mm: pmdp_huge_get_and_clear(): avoid atomic ops when !CONFIG_SMP Paul Walmsley
2025-11-20 4:18 ` [PATCH 2/3] riscv: mm: ptep_get_and_clear(): " Paul Walmsley
2025-11-20 4:18 ` Paul Walmsley [this message]
2025-11-20 4:30 ` [PATCH 0/3] riscv: mm: clean up and optimize some page table get-and-clear functions patchwork-bot+linux-riscv
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=20251120042001.1766011-4-pjw@kernel.org \
--to=pjw@kernel.org \
--cc=linux-riscv@lists.infradead.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