[PATCH] x86, numa: refactoring numa_register_memblks

From: Yinghai Lu
Date: Wed Feb 16 2011 - 15:59:50 EST



Don't hide init_memory_mapping and setup_bootmem into that __register__ function

those are really work.

Also We don't need to scan two times for setup_node_bootmem() becase we
are using mapped memblock for node_data already.

let num_register_memblks only take care of register them into early_node_map[]

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>

---
arch/x86/mm/numa_64.c | 47 ++++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)

Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_64.c
+++ linux-2.6/arch/x86/mm/numa_64.c
@@ -491,7 +491,7 @@ static bool __init numa_meminfo_cover_me

static int __init numa_register_memblks(struct numa_meminfo *mi)
{
- int i, j, nid;
+ int i;

/* Account for nodes with cpus and no memory */
node_possible_map = numa_nodes_parsed;
@@ -515,33 +515,34 @@ static int __init numa_register_memblks(
if (!numa_meminfo_cover_memory(mi))
return -EINVAL;

- init_memory_mapping_high();
+ return 0;
+}
+
+static void __init setup_numa_bootmem(struct numa_meminfo *mi)
+{
+ int i, nid;

/*
- * Finally register nodes. Do it twice in case setup_node_bootmem
- * missed one due to missing bootmem.
+ * Do not do that twice, not needed!
+ * We are using mapped memblock directly for node data
*/
- for (i = 0; i < 2; i++) {
- for_each_node_mask(nid, node_possible_map) {
- u64 start = (u64)max_pfn << PAGE_SHIFT;
- u64 end = 0;
-
- if (node_online(nid))
- continue;
+ for_each_node_mask(nid, node_possible_map) {
+ u64 start = (u64)max_pfn << PAGE_SHIFT;
+ u64 end = 0;

- for (j = 0; j < mi->nr_blks; j++) {
- if (nid != mi->blk[j].nid)
- continue;
- start = min(mi->blk[j].start, start);
- end = max(mi->blk[j].end, end);
- }
+ if (node_online(nid))
+ continue;

- if (start < end)
- setup_node_bootmem(nid, start, end);
+ for (i = 0; i < mi->nr_blks; i++) {
+ if (nid != mi->blk[i].nid)
+ continue;
+ start = min(mi->blk[i].start, start);
+ end = max(mi->blk[i].end, end);
}
- }

- return 0;
+ if (start < end)
+ setup_node_bootmem(nid, start, end);
+ }
}

#ifdef CONFIG_NUMA_EMU
@@ -968,6 +969,10 @@ void __init initmem_init(void)
if (numa_register_memblks(&numa_meminfo) < 0)
continue;

+ init_memory_mapping_high();
+
+ setup_numa_bootmem(&numa_meminfo);
+
for (j = 0; j < nr_cpu_ids; j++) {
int nid = early_cpu_to_node(j);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/