]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: mm: pmdp_huge_get_and_clear(): avoid atomic ops when !CONFIG_SMP
authorPaul Walmsley <pjw@kernel.org>
Tue, 18 Nov 2025 04:19:27 +0000 (21:19 -0700)
committerPaul Walmsley <pjw@kernel.org>
Fri, 19 Dec 2025 07:18:33 +0000 (00:18 -0700)
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>
arch/riscv/include/asm/pgtable.h

index 8bd36ac842eba94ec6af140ab81bd75d32ad1ff8..1df8a6adb407e0c8ed54a545402fbb5b1098e19f 100644 (file)
@@ -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);