x86/mm: Avoid duplicated pxm_to_node() calls
authorYinghai Lu <yinghai@kernel.org>
Sun, 26 Jan 2014 21:01:42 +0000 (13:01 -0800)
committerIngo Molnar <mingo@kernel.org>
Sun, 9 Feb 2014 14:32:31 +0000 (15:32 +0100)
In slit init code, too many pxm_to_node() function calls are done.

We can store from_node/to_node instead of keep calling
pxm_to_node().

  - Before this patch: pxm_to_node() is called n*(1+n*3) times.
  - After  this patch: pxm_to_node() is called n*(1+n) times.

for  8 sockets, it will be   72 instead of  200.
for 32 sockets, it will be 1056 instead of 3104.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Toshi Kani <toshi.kani@hp.com>
Cc: David Rientjes <rientjes@google.com>
Link: http://lkml.kernel.org/r/1390770102-4007-1-git-send-email-yinghai@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/mm/srat.c

index 1953e9c9391aecf6ae4cddb4d65baae045fd2911..66338a60aa6ef961c6017731b6fd6d9d169736e1 100644 (file)
@@ -52,12 +52,18 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
        int i, j;
 
        for (i = 0; i < slit->locality_count; i++) {
-               if (pxm_to_node(i) == NUMA_NO_NODE)
+               const int from_node = pxm_to_node(i);
+
+               if (from_node == NUMA_NO_NODE)
                        continue;
+
                for (j = 0; j < slit->locality_count; j++) {
-                       if (pxm_to_node(j) == NUMA_NO_NODE)
+                       const int to_node = pxm_to_node(j);
+
+                       if (to_node == NUMA_NO_NODE)
                                continue;
-                       numa_set_distance(pxm_to_node(i), pxm_to_node(j),
+
+                       numa_set_distance(from_node, to_node,
                                slit->entry[slit->locality_count * i + j]);
                }
        }