All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xen.org
Cc: Andrew.Cooper3@citrix.com, Wei Liu <wei.liu2@citrix.com>,
	Ian.Campbell@citrix.com, Ian.Jackson@citrix.com
Subject: [PATCH v11 3/5] xl: move the vcpu affinity parsing in a function
Date: Sat, 28 Jun 2014 02:35:54 +0200	[thread overview]
Message-ID: <20140628003554.29968.75547.stgit@Solace> (raw)
In-Reply-To: <20140628001809.29968.22845.stgit@Solace>

so that the same code can be shared for parsing also 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>
---
Chenges from v9:
 * this is still only code motion but, on the basis that the
  code being moved changed by quite a bit, I am not sticking
  the Acked-by  IanC provided during it.
---
 tools/libxl/xl_cmdimpl.c |   84 +++++++++++++++++++++++++---------------------
 1 file changed, 45 insertions(+), 39 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 5bd116b..5fa0a27 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -691,6 +691,49 @@ 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,
+                                libxl_domain_build_info *b_info,
+                                const char *buf, int num_cpus)
+{
+    /*
+     * If we are here, and buf is !NULL, we're dealing with a string. What
+     * we do in this case is parse it, and put the result in _all_ (up to
+     * b_info->max_vcpus) the elements of the vcpu affinity array.
+     *
+     * If buf is NULL, we have a list, and what we do is putting in the
+     * i-eth element of the vcpu affinity array the result of the parsing
+     * of the i-eth entry of the list. If there are more vcpus than
+     * entries, it is fine to just not touch the last array elements.
+     */
+    bool cpus_is_string = !!buf;
+    int j = 0;
+
+    if (num_cpus > b_info->max_vcpus || cpus_is_string)
+        num_cpus = b_info->max_vcpus;
+
+    b_info->vcpu_hard_affinity = xmalloc(num_cpus * sizeof(libxl_bitmap));
+
+    while (j < num_cpus && (cpus_is_string ||
+           (buf = xlu_cfg_get_listitem(cpus, j)) != NULL)) {
+        libxl_bitmap_init(&b_info->vcpu_hard_affinity[j]);
+
+        if (libxl_cpu_bitmap_alloc(ctx,
+                                   &b_info->vcpu_hard_affinity[j], 0)) {
+            fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", j);
+            exit(1);
+        }
+
+        if (vcpupin_parse(buf, &b_info->vcpu_hard_affinity[j]))
+            exit(1);
+
+        j++;
+    }
+    b_info->num_vcpu_hard_affinity = num_cpus;
+
+    /* We have a list of cpumaps, disable automatic placement */
+    libxl_defbool_set(&b_info->numa_placement, false);
+}
+
 static void parse_config_data(const char *config_source,
                               const char *config_data,
                               int config_len,
@@ -800,45 +843,8 @@ static void parse_config_data(const char *config_source,
 
     buf = NULL; num_cpus = 0;
     if (!xlu_cfg_get_list (config, "cpus", &cpus, &num_cpus, 1) ||
-        !xlu_cfg_get_string (config, "cpus", &buf, 0)) {
-        /*
-         * If we are here, and buf is !NULL, we're dealing with a string. What
-         * we do in this case is parse it, and put the result in _all_ (up to
-         * b_info->max_vcpus) the elements of the vcpu affinity array.
-         *
-         * If buf is NULL, we have a list, and what we do is putting in the
-         * i-eth element of the vcpu affinity array the result of the parsing
-         * of the i-eth entry of the list. If there are more vcpus than
-         * entries, it is fine to just not touch the last array elements.
-         */
-        bool cpus_is_string = !!buf;
-        int j = 0;
-
-        if (num_cpus > b_info->max_vcpus || cpus_is_string)
-            num_cpus = b_info->max_vcpus;
-
-        b_info->vcpu_hard_affinity = xmalloc(num_cpus * sizeof(libxl_bitmap));
-
-        while (j < num_cpus && (cpus_is_string ||
-               (buf = xlu_cfg_get_listitem(cpus, j)) != NULL)) {
-            libxl_bitmap_init(&b_info->vcpu_hard_affinity[j]);
-
-            if (libxl_cpu_bitmap_alloc(ctx,
-                                       &b_info->vcpu_hard_affinity[j], 0)) {
-                fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", j);
-                exit(1);
-            }
-
-            if (vcpupin_parse(buf, &b_info->vcpu_hard_affinity[j]))
-                exit(1);
-
-            j++;
-        }
-        b_info->num_vcpu_hard_affinity = num_cpus;
-
-        /* 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, b_info, buf, num_cpus);
 
     if (!xlu_cfg_get_long (config, "memory", &l, 0)) {
         b_info->max_memkb = l * 1024;

  parent reply	other threads:[~2014-06-28  0:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-28  0:35 [PATCH v11 0/5] Implement vcpu soft affinity for credit1 (toolstack side, leftover) Dario Faggioli
2014-06-28  0:35 ` [PATCH v11 1/5] xl: enable getting and setting soft affinity Dario Faggioli
2014-06-28  0:35 ` [PATCH v11 2/5] xl: move away from the use of cpumap for hard affinity Dario Faggioli
2014-07-02 15:06   ` Ian Campbell
2014-06-28  0:35 ` Dario Faggioli [this message]
2014-07-02 15:17   ` [PATCH v11 3/5] xl: move the vcpu affinity parsing in a function Ian Campbell
2014-06-28  0:36 ` [PATCH v11 4/5] libxl/xl: make it possible to specify soft-affinity in domain config file Dario Faggioli
2014-07-02 15:21   ` Ian Campbell
2014-06-28  0:36 ` [PATCH v11 5/5] 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=20140628003554.29968.75547.stgit@Solace \
    --to=dario.faggioli@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@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.