@@ -46,6 +46,7 @@ extern void numa_set_distance(nodeid_t from, nodeid_t to,
extern void numa_detect_cpu_node(unsigned int cpu);
extern int numa_device_tree_init(const void *fdt);
extern void numa_init(void);
+extern void numa_set_cpu_core_mask(int cpu);
/*
* Device tree NUMA doesn't have architecural node id.
@@ -62,6 +63,12 @@ static inline unsigned int numa_node_to_arch_nid(nodeid_t n)
#define cpu_to_node(cpu) 0
#define node_to_cpumask(node) (cpu_online_map)
+static inline void numa_set_cpu_core_mask(int cpu)
+{
+ cpumask_or(per_cpu(cpu_core_mask, cpu),
+ per_cpu(cpu_core_mask, cpu), &cpu_possible_map);
+}
+
/*
* TODO: make first_valid_mfn static when NUMA is supported on Arm, this
* is required because the dummy helpers are using it.
@@ -52,6 +52,17 @@ int __init arch_numa_setup(const char *opt)
return -EINVAL;
}
+void numa_set_cpu_core_mask(int cpu)
+{
+ nodeid_t node = cpu_to_node[cpu];
+
+ if ( node == NUMA_NO_NODE )
+ node = 0;
+
+ cpumask_or(per_cpu(cpu_core_mask, cpu),
+ per_cpu(cpu_core_mask, cpu), &node_to_cpumask(node));
+}
+
void __init numa_set_distance(nodeid_t from, nodeid_t to,
unsigned int distance)
{
@@ -1136,6 +1136,11 @@ void __init start_xen(unsigned long boot_phys_offset,
}
printk("Brought up %ld CPUs\n", (long)num_online_cpus());
+
+ /* Set per-cpu cpu_core_mask to cpus that belongs to the same NUMA node. */
+ for_each_online_cpu ( i )
+ numa_set_cpu_core_mask(i);
+
/* TODO: smp_cpus_done(); */
/* This should be done in a vpmu driver but we do not have one yet. */