Skip to content

Commit b9820d8

Browse files
Toshi Kanitorvalds
authored andcommitted
mm: change vunmap to tear down huge KVA mappings
Change vunmap_pmd_range() and vunmap_pud_range() to tear down huge KVA mappings when they are set. pud_clear_huge() and pmd_clear_huge() return zero when no-operation is performed, i.e. huge page mapping was not used. These changes are only enabled when CONFIG_HAVE_ARCH_HUGE_VMAP is defined on the architecture. [akpm@linux-foundation.org: use consistent code layout] Signed-off-by: Toshi Kani <toshi.kani@hp.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Robert Elliott <Elliott@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e61ce6a commit b9820d8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/asm-generic/pgtable.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ static inline int pmd_protnone(pmd_t pmd)
700700
#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
701701
int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot);
702702
int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot);
703+
int pud_clear_huge(pud_t *pud);
704+
int pmd_clear_huge(pmd_t *pmd);
703705
#else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
704706
static inline int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
705707
{
@@ -709,6 +711,14 @@ static inline int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
709711
{
710712
return 0;
711713
}
714+
static inline int pud_clear_huge(pud_t *pud)
715+
{
716+
return 0;
717+
}
718+
static inline int pmd_clear_huge(pmd_t *pmd)
719+
{
720+
return 0;
721+
}
712722
#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
713723

714724
#endif /* !__ASSEMBLY__ */

mm/vmalloc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ static void vunmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end)
7575
pmd = pmd_offset(pud, addr);
7676
do {
7777
next = pmd_addr_end(addr, end);
78+
if (pmd_clear_huge(pmd))
79+
continue;
7880
if (pmd_none_or_clear_bad(pmd))
7981
continue;
8082
vunmap_pte_range(pmd, addr, next);
@@ -89,6 +91,8 @@ static void vunmap_pud_range(pgd_t *pgd, unsigned long addr, unsigned long end)
8991
pud = pud_offset(pgd, addr);
9092
do {
9193
next = pud_addr_end(addr, end);
94+
if (pud_clear_huge(pud))
95+
continue;
9296
if (pud_none_or_clear_bad(pud))
9397
continue;
9498
vunmap_pmd_range(pud, addr, next);

0 commit comments

Comments
 (0)