@@ -23,9 +23,23 @@
#include <xen/numa.h>
#include <asm/acpi.h>
#include <xen/errno.h>
+#include <xen/cpumask.h>
int _node_distance[MAX_NUMNODES * 2];
int *node_distance;
+extern nodemask_t numa_nodes_parsed;
+
+void __init numa_set_cpu_node(int cpu, unsigned long hwid)
+{
+ unsigned node;
+
+ node = hwid >> 16 & 0xf;
+ if ( !node_isset(node, numa_nodes_parsed) || node == MAX_NUMNODES )
+ node = 0;
+
+ numa_set_node(cpu, node);
+ numa_add_cpu(cpu);
+}
u8 __node_distance(nodeid_t a, nodeid_t b)
{
@@ -37,6 +51,17 @@ u8 __node_distance(nodeid_t a, nodeid_t b)
EXPORT_SYMBOL(__node_distance);
+/*
+ * Setup early cpu_to_node.
+ */
+void __init init_cpu_to_node(void)
+{
+ int i;
+
+ for ( i = 0; i < nr_cpu_ids; i++ )
+ numa_set_node(i, 0);
+}
+
int __init numa_init(void)
{
int i, ret = 0;
@@ -749,6 +749,8 @@ void __init start_xen(unsigned long boot_phys_offset,
xen_paddr, xen_paddr + xen_bootmodule->size);
xen_bootmodule->start = xen_paddr;
+ init_cpu_to_node();
+
setup_mm(fdt_paddr, fdt_size);
/* Parse the ACPI tables for possible boot-time configuration */
@@ -30,6 +30,7 @@
#include <xen/irq.h>
#include <xen/console.h>
#include <asm/cpuerrata.h>
+#include <xen/numa.h>
#include <asm/gic.h>
#include <asm/psci.h>
#include <asm/acpi.h>
@@ -313,6 +314,8 @@ void start_secondary(unsigned long boot_phys_offset,
*/
smp_wmb();
+ numa_set_cpu_node(cpuid, hwid);
+
/* Now report this CPU is up */
cpumask_set_cpu(cpuid, &cpu_online_map);
@@ -2,16 +2,26 @@
#define __ARCH_ARM_NUMA_H
#include <xen/errno.h>
+#include <xen/cpumask.h>
typedef u8 nodeid_t;
#define NODES_SHIFT 2
#ifdef CONFIG_NUMA
+
+extern cpumask_t node_to_cpumask[];
+extern nodeid_t cpu_to_node[NR_CPUS];
+#define cpu_to_node(cpu) (cpu_to_node[cpu])
+#define parent_node(node) (node)
+#define node_to_first_cpu(node) (__ffs(node_to_cpumask[node]))
+#define node_to_cpumask(node) (node_to_cpumask[node])
+
int arch_numa_setup(char *opt);
int __init numa_init(void);
int __init dt_numa_init(void);
u8 __node_distance(nodeid_t a, nodeid_t b);
+void __init numa_set_cpu_node(int cpu, unsigned long hwid);
#else
static inline int arch_numa_setup(char *opt)
{
@@ -28,6 +38,11 @@ static inline int __init dt_numa_init(void)
return -EINVAL;
}
+static inline void __init numa_set_cpu_node(int cpu, unsigned long hwid)
+{
+ return;
+}
+
/* Fake one node for now. See also node_online_map. */
#define cpu_to_node(cpu) 0
#define node_to_cpumask(node) (cpu_online_map)