summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Walmsley <pjw@kernel.org>2025-11-18 07:19:27 +0300
committerPaul Walmsley <pjw@kernel.org>2025-12-19 10:18:33 +0300
commit1e6084d5c433b142b18d57694a6ab555ca6bb8cc (patch)
tree6390df44b0f4c3d7cb671e78f2185751c132cab2
parent818d78ba1b3f88d2bfee249f25020211488a26c3 (diff)
downloadlinux-1e6084d5c433b142b18d57694a6ab555ca6bb8cc.tar.xz
riscv: mm: pmdp_huge_get_and_clear(): avoid atomic ops when !CONFIG_SMP
When !CONFIG_SMP, there's no need for atomic operations in pmdp_huge_get_and_clear(), so, similar to what x86 does, let's not use atomics in this case. See also 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>
-rw-r--r--arch/riscv/include/asm/pgtable.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 8bd36ac842eb..1df8a6adb407 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -997,7 +997,13 @@ static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
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));
+#else
+ pmd_t pmd = *pmdp;
+
+ pmd_clear(pmdp);
+#endif
page_table_check_pmd_clear(mm, pmd);