|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 16/21] xen/arm: Balance Dom0 vCPU assignment across NUMA nodes
Configure the assignment of Dom0 vCPUs to NUMA nodes, aiming to balance
the compute load across the available nodes.
---
xen/arch/arm/domain_build.c | 46 +++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 1deb4c1139..a62adafa19 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1225,6 +1225,34 @@ int __init make_psci_node(void *fdt)
return res;
}
+/*
+ * Map a Dom0 vCPU ID to a target NUMA node ID.
+ */
+static nodeid_t __init dom0_vcpu_to_node(const struct domain *d, unsigned int
vcpu_id)
+{
+ nodeid_t nodes[MAX_NUMNODES];
+ unsigned int nr_nodes = 0;
+ unsigned int vcpus_per_node;
+ unsigned int node_idx;
+ nodeid_t n;
+
+ if ( nodes_empty(d->node_affinity) )
+ return 0;
+
+ for_each_node_mask(n, d->node_affinity)
+ nodes[nr_nodes++] = n;
+
+ if ( nr_nodes == 0 )
+ return 0;
+
+ vcpus_per_node = (d->max_vcpus + nr_nodes - 1) / nr_nodes;
+ node_idx = vcpu_id / vcpus_per_node;
+
+ ASSERT(node_idx < nr_nodes);
+
+ return nodes[node_idx];
+}
+
int __init make_cpus_node(const struct domain *d, struct kernel_info *kinfo)
{
int res;
@@ -1907,6 +1935,24 @@ int __init construct_domain(struct domain *d, struct
kernel_info *kinfo)
vcpu_switch_to_aarch64_mode(d->vcpu[i]);
}
+ /*
+ * If Dom0 has specific NUMA node affinity configured, bind each vCPU
+ * to its designated physical node.
+ */
+ for ( i = 0; i < d->max_vcpus; i++ )
+ {
+ struct vcpu *v = d->vcpu[i];
+ nodeid_t pnode;
+ const cpumask_t *nodemask;
+
+ if ( !v ) continue;
+
+ pnode = dom0_vcpu_to_node(d, i);
+ nodemask = &node_to_cpumask(pnode);
+
+ vcpu_set_hard_affinity(v, nodemask);
+ }
+
domain_update_node_affinity(d);
v->is_initialised = 1;
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |