x86/mm/hotplug: Don't remove PGD entries in remove_pagetable()
authorIngo Molnar <[email protected]>
Thu, 14 Jul 2016 20:22:49 +0000 (13:22 -0700)
committerIngo Molnar <[email protected]>
Fri, 15 Jul 2016 08:26:24 +0000 (10:26 +0200)
So when memory hotplug removes a piece of physical memory from pagetable
mappings, it also frees the underlying PGD entry.

This complicates PGD management, so don't do this. We can keep the
PGD mapped and the PUD table all clear - it's only a single 4K page
per 512 GB of memory hotplugged.

Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Andy Lutomirski <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Waiman Long <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/064ff6c7275734537f969e876f6cd0baa954d2cc.1468527351.git.luto@kernel.org
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/mm/init_64.c

index bb88fbc0a2886d18d71cbcf65f994f90a92b0973..e14f87057c3f807a49faf45d5259fdfff18cf7dd 100644 (file)
@@ -702,27 +702,6 @@ static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud)
        spin_unlock(&init_mm.page_table_lock);
 }
 
-/* Return true if pgd is changed, otherwise return false. */
-static bool __meminit free_pud_table(pud_t *pud_start, pgd_t *pgd)
-{
-       pud_t *pud;
-       int i;
-
-       for (i = 0; i < PTRS_PER_PUD; i++) {
-               pud = pud_start + i;
-               if (!pud_none(*pud))
-                       return false;
-       }
-
-       /* free a pud table */
-       free_pagetable(pgd_page(*pgd), 0);
-       spin_lock(&init_mm.page_table_lock);
-       pgd_clear(pgd);
-       spin_unlock(&init_mm.page_table_lock);
-
-       return true;
-}
-
 static void __meminit
 remove_pte_table(pte_t *pte_start, unsigned long addr, unsigned long end,
                 bool direct)
@@ -913,7 +892,6 @@ remove_pagetable(unsigned long start, unsigned long end, bool direct)
        unsigned long addr;
        pgd_t *pgd;
        pud_t *pud;
-       bool pgd_changed = false;
 
        for (addr = start; addr < end; addr = next) {
                next = pgd_addr_end(addr, end);
@@ -924,13 +902,8 @@ remove_pagetable(unsigned long start, unsigned long end, bool direct)
 
                pud = (pud_t *)pgd_page_vaddr(*pgd);
                remove_pud_table(pud, addr, next, direct);
-               if (free_pud_table(pud, pgd))
-                       pgd_changed = true;
        }
 
-       if (pgd_changed)
-               sync_global_pgds(start, end - 1, 1);
-
        flush_tlb_all();
 }