[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 12/33] mm: Create ptdesc equivalents for pgtable_{pte,pmd}_page_{ctor,dtor}



Creates ptdesc_pte_ctor(), ptdesc_pmd_ctor(), ptdesc_pte_dtor(), and
ptdesc_pmd_dtor() and make the original pgtable constructor/destructors
wrappers.

Signed-off-by: Vishal Moola (Oracle) <vishal.moola@xxxxxxxxx>
---
 include/linux/mm.h | 56 ++++++++++++++++++++++++++++++++++------------
 1 file changed, 42 insertions(+), 14 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 17a64cfd1430..cb136d2fdf74 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2847,20 +2847,34 @@ static inline bool ptlock_init(struct ptdesc *ptdesc) { 
return true; }
 static inline void ptlock_free(struct ptdesc *ptdesc) {}
 #endif /* USE_SPLIT_PTE_PTLOCKS */
 
-static inline bool pgtable_pte_page_ctor(struct page *page)
+static inline bool ptdesc_pte_ctor(struct ptdesc *ptdesc)
 {
-       if (!ptlock_init(page_ptdesc(page)))
+       struct folio *folio = ptdesc_folio(ptdesc);
+
+       if (!ptlock_init(ptdesc))
                return false;
-       __SetPageTable(page);
-       inc_lruvec_page_state(page, NR_PAGETABLE);
+       __SetPageTable(&folio->page);
+       lruvec_stat_add_folio(folio, NR_PAGETABLE);
        return true;
 }
 
+static inline bool pgtable_pte_page_ctor(struct page *page)
+{
+       return ptdesc_pte_ctor(page_ptdesc(page));
+}
+
+static inline void ptdesc_pte_dtor(struct ptdesc *ptdesc)
+{
+       struct folio *folio = ptdesc_folio(ptdesc);
+
+       ptlock_free(ptdesc);
+       __ClearPageTable(&folio->page);
+       lruvec_stat_sub_folio(folio, NR_PAGETABLE);
+}
+
 static inline void pgtable_pte_page_dtor(struct page *page)
 {
-       ptlock_free(page_ptdesc(page));
-       __ClearPageTable(page);
-       dec_lruvec_page_state(page, NR_PAGETABLE);
+       ptdesc_pte_dtor(page_ptdesc(page));
 }
 
 #define pte_offset_map_lock(mm, pmd, address, ptlp)    \
@@ -2942,20 +2956,34 @@ static inline spinlock_t *pmd_lock(struct mm_struct 
*mm, pmd_t *pmd)
        return ptl;
 }
 
-static inline bool pgtable_pmd_page_ctor(struct page *page)
+static inline bool ptdesc_pmd_ctor(struct ptdesc *ptdesc)
 {
-       if (!pmd_ptlock_init(page_ptdesc(page)))
+       struct folio *folio = ptdesc_folio(ptdesc);
+
+       if (!pmd_ptlock_init(ptdesc))
                return false;
-       __SetPageTable(page);
-       inc_lruvec_page_state(page, NR_PAGETABLE);
+       __SetPageTable(&folio->page);
+       lruvec_stat_add_folio(folio, NR_PAGETABLE);
        return true;
 }
 
+static inline bool pgtable_pmd_page_ctor(struct page *page)
+{
+       return ptdesc_pmd_ctor(page_ptdesc(page));
+}
+
+static inline void ptdesc_pmd_dtor(struct ptdesc *ptdesc)
+{
+       struct folio *folio = ptdesc_folio(ptdesc);
+
+       pmd_ptlock_free(ptdesc);
+       __ClearPageTable(&folio->page);
+       lruvec_stat_sub_folio(folio, NR_PAGETABLE);
+}
+
 static inline void pgtable_pmd_page_dtor(struct page *page)
 {
-       pmd_ptlock_free(page_ptdesc(page));
-       __ClearPageTable(page);
-       dec_lruvec_page_state(page, NR_PAGETABLE);
+       ptdesc_pmd_dtor(page_ptdesc(page));
 }
 
 /*
-- 
2.39.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.