Both numa_init_array() and init_cpu_to_node() aim at setting up the cpu to
node map, so combining them. And the coming patch will set up node to
cpumask map in the combined function.

Signed-off-by: Pingfan Liu <kernelf...@gmail.com>
CC: Thomas Gleixner <t...@linutronix.de>
CC: Ingo Molnar <mi...@redhat.com>
CC: Borislav Petkov <b...@alien8.de>
CC: "H. Peter Anvin" <h...@zytor.com>
CC: Dave Hansen <dave.han...@linux.intel.com>
CC: Vlastimil Babka <vba...@suse.cz>
CC: Mike Rapoport <r...@linux.vnet.ibm.com>
CC: Andrew Morton <a...@linux-foundation.org>
CC: Mel Gorman <mgor...@suse.de>
CC: Joonsoo Kim <iamjoonsoo....@lge.com>
CC: Andy Lutomirski <l...@kernel.org>
CC: Andi Kleen <a...@linux.intel.com>
CC: Petr Tesarik <ptesa...@suse.cz>
CC: Michal Hocko <mho...@suse.com>
CC: Stephen Rothwell <s...@canb.auug.org.au>
CC: Jonathan Corbet <cor...@lwn.net>
CC: Nicholas Piggin <npig...@gmail.com>
CC: Daniel Vacek <ne...@redhat.com>
CC: linux-kernel@vger.kernel.org
---
 arch/x86/mm/numa.c | 39 +++++++++++++--------------------------
 1 file changed, 13 insertions(+), 26 deletions(-)

diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index bfe6732..c8dd7af 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -599,30 +599,6 @@ static int __init numa_register_memblks(struct 
numa_meminfo *mi)
        return 0;
 }
 
-#ifdef CONFIG_NUMA
-/*
- * There are unfortunately some poorly designed mainboards around that
- * only connect memory to a single CPU. This breaks the 1:1 cpu->node
- * mapping. To avoid this fill in the mapping for all possible CPUs,
- * as the number of CPUs is not known yet. We round robin the existing
- * nodes.
- */
-static void __init numa_init_array(void)
-{
-       int rr, i;
-
-       rr = first_node(node_online_map);
-       for (i = 0; i < nr_cpu_ids; i++) {
-               if (early_cpu_to_node(i) != NUMA_NO_NODE)
-                       continue;
-               numa_set_node(i, rr);
-               rr = next_node_in(rr, node_online_map);
-       }
-}
-#else
-static void __init numa_init_array(void) {}
-#endif
-
 static int __init numa_init(int (*init_func)(void))
 {
        int i;
@@ -675,7 +651,6 @@ static int __init numa_init(int (*init_func)(void))
                if (!node_online(nid))
                        numa_clear_node(i);
        }
-       numa_init_array();
 
        return 0;
 }
@@ -758,14 +733,26 @@ void __init init_cpu_to_node(void)
 {
        int cpu;
        u16 *cpu_to_apicid = early_per_cpu_ptr(x86_cpu_to_apicid);
+       int rr;
 
        BUG_ON(cpu_to_apicid == NULL);
+       rr = first_node(node_online_map);
 
        for_each_possible_cpu(cpu) {
                int node = numa_cpu_node(cpu);
 
-               if (node == NUMA_NO_NODE)
+               /*
+                * There are unfortunately some poorly designed mainboards
+                * around that only connect memory to a single CPU. This
+                * breaks the 1:1 cpu->node mapping. To avoid this fill in
+                * the mapping for all possible CPUs, as the number of CPUs
+                * is not known yet. We round robin the existing nodes.
+                */
+               if (node == NUMA_NO_NODE) {
+                       numa_set_node(cpu, rr);
+                       rr = next_node_in(rr, node_online_map);
                        continue;
+               }
 
                if (!node_online(node))
                        init_memory_less_node(node);
-- 
2.7.4

Reply via email to