pagetable_free() now runs pagetable_dtor() for pages that have gone
through a page-table constructor, so pagetable_dtor_free() no longer
provides distinct behavior.

Use pagetable_free() directly at the remaining call sites and remove
the redundant helper. This keeps the decision to run the destructor in
the common free path.

Signed-off-by: Muchun Song <[email protected]>
---
 arch/m68k/include/asm/mcf_pgalloc.h |  4 ++--
 arch/m68k/mm/motorola.c             |  2 +-
 arch/s390/mm/pgalloc.c              |  4 ++--
 arch/sh/mm/pgtable.c                |  2 +-
 arch/x86/mm/pat/set_memory.c        | 10 +---------
 arch/x86/mm/pgtable.c               |  4 ++--
 include/asm-generic/pgalloc.h       | 12 ++++++------
 include/asm-generic/tlb.h           |  2 +-
 include/linux/mm.h                  |  6 ------
 9 files changed, 16 insertions(+), 30 deletions(-)

diff --git a/arch/m68k/include/asm/mcf_pgalloc.h 
b/arch/m68k/include/asm/mcf_pgalloc.h
index b53ff0950db2..27c3b91ac0b8 100644
--- a/arch/m68k/include/asm/mcf_pgalloc.h
+++ b/arch/m68k/include/asm/mcf_pgalloc.h
@@ -7,7 +7,7 @@
 
 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
 {
-       pagetable_dtor_free(virt_to_ptdesc(pte));
+       pagetable_free(virt_to_ptdesc(pte));
 }
 
 extern const char bad_pmd_string[];
@@ -74,7 +74,7 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t 
pgtable)
 
 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
 {
-       pagetable_dtor_free(virt_to_ptdesc(pgd));
+       pagetable_free(virt_to_ptdesc(pgd));
 }
 
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index f3efa0d13963..d4ad3ccb13b6 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -237,7 +237,7 @@ int free_pointer_table(void *table, int type)
                spin_unlock_bh(&ptable_lock);
 
                mmu_page_dtor((void *)pt_addr);
-               pagetable_dtor_free(virt_to_ptdesc((void *)pt_addr));
+               pagetable_free(virt_to_ptdesc((void *)pt_addr));
                return 1;
        } else if (ptable_list[type].next != dp) {
                /*
diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c
index 4b160eedc5a0..1b7061498adc 100644
--- a/arch/s390/mm/pgalloc.c
+++ b/arch/s390/mm/pgalloc.c
@@ -125,7 +125,7 @@ void page_table_free(struct mm_struct *mm, unsigned long 
*table)
 
        if (pagetable_is_reserved(ptdesc))
                return free_reserved_ptdesc(ptdesc);
-       pagetable_dtor_free(ptdesc);
+       pagetable_free(ptdesc);
 }
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -133,7 +133,7 @@ static void pte_free_now(struct rcu_head *head)
 {
        struct ptdesc *ptdesc = container_of(head, struct ptdesc, pt_rcu_head);
 
-       pagetable_dtor_free(ptdesc);
+       pagetable_free(ptdesc);
 }
 
 void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable)
diff --git a/arch/sh/mm/pgtable.c b/arch/sh/mm/pgtable.c
index f6184b86b89c..810730795358 100644
--- a/arch/sh/mm/pgtable.c
+++ b/arch/sh/mm/pgtable.c
@@ -64,7 +64,7 @@ static void __tlb_remove_table_slab(void *table)
 
 static void __tlb_remove_table_pgtable(void *table)
 {
-       pagetable_dtor_free(table);
+       pagetable_free(table);
 }
 
 void __tlb_remove_table(void *table)
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index b1d5c5a0ffb4..98c0a0d29769 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -441,15 +441,7 @@ static void __cpa_collapse_large_pages(struct cpa_data 
*cpa)
 
        list_for_each_entry_safe(ptdesc, tmp, &pgtables, pt_list) {
                list_del(&ptdesc->pt_list);
-               /*
-                * Only early alloc'd direct map should not be flagged PG_table
-                * here and those shouldn't be collapsed. However be abundantly
-                * cautious and handle the !PG_table case too.
-                */
-               if (PageTable((ptdesc_page(ptdesc))))
-                       pagetable_dtor_free(ptdesc);
-               else
-                       pagetable_free(ptdesc);
+               pagetable_free(ptdesc);
        }
 }
 
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 4a105f283cfb..81b3bb9a197a 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -732,7 +732,7 @@ int pud_free_pmd_page(pud_t *pud, unsigned long addr)
        for (i = 0; i < PTRS_PER_PMD; i++) {
                if (!pmd_none(pmd[i])) {
                        pt = page_ptdesc(pmd_page(pmd[i]));
-                       pagetable_dtor_free(pt);
+                       pagetable_free(pt);
                }
        }
 
@@ -759,7 +759,7 @@ int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
        /* INVLPG to clear all paging-structure caches */
        flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1);
 
-       pagetable_dtor_free(pt);
+       pagetable_free(pt);
 
        return 1;
 }
diff --git a/include/asm-generic/pgalloc.h b/include/asm-generic/pgalloc.h
index 051aa1331051..0ba651c1336d 100644
--- a/include/asm-generic/pgalloc.h
+++ b/include/asm-generic/pgalloc.h
@@ -54,7 +54,7 @@ static inline pte_t *pte_alloc_one_kernel_noprof(struct 
mm_struct *mm)
  */
 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
 {
-       pagetable_dtor_free(virt_to_ptdesc(pte));
+       pagetable_free(virt_to_ptdesc(pte));
 }
 
 /**
@@ -115,7 +115,7 @@ static inline void pte_free(struct mm_struct *mm, struct 
page *pte_page)
 {
        struct ptdesc *ptdesc = page_ptdesc(pte_page);
 
-       pagetable_dtor_free(ptdesc);
+       pagetable_free(ptdesc);
 }
 
 
@@ -162,7 +162,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t 
*pmd)
        struct ptdesc *ptdesc = virt_to_ptdesc(pmd);
 
        BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
-       pagetable_dtor_free(ptdesc);
+       pagetable_free(ptdesc);
 }
 #endif
 
@@ -213,7 +213,7 @@ static inline void __pud_free(struct mm_struct *mm, pud_t 
*pud)
        struct ptdesc *ptdesc = virt_to_ptdesc(pud);
 
        BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
-       pagetable_dtor_free(ptdesc);
+       pagetable_free(ptdesc);
 }
 
 #ifndef __HAVE_ARCH_PUD_FREE
@@ -261,7 +261,7 @@ static inline void __p4d_free(struct mm_struct *mm, p4d_t 
*p4d)
        struct ptdesc *ptdesc = virt_to_ptdesc(p4d);
 
        BUG_ON((unsigned long)p4d & (PAGE_SIZE-1));
-       pagetable_dtor_free(ptdesc);
+       pagetable_free(ptdesc);
 }
 
 #ifndef __HAVE_ARCH_P4D_FREE
@@ -300,7 +300,7 @@ static inline void __pgd_free(struct mm_struct *mm, pgd_t 
*pgd)
        struct ptdesc *ptdesc = virt_to_ptdesc(pgd);
 
        BUG_ON((unsigned long)pgd & (PAGE_SIZE-1));
-       pagetable_dtor_free(ptdesc);
+       pagetable_free(ptdesc);
 }
 
 #ifndef __HAVE_ARCH_PGD_FREE
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index fbe1114e9a44..b38b262bff5f 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -202,7 +202,7 @@ static inline void __tlb_remove_table(void *table)
 {
        struct ptdesc *ptdesc = (struct ptdesc *)table;
 
-       pagetable_dtor_free(ptdesc);
+       pagetable_free(ptdesc);
 }
 #endif
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index cb993a1d0728..26b1ad5998d9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4083,12 +4083,6 @@ static inline void pagetable_free(struct ptdesc *pt)
        }
 }
 
-static inline void pagetable_dtor_free(struct ptdesc *ptdesc)
-{
-       pagetable_dtor(ptdesc);
-       pagetable_free(ptdesc);
-}
-
 static inline bool pagetable_pte_ctor(struct mm_struct *mm,
                                      struct ptdesc *ptdesc)
 {
-- 
2.54.0


Reply via email to