[PATCH v3 11/22] riscv: mm: Simplify set_p4d() and set_pgd()
Samuel Holland
samuel.holland at sifive.com
Wed Nov 12 17:45:24 PST 2025
RISC-V uses the same page table entry format and has the same atomicity
requirements at all page table levels, so these setter functions use the
same underlying implementation at all levels. Checking the translation
mode to pick between two identical branches only serves to make these
functions less efficient.
Signed-off-by: Samuel Holland <samuel.holland at sifive.com>
---
(no changes since v2)
Changes in v2:
- New patch for v2
arch/riscv/include/asm/pgtable-64.h | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h
index 6e789fa58514..5532f8515450 100644
--- a/arch/riscv/include/asm/pgtable-64.h
+++ b/arch/riscv/include/asm/pgtable-64.h
@@ -275,10 +275,7 @@ static inline unsigned long _pmd_pfn(pmd_t pmd)
static inline void set_p4d(p4d_t *p4dp, p4d_t p4d)
{
- if (pgtable_l4_enabled)
- WRITE_ONCE(*p4dp, p4d);
- else
- set_pud((pud_t *)p4dp, (pud_t){ p4d_val(p4d) });
+ WRITE_ONCE(*p4dp, p4d);
}
static inline int p4d_none(p4d_t p4d)
@@ -342,10 +339,7 @@ pud_t *pud_offset(p4d_t *p4d, unsigned long address);
static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
{
- if (pgtable_l5_enabled)
- WRITE_ONCE(*pgdp, pgd);
- else
- set_p4d((p4d_t *)pgdp, (p4d_t){ pgd_val(pgd) });
+ WRITE_ONCE(*pgdp, pgd);
}
static inline int pgd_none(pgd_t pgd)
--
2.47.2
More information about the linux-riscv
mailing list