From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xen.org
Cc: keir@xen.org, Ian.Campbell@citrix.com, Andrew.Cooper3@citrix.com,
George.Dunlap@citrix.com, JBeulich@suse.com,
Ian.Jackson@citrix.com, Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH v8 11/13] xl: move the vcpu affinity parsing in a function
Date: Fri, 13 Jun 2014 15:10:36 +0200 [thread overview]
Message-ID: <20140613131036.4106.89927.stgit@Solace> (raw)
In-Reply-To: <20140613124847.4106.70161.stgit@Solace>
so that the same code can be shared for the parsing of the
soft affinity, being introduced in the next patch.
This is pure code motion, so no functional change intended,
and it is being done as a separate patch for the sake of
separating code motion from actual changes, i.e., for
facilitating reviews.
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
tools/libxl/xl_cmdimpl.c | 81 ++++++++++++++++++++++++----------------------
1 file changed, 43 insertions(+), 38 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index d9e235e..d08a149 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -692,6 +692,47 @@ static void parse_top_level_sdl_options(XLU_Config *config,
xlu_cfg_replace_string (config, "xauthority", &sdl->xauthority, 0);
}
+static void parse_vcpu_affinity(XLU_Config *config, XLU_ConfigList *cpus,
+ const char *buf, libxl_domain_build_info *info)
+{
+ info->num_vcpu_hard_affinity = info->max_vcpus;
+ const char *buf2;
+ int i;
+
+ info->vcpu_hard_affinity =
+ xmalloc(info->num_vcpu_hard_affinity * sizeof(libxl_bitmap));
+
+ for (i = 0; i < info->num_vcpu_hard_affinity; i++) {
+ libxl_bitmap_init(&info->vcpu_hard_affinity[i]);
+ if (libxl_cpu_bitmap_alloc(ctx, &info->vcpu_hard_affinity[i], 0)) {
+ fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", i);
+ exit(1);
+ }
+ libxl_bitmap_set_none(&info->vcpu_hard_affinity[i]);
+ }
+
+ /*
+ * When buf is !NULL, we've been passed a string, and what we do
+ * is parse it and put the result in all the entries of the vcpu
+ * affinity array. If it's NULL, what we have is a list, and what
+ * we put in each entry of the vcpu affinity array is the result of
+ * the parsing of each element of the list (if there are more
+ * vcpus than elements, the missing ones have their affinity masks
+ * completely full).
+ */
+ for (i = 0; i < info->num_vcpu_hard_affinity; i++) {
+ if (buf || ((buf2 = xlu_cfg_get_listitem(cpus, i)) != NULL)) {
+ if (vcpupin_parse(buf ? buf : buf2,
+ &info->vcpu_hard_affinity[i]))
+ exit(1);
+ } else
+ libxl_bitmap_set_any(&info->vcpu_hard_affinity[i]);
+ }
+
+ /* We have a list of cpumaps, disable automatic placement */
+ libxl_defbool_set(&info->numa_placement, false);
+}
+
static void parse_config_data(const char *config_source,
const char *config_data,
int config_len,
@@ -825,44 +866,8 @@ static void parse_config_data(const char *config_source,
buf = NULL;
if (!xlu_cfg_get_list (config, "cpus", &cpus, 0, 1) ||
- !xlu_cfg_get_string (config, "cpus", &buf, 0)) {
- b_info->num_vcpu_hard_affinity = b_info->max_vcpus;
- const char *buf2;
-
- b_info->vcpu_hard_affinity =
- xmalloc(b_info->num_vcpu_hard_affinity * sizeof(libxl_bitmap));
-
- for (i = 0; i < b_info->num_vcpu_hard_affinity; i++) {
- libxl_bitmap_init(&b_info->vcpu_hard_affinity[i]);
- if (libxl_cpu_bitmap_alloc(ctx,
- &b_info->vcpu_hard_affinity[i], 0)) {
- fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", i);
- exit(1);
- }
- libxl_bitmap_set_none(&b_info->vcpu_hard_affinity[i]);
- }
-
- /*
- * When buf is !NULL, we've been passed a string, and what we do
- * is parse it and put the result in all the entries of the vcpu
- * affinity array. If it's NULL, what we have is a list, and what
- * we put in each entry of the vcpu affinity array is the result of
- * the parsing of each element of the list (if there are more
- * vcpus than elements, the missing ones have their affinity masks
- * completely full).
- */
- for (i = 0; i < b_info->num_vcpu_hard_affinity; i++) {
- if (buf || ((buf2 = xlu_cfg_get_listitem(cpus, i)) != NULL)) {
- if (vcpupin_parse(buf ? buf : buf2,
- &b_info->vcpu_hard_affinity[i]))
- exit(1);
- } else
- libxl_bitmap_set_any(&b_info->vcpu_hard_affinity[i]);
- }
-
- /* We have a list of cpumaps, disable automatic placement */
- libxl_defbool_set(&b_info->numa_placement, false);
- }
+ !xlu_cfg_get_string (config, "cpus", &buf, 0))
+ parse_vcpu_affinity(config, cpus, buf, b_info);
if (!xlu_cfg_get_long (config, "memory", &l, 0)) {
b_info->max_memkb = l * 1024;
next prev parent reply other threads:[~2014-06-13 13:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-13 13:09 [PATCH v8 00/13] Implement vcpu soft affinity for credit1 Dario Faggioli
2014-06-13 13:09 ` [PATCH v8 01/13] xen: sched: rename v->cpu_affinity into v->cpu_hard_affinity Dario Faggioli
2014-06-13 13:09 ` [PATCH v8 02/13] xen: sched: introduce soft-affinity and use it instead d->node-affinity Dario Faggioli
2014-06-13 13:09 ` [PATCH v8 03/13] xen: derive NUMA node affinity from hard and soft CPU affinity Dario Faggioli
2014-06-13 13:09 ` [PATCH v8 04/13] xen/libxc: sched: DOMCTL_*vcpuaffinity works with hard and soft affinity Dario Faggioli
2014-06-13 13:09 ` [PATCH v8 05/13] libxc/libxl: bump library SONAMEs Dario Faggioli
2014-06-13 13:09 ` [PATCH v8 06/13] libxc: get and set soft and hard affinity Dario Faggioli
2014-06-13 13:10 ` [PATCH v8 07/13] libxl: get and set soft affinity Dario Faggioli
2014-06-13 13:10 ` [PATCH v8 08/13] xl: enable getting and setting " Dario Faggioli
2014-06-13 13:10 ` [PATCH v8 09/13] libxl/xl: push VCPU affinity pinning down to libxl Dario Faggioli
2014-06-13 13:25 ` Wei Liu
2014-06-17 10:09 ` Dario Faggioli
2014-06-13 13:10 ` [PATCH v8 10/13] libxl/xl: deprecate the build_info->cpumap field Dario Faggioli
2014-06-13 13:34 ` Wei Liu
2014-06-13 13:38 ` Ian Campbell
2014-06-17 10:11 ` Dario Faggioli
2014-06-13 13:49 ` Wei Liu
2014-06-17 9:59 ` Dario Faggioli
2014-06-17 10:16 ` Wei Liu
2014-06-17 10:29 ` Dario Faggioli
2014-06-17 10:45 ` Wei Liu
2014-06-13 13:10 ` Dario Faggioli [this message]
2014-06-13 13:10 ` [PATCH v8 12/13] xl: enable for specifying soft-affinity in the config file Dario Faggioli
2014-06-17 10:34 ` Wei Liu
2014-06-13 13:10 ` [PATCH v8 13/13] libxl: automatic NUMA placement affects soft affinity Dario Faggioli
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=20140613131036.4106.89927.stgit@Solace \
--to=dario.faggioli@citrix.com \
--cc=Andrew.Cooper3@citrix.com \
--cc=George.Dunlap@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--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.