Skip to content

Commit 28ee90f

Browse files
toshikanitorvalds
authored andcommitted
x86/mm: implement free pmd/pte page interfaces
Implement pud_free_pmd_page() and pmd_free_pte_page() on x86, which clear a given pud/pmd entry and free up lower level page table(s). The address range associated with the pud/pmd entry must have been purged by INVLPG. Link: http://lkml.kernel.org/r/20180314180155.19492-3-toshi.kani@hpe.com Fixes: e61ce6a ("mm: change ioremap to set up huge I/O mappings") Signed-off-by: Toshi Kani <toshi.kani@hpe.com> Reported-by: Lei Li <lious.lilei@hisilicon.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Borislav Petkov <bp@suse.de> Cc: Matthew Wilcox <willy@infradead.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b6bdb75 commit 28ee90f

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

arch/x86/mm/pgtable.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,22 @@ int pmd_clear_huge(pmd_t *pmd)
712712
*/
713713
int pud_free_pmd_page(pud_t *pud)
714714
{
715-
return pud_none(*pud);
715+
pmd_t *pmd;
716+
int i;
717+
718+
if (pud_none(*pud))
719+
return 1;
720+
721+
pmd = (pmd_t *)pud_page_vaddr(*pud);
722+
723+
for (i = 0; i < PTRS_PER_PMD; i++)
724+
if (!pmd_free_pte_page(&pmd[i]))
725+
return 0;
726+
727+
pud_clear(pud);
728+
free_page((unsigned long)pmd);
729+
730+
return 1;
716731
}
717732

718733
/**
@@ -724,6 +739,15 @@ int pud_free_pmd_page(pud_t *pud)
724739
*/
725740
int pmd_free_pte_page(pmd_t *pmd)
726741
{
727-
return pmd_none(*pmd);
742+
pte_t *pte;
743+
744+
if (pmd_none(*pmd))
745+
return 1;
746+
747+
pte = (pte_t *)pmd_page_vaddr(*pmd);
748+
pmd_clear(pmd);
749+
free_page((unsigned long)pte);
750+
751+
return 1;
728752
}
729753
#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */

0 commit comments

Comments
 (0)