[V2,4/6] arm64/mm: Call pgtable_page_dtor() for both PMD and PUD page table pages
diff mbox series

Message ID 1551071039-20192-5-git-send-email-anshuman.khandual@arm.com
State New
Headers show
  • arm64/mm: Enable accounting for page table pages
Related show

Commit Message

Anshuman Khandual Feb. 25, 2019, 5:03 a.m. UTC
TLB flush during PMD and PUD level page table page tear down currently does
not call pgtable_page_dtor() like that for PTE page table pages. Now that
all the page table pages which are allocated from the buddy allocator must
have been initialized through pgtable_page_ctor() they must be freed back
only after being called into pgtable_page_dtor() destructor. Else these
pages might run into bad page state errors while getting freed into buddy

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
 arch/arm64/include/asm/tlb.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff mbox series

diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index 106fdc951b6e..3ef2d7ffafee 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -62,6 +62,9 @@  static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte,
 static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
 				  unsigned long addr)
+	struct page *page = virt_to_page(pmdp);
+	pgtable_page_dtor(page);
 	tlb_remove_table(tlb, virt_to_page(pmdp));
@@ -70,6 +73,9 @@  static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
 static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pudp,
 				  unsigned long addr)
+	struct page *page = virt_to_page(pudp);
+	pgtable_page_dtor(page);
 	tlb_remove_table(tlb, virt_to_page(pudp));