Skip to content

Commit 425cc08

Browse files
author
Paul Walmsley
committed
riscv: mm: ptep_get_and_clear(): avoid atomic ops when !CONFIG_SMP
When !CONFIG_SMP, there's no need for atomic operations in ptep_get_and_clear(), so, similar to x86, let's not use atomics in this case. Cc: Alexandre Ghiti <alex@ghiti.fr> Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent 1e6084d commit 425cc08

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

arch/riscv/include/asm/pgtable.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,13 @@ extern int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long a
660660
static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
661661
unsigned long address, pte_t *ptep)
662662
{
663+
#ifdef CONFIG_SMP
663664
pte_t pte = __pte(atomic_long_xchg((atomic_long_t *)ptep, 0));
665+
#else
666+
pte_t pte = *ptep;
667+
668+
set_pte(ptep, __pte(0));
669+
#endif
664670

665671
page_table_check_pte_clear(mm, pte);
666672

0 commit comments

Comments
 (0)