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
/*
#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);
}
}
# 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 */
#endif
#ifdef CONFIG_NUMA
struct ia64_node_data *node_data;
- int nodeid;
#endif
};
#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 *);
#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'