]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ia64: 2.5.44 NUMA fixups
authorErich Focht <efocht@ess.nec.de>
Thu, 31 Oct 2002 13:49:00 +0000 (05:49 -0800)
committerDavid Mosberger <davidm@tiger.hpl.hp.com>
Thu, 31 Oct 2002 13:49:00 +0000 (05:49 -0800)
Dear David,

please find attached two patches for the latest 2.5.44-ia64. They fix
some problems and simplify things a bit.

remove_nodeid-2.5.44.patch:
This comes from Kimi. In 2.5.44 we suddenly had two definitions for
numa_node_id(), one was IA64 specific (local_cpu_data->nodeid) while
the other one is now platform independent:
__cpu_to_node(smp_processor_id()). After some discussions we decided
to remove the nodeid from the local_cpu_data and keep the definition of
all other platforms. With using the cpu_to_node_map[] we are also
faster when doing multiple lookups, as all node ids come in a single
cache line (which is not bounced around, as it's content is only
read).

ia64_topology_fixup-2.5.44.patch:
I'm following here the latest fixup for i386 from Matthew Dobson. The
__node_to_cpu_mask() macro now accesses an array which is initialized
after the ACPI CPU discovery. It also simplifies
__node_to_first_cpu(). A compiler warning has been fixed, too.

Please apply these to your kernel tree.

arch/ia64/kernel/setup.c
arch/ia64/kernel/smpboot.c
include/asm-ia64/numa.h
include/asm-ia64/processor.h
include/asm-ia64/topology.h

index db1479fd263679843519669a8c70746379967307..742fc9c03efb273cbf91acbfca963075c748ef96 100644 (file)
@@ -647,7 +647,6 @@ cpu_init (void)
        cpu_info = cpu_data + ((char *) &__get_cpu_var(cpu_info) - __per_cpu_start);
 #ifdef CONFIG_NUMA
        cpu_info->node_data = get_node_data_ptr();
-       cpu_info->nodeid = boot_get_local_nodeid();
 #endif
 
        /*
index a47810008ef8692deb9511abc90fbca6a07f1c8c..d3fac226d150d9d3dac9ee428095ec8dc0618ffe 100644 (file)
@@ -430,30 +430,39 @@ smp_build_cpu_map (void)
 
 #ifdef CONFIG_NUMA
 
-char cpu_to_node_map[NR_CPUS] __cacheline_aligned;
+/* on which node is each logical CPU (one cacheline even for 64 CPUs) */
+volatile char cpu_to_node_map[NR_CPUS] __cacheline_aligned;
+/* which logical CPUs are on which nodes */
+volatile unsigned long node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
 
 /*
- * Build cpu to node mapping.
+ * Build cpu to node mapping and initialize the per node cpu masks.
  */
 void __init
 build_cpu_to_node_map (void)
 {
-       int cpu, i;
+       int cpu, i, node;
 
+       for(node=0; node<MAX_NUMNODES; node++)
+               node_to_cpu_mask[node] = 0;
        for(cpu = 0; cpu < NR_CPUS; ++cpu) {
                /*
                 * All Itanium NUMA platforms I know use ACPI, so maybe we
                 * can drop this ifdef completely.                    [EF]
                 */
 #ifdef CONFIG_ACPI_NUMA
+               node = -1;
                for (i = 0; i < NR_CPUS; ++i)
                        if (cpu_physical_id(cpu) == node_cpuid[i].phys_id) {
-                               cpu_to_node_map[cpu] = node_cpuid[i].nid;
+                               node = node_cpuid[i].nid;
                                break;
                        }
 #else
 #              error Fixme: Dunno how to build CPU-to-node map.
 #endif
+               cpu_to_node_map[cpu] = node;
+               if (node >= 0)
+                       node_to_cpu_mask[node] |= (1UL << cpu);
        }
 }
 
index fa0ad42f3798fbeca72b0149ec7256d7a66e872a..df9160f89df0c5764ac17ac3e4477c7790a6c7c6 100644 (file)
@@ -21,7 +21,9 @@
 # define NR_MEMBLKS   (NR_NODES * 8)
 #endif
 
-extern char cpu_to_node_map[NR_CPUS] __cacheline_aligned;
+#include <linux/cache.h>
+extern volatile char cpu_to_node_map[NR_CPUS] __cacheline_aligned;
+extern volatile unsigned long node_to_cpu_mask[NR_NODES] __cacheline_aligned;
 
 /* Stuff below this line could be architecture independent */
 
index a2c030c261f1e00284a8f2d0a57870b1aa1695b0..f3ce4913ea2fc3880733dc0b72ba4c57f340b0f0 100644 (file)
@@ -179,7 +179,6 @@ struct cpuinfo_ia64 {
 #endif
 #ifdef CONFIG_NUMA
        struct ia64_node_data *node_data;
-       int nodeid;
 #endif
 };
 
@@ -192,10 +191,6 @@ DECLARE_PER_CPU(struct cpuinfo_ia64, cpu_info);
 #define local_cpu_data         (&__get_cpu_var(cpu_info))
 #define cpu_data(cpu)          (&per_cpu(cpu_info, cpu))
 
-#ifdef CONFIG_NUMA
-#define numa_node_id()         (local_cpu_data->nodeid)
-#endif
-
 extern void identify_cpu (struct cpuinfo_ia64 *);
 extern void print_cpu_info (struct cpuinfo_ia64 *);
 
index afb89ccd70884aa6d7a31d776e3e8bb60a3efc8b..8c64e194540df224a15d47e509e1b2fd8a79a3e6 100644 (file)
 
 #include <asm/acpi.h>
 #include <asm/numa.h>
+#include <asm/smp.h>
 
-/* Returns the number of the node containing CPU 'cpu' */
 #ifdef CONFIG_NUMA
-#define __cpu_to_node(cpu) cpu_to_node_map[cpu]
+/*
+ * Returns the number of the node containing CPU 'cpu'
+ */
+#define __cpu_to_node(cpu) (int)(cpu_to_node_map[cpu])
+
+/*
+ * Returns a bitmask of CPUs on Node 'node'.
+ */
+#define __node_to_cpu_mask(node) (node_to_cpu_mask[node])
+
 #else
 #define __cpu_to_node(cpu) (0)
+#define __node_to_cpu_mask(node) (phys_cpu_present_map)
 #endif
 
 /*
 
 /*
  * Returns the number of the first CPU on Node 'node'.
- * Slow in the current implementation.
- * Who needs this?
  */
-/* #define __node_to_first_cpu(node) pool_cpus[pool_ptr[node]] */
-static inline int __node_to_first_cpu(int node)
-{
-       int i;
-
-       for (i=0; i<NR_CPUS; i++)
-               if (__cpu_to_node(i)==node)
-                       return i;
-       BUG(); /* couldn't find a cpu on given node */
-       return -1;
-}
-
-/*
- * Returns a bitmask of CPUs on Node 'node'.
- */
-static inline unsigned long __node_to_cpu_mask(int node)
-{
-       int cpu;
-       unsigned long mask = 0UL;
-
-       for(cpu=0; cpu<NR_CPUS; cpu++)
-               if (__cpu_to_node(cpu) == node)
-                       mask |= 1UL << cpu;
-       return mask;
-}
+#define __node_to_first_cpu(node) (__ffs(__node_to_cpu_mask(node)))
 
 /*
  * Returns the number of the first MemBlk on Node 'node'