[RFC PATCH 10/12] mm: add default definition of p4d_index()
Ard Biesheuvel
ardb at kernel.org
Wed Jan 26 09:30:09 PST 2022
Implement a default version of p4d_index() similar to how pud/pmd_index
are defined.
Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
include/linux/pgtable.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index bc8713a76e03..e8aacf6ea207 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -79,6 +79,14 @@ static inline unsigned long pud_index(unsigned long address)
#define pud_index pud_index
#endif
+#ifndef p4d_index
+static inline unsigned long p4d_index(unsigned long address)
+{
+ return (address >> P4D_SHIFT) & (PTRS_PER_P4D - 1);
+}
+#define p4d_index p4d_index
+#endif
+
#ifndef pgd_index
/* Must be a compile-time constant, so implement it as a macro */
#define pgd_index(a) (((a) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
--
2.30.2
More information about the linux-arm-kernel
mailing list