x86, mm: Separate x86_64 vmalloc_sync_all() into separate functions
authorHaicheng Li <haicheng.li@linux.intel.com>
Wed, 19 May 2010 09:42:14 +0000 (17:42 +0800)
committerH. Peter Anvin <hpa@linux.intel.com>
Thu, 26 Aug 2010 21:02:29 +0000 (14:02 -0700)
No behavior change.

Move some of vmalloc_sync_all() code into a new function
sync_global_pgds() that will be useful for memory hotplug.

Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
LKML-Reference: <4C6E4ECD.1090607@linux.intel.com>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/include/asm/pgtable_64.h
arch/x86/mm/fault.c
arch/x86/mm/init_64.c

index 076052cd62bef2d08af47a725ad3b187cd735be6..f96ac9bedf75db0ca247326ab580301832761d82 100644 (file)
@@ -102,6 +102,8 @@ static inline void native_pgd_clear(pgd_t *pgd)
        native_set_pgd(pgd, native_make_pgd(0));
 }
 
+extern void sync_global_pgds(unsigned long start, unsigned long end);
+
 /*
  * Conversion functions: convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
index 4c4508e8a2043015c1cce3eb49a46c0c435e9297..51f7ee71d6c716c7fb1868f5a7ecc8027ea30a86 100644 (file)
@@ -326,29 +326,7 @@ out:
 
 void vmalloc_sync_all(void)
 {
-       unsigned long address;
-
-       for (address = VMALLOC_START & PGDIR_MASK; address <= VMALLOC_END;
-            address += PGDIR_SIZE) {
-
-               const pgd_t *pgd_ref = pgd_offset_k(address);
-               unsigned long flags;
-               struct page *page;
-
-               if (pgd_none(*pgd_ref))
-                       continue;
-
-               spin_lock_irqsave(&pgd_lock, flags);
-               list_for_each_entry(page, &pgd_list, lru) {
-                       pgd_t *pgd;
-                       pgd = (pgd_t *)page_address(page) + pgd_index(address);
-                       if (pgd_none(*pgd))
-                               set_pgd(pgd, *pgd_ref);
-                       else
-                               BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
-               }
-               spin_unlock_irqrestore(&pgd_lock, flags);
-       }
+       sync_global_pgds(VMALLOC_START & PGDIR_MASK, VMALLOC_END);
 }
 
 /*
index 9a6674689a20f8e491f0a0f845079de9febaac5f..61a1b4fdecbf08c0bb238118fb595292834ec81c 100644 (file)
@@ -97,6 +97,36 @@ static int __init nonx32_setup(char *str)
 }
 __setup("noexec32=", nonx32_setup);
 
+/*
+ * When memory was added/removed make sure all the processes MM have
+ * suitable PGD entries in the local PGD level page.
+ */
+void sync_global_pgds(unsigned long start, unsigned long end)
+{
+       unsigned long address;
+
+       for (address = start; address <= end; address += PGDIR_SIZE) {
+              const pgd_t *pgd_ref = pgd_offset_k(address);
+              unsigned long flags;
+              struct page *page;
+
+              if (pgd_none(*pgd_ref))
+                      continue;
+
+              spin_lock_irqsave(&pgd_lock, flags);
+              list_for_each_entry(page, &pgd_list, lru) {
+                      pgd_t *pgd;
+                      pgd = (pgd_t *)page_address(page) + pgd_index(address);
+                      if (pgd_none(*pgd))
+                              set_pgd(pgd, *pgd_ref);
+                      else
+                              BUG_ON(pgd_page_vaddr(*pgd)
+                                       != pgd_page_vaddr(*pgd_ref));
+              }
+              spin_unlock_irqrestore(&pgd_lock, flags);
+       }
+}
+
 /*
  * NOTE: This function is marked __ref because it calls __init function
  * (alloc_bootmem_pages). It's safe to do it ONLY when after_bootmem == 0.