|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/3] libxl: automatically set soft affinity after vnuma info
More specifically, vcpus are assigned to a vnode, which in
turn is associated with a pnode. If a vcpu does not have any
soft affinity, automatically build up one, matching the pcpus
of the said pnode.
Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
---
tools/libxl/libxl_dom.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index ace8a66..554ea68 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -439,6 +439,44 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
return rc;
}
+static int set_vnuma_affinity(libxl__gc *gc, uint32_t domid,
+ libxl_domain_build_info *info)
+{
+ libxl_bitmap cpumap;
+ libxl_vnode_info *v;
+ unsigned int i, j;
+ int rc = 0;
+
+ libxl_bitmap_init(&cpumap);
+
+ rc = libxl_cpu_bitmap_alloc(CTX, &cpumap, 0);
+ if (rc) {
+ LOG(ERROR, "Can't allocate nodemap");
+ goto out;
+ }
+
+ /*
+ * For each vcpu in each vnode, set its soft affinity to
+ * the pcpus belonging to the pnode the vnode is on
+ */
+ for (i = 0; i < info->num_vnuma_nodes; i++) {
+ v = &info->vnuma_nodes[i];
+
+ rc = libxl_node_to_cpumap(CTX, v->pnode, &cpumap);
+ if (rc) {
+ LOG(ERROR, "Can't get cpumap for vnode %d", i);
+ goto out;
+ }
+
+ libxl_for_each_set_bit(j, v->vcpus)
+ libxl_set_vcpuaffinity(CTX, domid, j, NULL, &cpumap);
+ }
+
+out:
+ libxl_bitmap_dispose(&cpumap);
+ return rc;
+}
+
int libxl__build_post(libxl__gc *gc, uint32_t domid,
libxl_domain_build_info *info,
libxl__domain_build_state *state,
@@ -450,6 +488,12 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid,
char **ents;
int i, rc;
+ if (info->num_vnuma_nodes && !info->num_vcpu_soft_affinity) {
+ rc = set_vnuma_affinity(gc, domid, info);
+ if (rc)
+ return rc;
+ }
+
rc = libxl_domain_sched_params_set(CTX, domid, &info->sched_params);
if (rc)
return rc;
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |