arm64: mm: Implement arch_wants_old_prefaulted_pte()
authorWill Deacon <will@kernel.org>
Tue, 24 Nov 2020 18:49:26 +0000 (18:49 +0000)
committerWill Deacon <will@kernel.org>
Wed, 20 Jan 2021 14:46:04 +0000 (14:46 +0000)
On CPUs with hardware AF/DBM, initialising prefaulted PTEs as 'old'
improves vmscan behaviour and does not appear to introduce any overhead
elsewhere.

Implement arch_wants_old_prefaulted_pte() to return 'true' if we detect
hardware access flag support at runtime. This can be extended in future
based on MIDR matching if necessary.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/pgtable.h

index 501562793ce26d855bf9ab620256a43c4522bff4..e17b96d0e4b59845f293cb3f3a050b90fc596520 100644 (file)
@@ -980,7 +980,17 @@ static inline bool arch_faults_on_old_pte(void)
 
        return !cpu_has_hw_af();
 }
-#define arch_faults_on_old_pte arch_faults_on_old_pte
+#define arch_faults_on_old_pte         arch_faults_on_old_pte
+
+/*
+ * Experimentally, it's cheap to set the access flag in hardware and we
+ * benefit from prefaulting mappings as 'old' to start with.
+ */
+static inline bool arch_wants_old_prefaulted_pte(void)
+{
+       return !arch_faults_on_old_pte();
+}
+#define arch_wants_old_prefaulted_pte  arch_wants_old_prefaulted_pte
 
 #endif /* !__ASSEMBLY__ */