--- v4
+++ v9
@@ -1,74 +1,35 @@
-Currently, page table information is stored within struct page. As part
-of simplifying struct page, create struct ptdesc for page table
-information.
+Converts internal pmd_pgtable_page() callers to use pmd_ptdesc(). This
+removes some direct accesses to struct page, working towards splitting
+out struct ptdesc from struct page.
+Acked-by: Mike Rapoport (IBM) <rppt@kernel.org>
Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
- include/linux/pgtable.h | 51 +++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 51 insertions(+)
+ include/linux/mm.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
-diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
-index c5a51481bbb9..330de96ebfd6 100644
---- a/include/linux/pgtable.h
-+++ b/include/linux/pgtable.h
-@@ -975,6 +975,57 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma,
- #endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */
- #endif /* CONFIG_MMU */
+diff --git a/include/linux/mm.h b/include/linux/mm.h
+index 54dc176b90ea..f6d14a5fe747 100644
+--- a/include/linux/mm.h
++++ b/include/linux/mm.h
+@@ -2990,7 +2990,7 @@ static inline struct ptdesc *pmd_ptdesc(pmd_t *pmd)
-+
-+/**
-+ * struct ptdesc - Memory descriptor for page tables.
-+ * @__page_flags: Same as page flags. Unused for page tables.
-+ * @pt_list: List of used page tables. Used for s390 and x86.
-+ * @_pt_pad_1: Padding that aliases with page's compound head.
-+ * @pmd_huge_pte: Protected by ptdesc->ptl, used for THPs.
-+ * @_pt_s390_gaddr: Aliases with page's mapping. Used for s390 gmap only.
-+ * @pt_mm: Used for x86 pgds.
-+ * @pt_frag_refcount: For fragmented page table tracking. Powerpc and s390 only.
-+ * @ptl: Lock for the page table.
-+ *
-+ * This struct overlays struct page for now. Do not modify without a good
-+ * understanding of the issues.
-+ */
-+struct ptdesc {
-+ unsigned long __page_flags;
-+
-+ union {
-+ struct list_head pt_list;
-+ struct {
-+ unsigned long _pt_pad_1;
-+ pgtable_t pmd_huge_pte;
-+ };
-+ };
-+ unsigned long _pt_s390_gaddr;
-+
-+ union {
-+ struct mm_struct *pt_mm;
-+ atomic_t pt_frag_refcount;
-+ };
-+
-+#if ALLOC_SPLIT_PTLOCKS
-+ spinlock_t *ptl;
-+#else
-+ spinlock_t ptl;
-+#endif
-+};
-+
-+#define TABLE_MATCH(pg, pt) \
-+ static_assert(offsetof(struct page, pg) == offsetof(struct ptdesc, pt))
-+TABLE_MATCH(flags, __page_flags);
-+TABLE_MATCH(compound_head, pt_list);
-+TABLE_MATCH(compound_head, _pt_pad_1);
-+TABLE_MATCH(pmd_huge_pte, pmd_huge_pte);
-+TABLE_MATCH(mapping, _pt_s390_gaddr);
-+TABLE_MATCH(pt_mm, pt_mm);
-+TABLE_MATCH(ptl, ptl);
-+#undef TABLE_MATCH
-+static_assert(sizeof(struct ptdesc) <= sizeof(struct page));
-+
- /*
- * No-op macros that just return the current protection value. Defined here
- * because these macros can be used even if CONFIG_MMU is not defined.
+ static inline spinlock_t *pmd_lockptr(struct mm_struct *mm, pmd_t *pmd)
+ {
+- return ptlock_ptr(pmd_pgtable_page(pmd));
++ return ptlock_ptr(ptdesc_page(pmd_ptdesc(pmd)));
+ }
+
+ static inline bool pmd_ptlock_init(struct page *page)
+@@ -3009,7 +3009,7 @@ static inline void pmd_ptlock_free(struct page *page)
+ ptlock_free(page);
+ }
+
+-#define pmd_huge_pte(mm, pmd) (pmd_pgtable_page(pmd)->pmd_huge_pte)
++#define pmd_huge_pte(mm, pmd) (pmd_ptdesc(pmd)->pmd_huge_pte)
+
+ #else
+
--
2.40.1