xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Marcus Granado <Marcus.Granado@eu.citrix.com>,
	Keir Fraser <keir@xen.org>, Matt Wilson <msw@amazon.com>,
	Li Yechen <lccycc123@gmail.com>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	Juergen Gross <juergen.gross@ts.fujitsu.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	xen-devel@lists.xen.org, Jan Beulich <JBeulich@suse.com>,
	Justin Weaver <jtweaver@hawaii.edu>,
	Elena Ufimtseva <ufimtseva@gmail.com>
Subject: Re: [PATCH v3 13/14] xl: enable for specifying node-affinity in the config file
Date: Tue, 19 Nov 2013 17:35:23 +0000	[thread overview]
Message-ID: <1384882523.16252.56.camel@hastur.hellion.org.uk> (raw)
In-Reply-To: <20131118181832.31002.47383.stgit@Solace>

On Mon, 2013-11-18 at 19:18 +0100, Dario Faggioli wrote:
> in a similar way to how it is possible to specify vcpu-affinity.
> 
> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
> ---
> Changes from v2:
>  * use the new libxl API. Although the implementation changed
>    only a little bit, I removed IanJ's Acked-by, although I am
>    here saying that he did provided it, as requested.
> ---
>  docs/man/xl.cfg.pod.5    |   27 ++++++++++++++--
>  tools/libxl/libxl_dom.c  |    3 +-
>  tools/libxl/xl_cmdimpl.c |   79 +++++++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 103 insertions(+), 6 deletions(-)
> 
> diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
> index 5dbc73c..733c74e 100644
> --- a/docs/man/xl.cfg.pod.5
> +++ b/docs/man/xl.cfg.pod.5
> @@ -144,19 +144,40 @@ run on cpu #3 of the host.
>  =back
>  
>  If this option is not specified, no vcpu to cpu pinning is established,
> -and the vcpus of the guest can run on all the cpus of the host.
> +and the vcpus of the guest can run on all the cpus of the host. If this
> +option is specified, the intersection of the vcpu pinning mask, provided
> +here, and the soft affinity mask, provided via B<cpus\_soft=> (if any),
> +is utilized to compute the domain node-affinity, for driving memory
> +allocations.
>  
>  If we are on a NUMA machine (i.e., if the host has more than one NUMA
>  node) and this option is not specified, libxl automatically tries to
>  place the guest on the least possible number of nodes. That, however,
>  will not affect vcpu pinning, so the guest will still be able to run on
> -all the cpus, it will just prefer the ones from the node it has been
> -placed on. A heuristic approach is used for choosing the best node (or
> +all the cpus. A heuristic approach is used for choosing the best node (or
>  set of nodes), with the goals of maximizing performance for the guest
>  and, at the same time, achieving efficient utilization of host cpus
>  and memory. See F<docs/misc/xl-numa-placement.markdown> for more
>  details.
>  
> +=item B<cpus_soft="CPU-LIST">
> +
> +Exactly as B<cpus=>, but specifies soft affinity, rather than pinning
> +(also called hard affinity). Starting from Xen 4.4, and if the credit

I don't think we need to reference particular versions in what is
effectively the manpage which comes with that version.

> +scheduler is used, this means the vcpus of the domain prefers to run
> +these pcpus. Default is either all pcpus or xl (via libxl) guesses
> +(depending on what other options are present).

No need to mention libxl here. TBH I would either document what the
other options which affect the guess are or not mention it at all, as it
stands the sentence doesn't tell me anything very useful.

> +
> +A C<CPU-LIST> is specified exactly as above, for B<cpus=>.
> +
> +If this option is not specified, the vcpus of the guest will not have
> +any preference regarding on what cpu to run, and the scheduler will
> +treat all the cpus where a vcpu can execute (if B<cpus=> is specified),
> +or all the host cpus (if not), the same. If this option is specified,
> +the intersection of the soft affinity mask, provided here, and the vcpu
> +pinning, provided via B<cpus=> (if any), is utilized to compute the
> +domain node-affinity, for driving memory allocations.
> +
>  =back
>  
>  =head3 CPU Scheduling
> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index a1c16b0..ceb37a3 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -236,7 +236,8 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
>              return rc;
>      }
>      libxl_domain_set_nodeaffinity(ctx, domid, &info->nodemap);
> -    libxl_set_vcpuaffinity_all(ctx, domid, info->max_vcpus, &info->cpumap);
> +    libxl_set_vcpuaffinity_all3(ctx, domid, info->max_vcpus, &info->cpumap,
> +                                &info->cpumap_soft);
>  
>      xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT);
>      xs_domid = xs_read(ctx->xsh, XBT_NULL, "/tool/xenstored/domid", NULL);
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index d5c4eb1..660bb1f 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -76,8 +76,9 @@ xlchild children[child_max];
>  static const char *common_domname;
>  static int fd_lock = -1;
>  
> -/* Stash for specific vcpu to pcpu mappping */
> +/* Stash for specific vcpu to pcpu hard and soft mappping */
>  static int *vcpu_to_pcpu;
> +static int *vcpu_to_pcpu_soft;
>  
>  static const char savefileheader_magic[32]=
>      "Xen saved domain, xl format\n \0 \r";
> @@ -647,7 +648,8 @@ static void parse_config_data(const char *config_source,
>      const char *buf;
>      long l;
>      XLU_Config *config;
> -    XLU_ConfigList *cpus, *vbds, *nics, *pcis, *cvfbs, *cpuids, *vtpms;
> +    XLU_ConfigList *cpus, *cpus_soft, *vbds, *nics, *pcis;
> +    XLU_ConfigList *cvfbs, *cpuids, *vtpms;
>      XLU_ConfigList *ioports, *irqs, *iomem;
>      int num_ioports, num_irqs, num_iomem;
>      int pci_power_mgmt = 0;
> @@ -824,6 +826,50 @@ static void parse_config_data(const char *config_source,
>          libxl_defbool_set(&b_info->numa_placement, false);
>      }
>  
> +    if (!xlu_cfg_get_list (config, "cpus_soft", &cpus_soft, 0, 1)) {

How much of this block duplicates the parsing of the pinning field? Can
it be refactored?

> +        int n_cpus = 0;
> +
> +        if (libxl_node_bitmap_alloc(ctx, &b_info->cpumap_soft, 0)) {
> +            fprintf(stderr, "Unable to allocate cpumap_soft\n");
> +            exit(1);
> +        }
> +
> +        /* As above, use a temporary storage for the single affinities */

"use temporary storage..." (the "a" is redundant/sounds wierd)

> +        vcpu_to_pcpu_soft = xmalloc(sizeof(int) * b_info->max_vcpus);
> +        memset(vcpu_to_pcpu_soft, -1, sizeof(int) * b_info->max_vcpus);
> +
> +        libxl_bitmap_set_none(&b_info->cpumap_soft);
> +        while ((buf = xlu_cfg_get_listitem(cpus_soft, n_cpus)) != NULL) {
> +            i = atoi(buf);
> +            if (!libxl_bitmap_cpu_valid(&b_info->cpumap_soft, i)) {
> +                fprintf(stderr, "cpu %d illegal\n", i);
> +                exit(1);
> +            }
> +            libxl_bitmap_set(&b_info->cpumap_soft, i);
> +            if (n_cpus < b_info->max_vcpus)
> +                vcpu_to_pcpu_soft[n_cpus] = i;
> +            n_cpus++;
> +        }
> +
> +        /* We have a soft affinity map, disable automatic placement */
> +        libxl_defbool_set(&b_info->numa_placement, false);
> +    }
> +    else if (!xlu_cfg_get_string (config, "cpus_soft", &buf, 0)) {
> +        char *buf2 = strdup(buf);
> +
> +        if (libxl_node_bitmap_alloc(ctx, &b_info->cpumap_soft, 0)) {
> +            fprintf(stderr, "Unable to allocate cpumap_soft\n");
> +            exit(1);
> +        }
> +
> +        libxl_bitmap_set_none(&b_info->cpumap_soft);
> +        if (vcpupin_parse(buf2, &b_info->cpumap_soft))
> +            exit(1);
> +        free(buf2);
> +
> +        libxl_defbool_set(&b_info->numa_placement, false);
> +    }
> +
>      if (!xlu_cfg_get_long (config, "memory", &l, 0)) {
>          b_info->max_memkb = l * 1024;
>          b_info->target_memkb = b_info->max_memkb;
> @@ -2183,6 +2229,35 @@ start:
>          free(vcpu_to_pcpu); vcpu_to_pcpu = NULL;
>      }
>  
> +    /* And do the same for single vcpu to soft-affinity mapping */

Another option to refactor common code then?

  reply	other threads:[~2013-11-19 17:35 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-18 18:16 [PATCH v3 00/14] Series short description Dario Faggioli
2013-11-18 18:16 ` [PATCH v3 01/14] xl: match output of vcpu-list with pinning syntax Dario Faggioli
2013-11-18 18:16 ` [PATCH v3 02/14] libxl: sanitize error handling in libxl_get_max_{cpus, nodes} Dario Faggioli
2013-11-19 12:24   ` George Dunlap
2013-11-19 12:34     ` Dario Faggioli
2013-11-18 18:16 ` [PATCH v3 03/14] xl: allow for node-wise specification of vcpu pinning Dario Faggioli
2013-11-18 18:17 ` [PATCH v3 04/14] xl: implement and enable dryrun mode for `xl vcpu-pin' Dario Faggioli
2013-11-18 18:17 ` [PATCH v3 05/14] xl: test script for the cpumap parser (for vCPU pinning) Dario Faggioli
2013-11-18 18:17 ` [PATCH v3 06/14] xen: sched: rename v->cpu_affinity into v->cpu_hard_affinity Dario Faggioli
2013-11-18 18:17 ` [PATCH v3 07/14] xen: sched: introduce soft-affinity and use it instead d->node-affinity Dario Faggioli
2013-11-18 18:17 ` [PATCH v3 08/14] xen: derive NUMA node affinity from hard and soft CPU affinity Dario Faggioli
2013-11-19 14:14   ` George Dunlap
2013-11-19 16:20   ` Jan Beulich
2013-11-19 16:35     ` Dario Faggioli
2013-11-18 18:17 ` [PATCH v3 09/14] xen: sched: DOMCTL_*vcpuaffinity works with hard and soft affinity Dario Faggioli
2013-11-19 14:32   ` George Dunlap
2013-11-19 16:39   ` Jan Beulich
2013-11-22 18:55     ` Dario Faggioli
2013-11-25  9:32       ` Jan Beulich
2013-11-25  9:54         ` Dario Faggioli
2013-11-25 10:00           ` Jan Beulich
2013-11-25 10:58             ` George Dunlap
2013-11-18 18:18 ` [PATCH v3 10/14] libxc: get and set soft and hard affinity Dario Faggioli
2013-11-19 14:51   ` George Dunlap
2013-11-19 14:57     ` Ian Campbell
2013-11-19 14:58       ` George Dunlap
2013-11-19 17:08   ` Ian Campbell
2013-11-19 18:01     ` Dario Faggioli
2013-11-18 18:18 ` [PATCH v3 11/14] libxl: get and set soft affinity Dario Faggioli
2013-11-19 15:41   ` George Dunlap
2013-11-19 16:09     ` Dario Faggioli
2013-11-19 17:15       ` Ian Campbell
2013-11-19 18:58         ` Dario Faggioli
2013-11-20 11:30           ` Ian Campbell
2013-11-20 13:59             ` George Dunlap
2013-11-20 14:04               ` Ian Campbell
2013-11-20 16:59                 ` Ian Jackson
2013-11-20 17:46                   ` Dario Faggioli
2013-11-20 14:09       ` George Dunlap
2013-11-19 17:24   ` Ian Campbell
2013-11-19 17:51     ` Dario Faggioli
2013-11-20 11:27       ` Ian Campbell
2013-11-20 11:29         ` George Dunlap
2013-11-20 11:32           ` Ian Campbell
2013-11-20 11:40             ` Dario Faggioli
2013-11-20 14:45               ` George Dunlap
2013-11-20 14:52                 ` Dario Faggioli
2013-11-20 12:00         ` Dario Faggioli
2013-11-20 12:05           ` Ian Campbell
2013-11-20 12:18             ` Dario Faggioli
2013-11-20 12:26               ` Ian Campbell
2013-11-20 14:50                 ` Dario Faggioli
2013-11-20 14:56                   ` Ian Campbell
2013-11-20 16:27                     ` Dario Faggioli
2013-11-18 18:18 ` [PATCH v3 12/14] xl: enable getting and setting soft Dario Faggioli
2013-11-19 17:30   ` Ian Campbell
2013-11-19 17:52     ` Dario Faggioli
2013-11-18 18:18 ` [PATCH v3 13/14] xl: enable for specifying node-affinity in the config file Dario Faggioli
2013-11-19 17:35   ` Ian Campbell [this message]
2013-11-18 18:18 ` [PATCH v3 14/14] libxl: automatic NUMA placement affects soft affinity Dario Faggioli
2013-11-19 17:41   ` Ian Campbell
2013-11-19 17:57     ` Dario Faggioli
2013-11-18 18:20 ` [PATCH v3 00/14] Series short description Dario Faggioli
2013-11-19 16:00 ` George Dunlap
2013-11-19 16:08   ` Jan Beulich

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=1384882523.16252.56.camel@hastur.hellion.org.uk \
    --to=ian.campbell@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Marcus.Granado@eu.citrix.com \
    --cc=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jtweaver@hawaii.edu \
    --cc=juergen.gross@ts.fujitsu.com \
    --cc=keir@xen.org \
    --cc=lccycc123@gmail.com \
    --cc=msw@amazon.com \
    --cc=ufimtseva@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).