From: Dario Faggioli <dario.faggioli@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 2/3] libxl: automatically set soft affinity after vnuma info
Date: Tue, 24 Mar 2015 14:42:15 +0100 [thread overview]
Message-ID: <20150324134155.10874.85362.stgit@Solace.station> (raw)
In-Reply-To: <20150324132630.10874.78040.stgit@Solace.station>
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@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
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;
next prev parent reply other threads:[~2015-03-24 13:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-24 13:41 [PATCH 0/3] Automatically derive soft affinity from vnuma information Dario Faggioli
2015-03-24 13:41 ` [PATCH 1/3] libxl: check whether vcpu affinity and vnuma info match Dario Faggioli
2015-03-24 14:41 ` Wei Liu
2015-03-24 15:47 ` Dario Faggioli
2015-03-24 15:56 ` Wei Liu
2015-03-24 13:42 ` Dario Faggioli [this message]
2015-03-24 14:32 ` [PATCH 2/3] libxl: automatically set soft affinity after vnuma info Wei Liu
2015-03-24 15:06 ` Dario Faggioli
2015-03-24 15:23 ` Wei Liu
2015-03-24 13:42 ` [PATCH 3/3] libxl: cleanup some misuse of 'cpumap' as parameter Dario Faggioli
2015-03-24 14:33 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150324134155.10874.85362.stgit@Solace.station \
--to=dario.faggioli@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.