OSDN Git Service

arm64: Add fallback option during memory hot add
authorArun KS <arunks@codeaurora.org>
Mon, 9 Oct 2017 11:09:57 +0000 (16:39 +0530)
committerArun KS <arunks@codeaurora.org>
Wed, 22 Nov 2017 11:43:04 +0000 (17:13 +0530)
Section mapping is good for TLB. But sometimes, when
system is low on physically continuous memory, this can
cause memory allocation failures. Add a fallback option to
allocate vmemmap pages from discontinuous pages.

Change-Id: Ide921c36c1e8980a8af047e2c991310405804858
Signed-off-by: Arun KS <arunks@codeaurora.org>
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
arch/arm64/mm/mmu.c

index 2b48e29..8c063d3 100644 (file)
@@ -1073,6 +1073,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node)
        pgd_t *pgd;
        pud_t *pud;
        pmd_t *pmd;
+       int ret = 0;
 
        do {
                next = pmd_addr_end(addr, end);
@@ -1090,15 +1091,23 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node)
                        void *p = NULL;
 
                        p = vmemmap_alloc_block_buf(PMD_SIZE, node);
-                       if (!p)
-                               return -ENOMEM;
+                       if (!p) {
+#ifdef CONFIG_MEMORY_HOTPLUG
+                               vmemmap_free(start, end);
+#endif
+                               ret = -ENOMEM;
+                               break;
+                       }
 
                        set_pmd(pmd, __pmd(__pa(p) | PROT_SECT_NORMAL));
                } else
                        vmemmap_verify((pte_t *)pmd, node, addr, next);
        } while (addr = next, addr != end);
 
-       return 0;
+       if (ret)
+               return vmemmap_populate_basepages(start, end, node);
+       else
+               return ret;
 }
 #endif /* CONFIG_ARM64_64K_PAGES */
 void vmemmap_free(unsigned long start, unsigned long end)