From: George Dunlap <george.dunlap@eu.citrix.com>
To: Dario Faggioli <dario.faggioli@citrix.com>, 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
Subject: Re: [v7 PATCH 07/10] libxl: get and set soft affinity
Date: Tue, 10 Jun 2014 16:39:25 +0100 [thread overview]
Message-ID: <539726AD.6060805@eu.citrix.com> (raw)
In-Reply-To: <20140610004518.16660.71324.stgit@Solace>
On 06/10/2014 01:45 AM, Dario Faggioli wrote:
> Make space for two new cpumap-s, one in vcpu_info (for getting
> soft affinity) and build_info (for setting it) and amend the
> API for setting vCPU affinity.
>
> libxl_set_vcpuaffinity() now takes two cpumaps, one for hard
> and one for soft affinity (LIBXL_API_VERSION is exploited to
> retain source level backword compatibility). Either of the
> two cpumap can be NULL, in which case, only the affinity
> corresponding to the non-NULL cpumap will be affected.
>
> Getting soft affinity happens indirectly, via `xl vcpu-list'
> (as it is already for hard affinity).
>
> This commit also introduces some logic to check whether the
> affinity which will be used by Xen to schedule the vCPU(s)
> does actually match with the cpumaps provided. In fact, we
> want to allow every possible combination of hard and soft
> affinity to be set, but we warn the user upon particularly
> weird situations (e.g., hard and soft being disjoint sets
> of pCPUs).
>
> This very change also update the error handling for calls
> to libxl_set_vcpuaffinity() in xl, as that can now be any
> libxl error code, not just only -1.
>
> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
> Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
>
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index 80947c3..e549db8 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -82,6 +82,15 @@
> #define LIBXL_HAVE_DOMAIN_NODEAFFINITY 1
>
> /*
> + * LIBXL_HAVE_SOFT_AFFINITY indicates that a 'cpumap_soft'
> + * field (of libxl_bitmap type) is present in:
> + * - libxl_vcpuinfo, containing the soft affinity of a vcpu;
> + * - libxl_domain_build_info, for setting the soft affinity of
> + * all vcpus while creating the domain.
> + */
> +#define LIBXL_HAVE_SOFT_AFFINITY 1
Did we say we were going to move these to where the actual change was
happening (say, down in the libxl_set_vcpuaffinity definitions)? I'm OK
either way.
> +
> +/*
> * LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE indicates that the
> * libxl_vendor_device field is present in the hvm sections of
> * libxl_domain_build_info. This field tells libxl which
> @@ -1097,9 +1106,22 @@ int libxl_userdata_retrieve(libxl_ctx *ctx, uint32_t domid,
>
> int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
> int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
> - libxl_bitmap *cpumap);
> + const libxl_bitmap *cpumap_hard,
> + const libxl_bitmap *cpumap_soft);
> int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,
> - unsigned int max_vcpus, libxl_bitmap *cpumap);
> + unsigned int max_vcpus,
> + const libxl_bitmap *cpumap_hard,
> + const libxl_bitmap *cpumap_soft);
> +
> +#if defined (LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x040500
> +
> +#define libxl_set_vcpuaffinity(ctx, domid, vcpuid, map) \
> + libxl_set_vcpuaffinity((ctx), (domid), (vcpuid), (map), NULL)
> +#define libxl_set_vcpuaffinity_all(ctx, domid, max_vcpus, map) \
> + libxl_set_vcpuaffinity_all((ctx), (domid), (max_vcpus), (map), NULL)
> +
> +#endif
> +
> int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
> libxl_bitmap *nodemap);
> int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
> diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> index d015cf4..49a01a7 100644
> --- a/tools/libxl/libxl_create.c
> +++ b/tools/libxl/libxl_create.c
> @@ -193,6 +193,12 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
> libxl_bitmap_set_any(&b_info->cpumap);
> }
>
> + if (!b_info->cpumap_soft.size) {
> + if (libxl_cpu_bitmap_alloc(CTX, &b_info->cpumap_soft, 0))
> + return ERROR_FAIL;
> + libxl_bitmap_set_any(&b_info->cpumap_soft);
> + }
> +
> libxl_defbool_setdefault(&b_info->numa_placement, true);
>
> if (!b_info->nodemap.size) {
> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
> index 661999c..91af7f8 100644
> --- a/tools/libxl/libxl_dom.c
> +++ b/tools/libxl/libxl_dom.c
> @@ -261,7 +261,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_all(ctx, domid, info->max_vcpus, &info->cpumap,
> + &info->cpumap_soft);
>
> if (xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb +
> LIBXL_MAXMEM_CONSTANT) < 0) {
> diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> index 52f1aa9..15382cc 100644
> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -300,6 +300,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
> ("max_vcpus", integer),
> ("avail_vcpus", libxl_bitmap),
> ("cpumap", libxl_bitmap),
> + ("cpumap_soft", libxl_bitmap),
> ("nodemap", libxl_bitmap),
> ("numa_placement", libxl_defbool),
> ("tsc_mode", libxl_tsc_mode),
> @@ -516,7 +517,8 @@ libxl_vcpuinfo = Struct("vcpuinfo", [
> ("blocked", bool),
> ("running", bool),
> ("vcpu_time", uint64), # total vcpu time ran (ns)
> - ("cpumap", libxl_bitmap), # current cpu's affinities
> + ("cpumap", libxl_bitmap), # current hard cpu affinity
> + ("cpumap_soft", libxl_bitmap), # current soft cpu affinity
> ], dir=DIR_OUT)
>
> libxl_physinfo = Struct("physinfo", [
> diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
> index e37fb89..014f1f6 100644
> --- a/tools/libxl/libxl_utils.h
> +++ b/tools/libxl/libxl_utils.h
> @@ -98,6 +98,31 @@ static inline int libxl_bitmap_cpu_valid(libxl_bitmap *bitmap, int bit)
> #define libxl_for_each_set_bit(v, m) for (v = 0; v < (m).size * 8; v++) \
> if (libxl_bitmap_test(&(m), v))
>
> +/*
> + * Compares two bitmaps bit by bit, up to nr_bits or, if nr_bits is 0, up
> + * to the size of the lagest bitmap. If sizes does not match, bits past the
*largest
Other than that:
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
next prev parent reply other threads:[~2014-06-10 15:39 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-10 0:44 [v7 PATCH 00/10] Implement vcpu soft affinity for credit1 Dario Faggioli
2014-06-10 0:44 ` [v7 PATCH 01/10] xen: sched: rename v->cpu_affinity into v->cpu_hard_affinity Dario Faggioli
2014-06-10 0:44 ` [v7 PATCH 02/10] xen: sched: introduce soft-affinity and use it instead d->node-affinity Dario Faggioli
2014-06-10 11:26 ` George Dunlap
2014-06-10 0:44 ` [v7 PATCH 03/10] xen: derive NUMA node affinity from hard and soft CPU affinity Dario Faggioli
2014-06-10 14:53 ` George Dunlap
2014-06-10 15:20 ` Dario Faggioli
2014-06-10 15:33 ` George Dunlap
2014-06-10 0:44 ` [v7 PATCH 04/10] xen/libxc: sched: DOMCTL_*vcpuaffinity works with hard and soft affinity Dario Faggioli
2014-06-10 0:45 ` [v7 PATCH 05/10] libxc/libxl: bump library SONAMEs Dario Faggioli
2014-06-10 13:46 ` Ian Campbell
2014-06-10 0:45 ` [v7 PATCH 06/10] libxc: get and set soft and hard affinity Dario Faggioli
2014-06-10 0:45 ` [v7 PATCH 07/10] libxl: get and set soft affinity Dario Faggioli
2014-06-10 14:02 ` Ian Campbell
2014-06-11 7:13 ` Dario Faggioli
2014-06-10 15:39 ` George Dunlap [this message]
2014-06-10 15:44 ` Ian Campbell
2014-06-10 0:45 ` [v7 PATCH 08/10] xl: enable getting and setting soft Dario Faggioli
2014-06-10 14:10 ` Ian Campbell
2014-06-10 15:10 ` Dario Faggioli
2014-06-10 0:45 ` [v7 PATCH 09/10] xl: enable for specifying soft-affinity in the config file Dario Faggioli
2014-06-10 14:38 ` Ian Campbell
2014-06-10 15:36 ` Dario Faggioli
2014-06-10 15:46 ` Ian Campbell
2014-06-10 0:45 ` [v7 PATCH 10/10] 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=539726AD.6060805@eu.citrix.com \
--to=george.dunlap@eu.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=dario.faggioli@citrix.com \
--cc=keir@xen.org \
--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.