[PATCH] Trim careful_alocation()

Mike Kravetz kravetz at us.ibm.com
Thu Mar 31 06:42:07 EST 2005


The following patch removes the call to __alloc_bootmem_node() in
careful_allocation().  Note that careful_allocation is only called
in two places:
1) to allocate the node pglist_data structure
2) to allocate the bootmem map for the node
As such, calling __alloc_bootmem_node to allocate space for these
items makes no sense.  You can't use the bootmem allocator to create
the initial data structures for the bootmem allocator.

-- 
Signed-off-by: Mike Kravetz <kravetz at us.ibm.com>


diff -Naupr linux-2.6.12-rc1/arch/ppc64/mm/numa.c linux-2.6.12-rc1.work/arch/ppc64/mm/numa.c
--- linux-2.6.12-rc1/arch/ppc64/mm/numa.c	2005-03-02 07:38:38.000000000 +0000
+++ linux-2.6.12-rc1.work/arch/ppc64/mm/numa.c	2005-03-30 19:12:12.000000000 +0000
@@ -469,13 +469,13 @@ static void __init dump_numa_topology(vo
 }
 
 /*
- * Allocate some memory, satisfying the lmb or bootmem allocator where
- * required. nid is the preferred node and end is the physical address of
- * the highest address in the node.
+ * Allocate some memory via the lmb allocator while trying to allocate space
+ * close to, but less than the end parameter.  For 'node local' allocations
+ * end should be the highest physical address in the node.
  *
  * Returns the physical address of the memory.
  */
-static unsigned long careful_allocation(int nid, unsigned long size,
+static unsigned long careful_allocation(unsigned long size,
 					unsigned long align, unsigned long end)
 {
 	unsigned long ret = lmb_alloc_base(size, align, end);
@@ -485,26 +485,8 @@ static unsigned long careful_allocation(
 		ret = lmb_alloc_base(size, align, lmb_end_of_DRAM());
 
 	if (!ret)
-		panic("numa.c: cannot allocate %lu bytes on node %d",
-		      size, nid);
-
-	/*
-	 * If the memory came from a previously allocated node, we must
-	 * retry with the bootmem allocator.
-	 */
-	if (pa_to_nid(ret) < nid) {
-		nid = pa_to_nid(ret);
-		ret = (unsigned long)__alloc_bootmem_node(NODE_DATA(nid),
-				size, align, 0);
-
-		if (!ret)
-			panic("numa.c: cannot allocate %lu bytes on node %d",
-			      size, nid);
-
-		ret = virt_to_abs(ret);
-
-		dbg("alloc_bootmem %lx %lx\n", ret, size);
-	}
+		panic("numa.c: careful_allocation cannot allocate %lu bytes",
+		      size);
 
 	return ret;
 }
@@ -538,7 +520,7 @@ void __init do_init_bootmem(void)
 		end_paddr = start_paddr + (init_node_data[nid].node_spanned_pages * PAGE_SIZE);
 
 		/* Allocate the node structure node local if possible */
-		NODE_DATA(nid) = (struct pglist_data *)careful_allocation(nid,
+		NODE_DATA(nid) = (struct pglist_data *)careful_allocation(
 					sizeof(struct pglist_data),
 					SMP_CACHE_BYTES, end_paddr);
 		NODE_DATA(nid) = abs_to_virt(NODE_DATA(nid));
@@ -561,8 +543,7 @@ void __init do_init_bootmem(void)
 
 		bootmap_pages = bootmem_bootmap_pages((end_paddr - start_paddr) >> PAGE_SHIFT);
 
-		bootmem_paddr = careful_allocation(nid,
-				bootmap_pages << PAGE_SHIFT,
+		bootmem_paddr = careful_allocation(bootmap_pages << PAGE_SHIFT,
 				PAGE_SIZE, end_paddr);
 		memset(abs_to_virt(bootmem_paddr), 0,
 		       bootmap_pages << PAGE_SHIFT);



More information about the Linuxppc64-dev mailing list