diff mbox series

[RFC,v2,10/21] riscv: mm: Reimplement PTE A/D bit check function

Message ID 20241205103729.14798-11-luxu.kernel@bytedance.com (mailing list archive)
State New
Headers show
Series riscv: Introduce 64K base page | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR fail PR summary
conchuod/patch-10-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 209.87s
conchuod/patch-10-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 2558.38s
conchuod/patch-10-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 2944.70s
conchuod/patch-10-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 78.51s
conchuod/patch-10-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 80.58s
conchuod/patch-10-test-6 success .github/scripts/patches/tests/checkpatch.sh took 0.49s
conchuod/patch-10-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 48.53s
conchuod/patch-10-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.01s
conchuod/patch-10-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.64s
conchuod/patch-10-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-10-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.00s
conchuod/patch-10-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.04s
conchuod/vmtest-fixes-PR fail merge-conflict

Commit Message

Xu Lu Dec. 5, 2024, 10:37 a.m. UTC
CPU that supports only 4K MMU usually updates access/dirty bit at 4K pte
level. As each software page can contains multiple 4K hardware pages, we need
to traverse all mapping entries to check whether corresponding 4K page
is accessed or dirty during pte_dirty/pte_access functions.

Signed-off-by: Xu Lu <luxu.kernel@bytedance.com>
---
 arch/riscv/include/asm/pgtable.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index bf724d006236..c0f7442c8a9e 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -553,6 +553,29 @@  static inline int pte_huge(pte_t pte)
 	return pte_present(pte) && (pte_val(pte) & _PAGE_LEAF);
 }
 
+#ifdef CONFIG_RISCV_USE_SW_PAGE
+static inline int pte_dirty(pte_t pte)
+{
+	unsigned int i;
+
+	for (i = 0; i < HW_PAGES_PER_PAGE; i++)
+		if (pte.ptes[i] & _PAGE_DIRTY)
+			return 1;
+
+	return 0;
+}
+
+static inline int pte_young(pte_t pte)
+{
+	unsigned int i;
+
+	for (i = 0; i < HW_PAGES_PER_PAGE; i++)
+		if (pte.ptes[i] & _PAGE_ACCESSED)
+			return 1;
+
+	return 0;
+}
+#else
 static inline int pte_dirty(pte_t pte)
 {
 	return pte_val(pte) & _PAGE_DIRTY;
@@ -562,6 +585,7 @@  static inline int pte_young(pte_t pte)
 {
 	return pte_val(pte) & _PAGE_ACCESSED;
 }
+#endif /* CONFIG_RISCV_USE_SW_PAGE */
 
 static inline int pte_special(pte_t pte)
 {