[PATCH 1/2] Unify numa_memory_lookup_table allocation and setup.

Gustavo Sverzut Barbieri gsbarb at br.ibm.com
Thu Sep 29 04:10:25 EST 2005


Here are some patches to clean up lmb.c, numa.c and init.c, as requested by 
Dave Hansen.

This patch unify duplicated code under setup_numa_memory_lookup_table()

-- 
Gustavo Sverzut Barbieri
------------------------
LTC - Brazil
-------------- next part --------------
Subject: [PATCH 1/2] Unify numa_memory_lookup_table allocation and setup.

---

 arch/ppc64/mm/numa.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)

db3ba0826755c6213a94eeae53a55ef178e5418b
diff --git a/arch/ppc64/mm/numa.c b/arch/ppc64/mm/numa.c
--- a/arch/ppc64/mm/numa.c
+++ b/arch/ppc64/mm/numa.c
@@ -58,6 +58,18 @@ EXPORT_SYMBOL(numa_memory_lookup_table);
 EXPORT_SYMBOL(numa_cpumask_lookup_table);
 EXPORT_SYMBOL(nr_cpus_in_node);
 
+static inline void setup_numa_memory_lookup_table(void)
+{
+	long i;
+	long entries = lmb_end_of_DRAM() >> MEMORY_INCREMENT_SHIFT;
+
+	numa_memory_lookup_table =
+		(char *)abs_to_virt(lmb_alloc(entries * sizeof(char), 1));
+
+	for (i = 0; i < entries ; i++)
+		numa_memory_lookup_table[i] = ARRAY_INITIALISER;
+}
+
 static inline void map_cpu_to_node(int cpu, int node)
 {
 	numa_cpu_lookup_table[cpu] = node;
@@ -320,7 +332,6 @@ static int __init parse_numa_properties(
 	struct device_node *memory = NULL;
 	int addr_cells, size_cells;
 	int max_domain = 0;
-	long entries = lmb_end_of_DRAM() >> MEMORY_INCREMENT_SHIFT;
 	unsigned long i;
 
 	if (numa_enabled == 0) {
@@ -328,12 +339,7 @@ static int __init parse_numa_properties(
 		return -1;
 	}
 
-	numa_memory_lookup_table =
-		(char *)abs_to_virt(lmb_alloc(entries * sizeof(char), 1));
-	memset(numa_memory_lookup_table, 0, entries * sizeof(char));
-
-	for (i = 0; i < entries ; i++)
-		numa_memory_lookup_table[i] = ARRAY_INITIALISER;
+	setup_numa_memory_lookup_table();
 
 	min_common_depth = find_min_common_depth();
 
@@ -462,14 +468,8 @@ static void __init setup_nonnuma(void)
 	printk(KERN_INFO "Memory hole size: %ldMB\n",
 	       (top_of_ram - total_ram) >> 20);
 
-	if (!numa_memory_lookup_table) {
-		long entries = top_of_ram >> MEMORY_INCREMENT_SHIFT;
-		numa_memory_lookup_table =
-			(char *)abs_to_virt(lmb_alloc(entries * sizeof(char), 1));
-		memset(numa_memory_lookup_table, 0, entries * sizeof(char));
-		for (i = 0; i < entries ; i++)
-			numa_memory_lookup_table[i] = ARRAY_INITIALISER;
-	}
+	if (!numa_memory_lookup_table)
+		setup_numa_memory_lookup_table();
 
 	map_cpu_to_node(boot_cpuid, 0);
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20050928/a64dca09/attachment.pgp 


More information about the Linuxppc64-dev mailing list