powerpc/mm:: Cleanup careful_allocation(): bootmem already panics
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / powerpc / mm / numa.c
index cf81049e1e51a0ce98d0ebdf9b7a74d5901de211..aabf30175eb50db953a984191af324ed127a8e5d 100644 (file)
@@ -836,22 +836,26 @@ static void __init *careful_allocation(int nid, unsigned long size,
                ret = __lmb_alloc_base(size, align, lmb_end_of_DRAM());
 
        if (!ret)
-               panic("numa.c: cannot allocate %lu bytes on node %d",
+               panic("numa.c: cannot allocate %lu bytes for node %d",
                      size, nid);
 
        /*
-        * If the memory came from a previously allocated node, we must
-        * retry with the bootmem allocator.
+        * We initialize the nodes in numeric order: 0, 1, 2...
+        * and hand over control from the LMB allocator to the
+        * bootmem allocator.  If this function is called for
+        * node 5, then we know that all nodes <5 are using the
+        * bootmem allocator instead of the LMB allocator.
+        *
+        * So, check the nid from which this allocation came
+        * and double check to see if we need to use bootmem
+        * instead of the LMB.  We don't free the LMB memory
+        * since it would be useless.
         */
        new_nid = early_pfn_to_nid(ret >> PAGE_SHIFT);
        if (new_nid < nid) {
                ret = (unsigned long)__alloc_bootmem_node(NODE_DATA(new_nid),
                                size, align, 0);
 
-               if (!ret)
-                       panic("numa.c: cannot allocate %lu bytes on node %d",
-                             size, new_nid);
-
                ret = __pa(ret);
 
                dbg("alloc_bootmem %lx %lx\n", ret, size);