]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - arch/x86/mm/numa_64.c
x86, numa: Use near(er) online node instead of roundrobin for NUMA
[net-next-2.6.git] / arch / x86 / mm / numa_64.c
index 3acd870d316a84533c219638638ed8ed77d428f1..83bbc70d11bb7a03754b88b432781fa142dffe9e 100644 (file)
@@ -764,6 +764,25 @@ static __init int numa_setup(char *opt)
 early_param("numa", numa_setup);
 
 #ifdef CONFIG_NUMA
+
+static __init int find_near_online_node(int node)
+{
+       int n, val;
+       int min_val = INT_MAX;
+       int best_node = -1;
+
+       for_each_online_node(n) {
+               val = node_distance(node, n);
+
+               if (val < min_val) {
+                       min_val = val;
+                       best_node = n;
+               }
+       }
+
+       return best_node;
+}
+
 /*
  * Setup early cpu_to_node.
  *
@@ -795,7 +814,7 @@ void __init init_cpu_to_node(void)
                if (node == NUMA_NO_NODE)
                        continue;
                if (!node_online(node))
-                       continue;
+                       node = find_near_online_node(node);
                numa_set_node(cpu, node);
        }
 }