All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Chao Peng <chao.p.peng@linux.intel.com>
Cc: keir@xen.org, stefano.stabellini@eu.citrix.com,
	andrew.cooper3@citrix.com, Ian.Jackson@eu.citrix.com,
	xen-devel@lists.xen.org, will.auld@intel.com, JBeulich@suse.com,
	wei.liu2@citrix.com, dgdegra@tycho.nsa.gov
Subject: Re: [PATCH v3 8/8] tools: add tools support for Intel CAT
Date: Tue, 31 Mar 2015 17:28:54 +0100	[thread overview]
Message-ID: <1427819334.2115.194.camel@citrix.com> (raw)
In-Reply-To: <1427373505-9303-9-git-send-email-chao.p.peng@linux.intel.com>

On Thu, 2015-03-26 at 20:38 +0800, Chao Peng wrote:
> This is the xc/xl changes to support Intel Cache Allocation
> Technology(CAT). Two commands are introduced:
> - xl psr-cat-cbm-set [-s socket] <domain> <cbm>
>   Set cache capacity bitmasks(CBM) for a domain.
> - xl psr-cat-show <domain>
>   Show Cache Allocation Technology information.

Please could you show an example of the output from this one.

> 
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> ---
> Changes in v3:
> * Add manpage.
> * libxl_psr_cat_set/get_domain_data => libxl_psr_cat_set/get_cbm.
> * Move libxl_count_physical_sockets into seperate patch.
> * Support LIBXL_PSR_TARGET_ALL for libxl_psr_cat_set_cbm.
> * Clean up the print codes.
> ---
>  docs/man/xl.pod.1             |  31 +++++++++
>  tools/libxc/include/xenctrl.h |  15 +++++
>  tools/libxc/xc_psr.c          |  74 +++++++++++++++++++++
>  tools/libxl/libxl.h           |  20 ++++++
>  tools/libxl/libxl_psr.c       | 126 ++++++++++++++++++++++++++++++++++--
>  tools/libxl/libxl_types.idl   |   5 ++
>  tools/libxl/xl.h              |   4 ++
>  tools/libxl/xl_cmdimpl.c      | 146 ++++++++++++++++++++++++++++++++++++++++++
>  tools/libxl/xl_cmdtable.c     |  12 ++++
>  9 files changed, 426 insertions(+), 7 deletions(-)
> 
> diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1
> index b016272..99979a5 100644
> --- a/docs/man/xl.pod.1
> +++ b/docs/man/xl.pod.1
> @@ -1492,6 +1492,37 @@ monitor types are:
>  
>  =back
>  
> +=head1 CACHE ALLOCATION TECHNOLOGY
> +
> +Intel Broadwell and later server platforms offer capabilities to configure and
> +make use of the Cache Allocation Technology (CAT) mechanisms, which enable more
> +cache resources (i.e. L3 cache) to be made available for high priority
> +applications. In Xen implementation, CAT is used to control cache allocation
> +on VM basis. To enforce cache on a specific domain, just set capacity bitmasks
> +(CBM) for the domain.
> +
> +=over 4
> +
> +=item B<psr-cat-cbm-set> [I<OPTIONS>] [I<domain-id>]
> +
> +Set cache capacity bitmasks(CBM) for a domain.

What is the syntax of these bitmaps, and where do I pass them?

I think there is also a bunch of terminology (CBM, COS) which need
explaining, otherwise no one will know how to use it. Perhaps that
belongs in a separate document or the wiki though?

> diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
> index e367a80..6c670d5 100644
> --- a/tools/libxc/xc_psr.c
> +++ b/tools/libxc/xc_psr.c
> @@ -248,6 +248,80 @@ int xc_psr_cmt_enabled(xc_interface *xch)
>  
>      return 0;
>  }
> +int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
> +                               xc_psr_cat_type type, uint32_t target,
> +                               uint64_t data)
> +{
> +    DECLARE_DOMCTL;
> +    uint32_t cmd;
> +
> +    switch ( type )
> +    {
> +    case XC_PSR_CAT_L3_CBM:
> +        cmd = XEN_DOMCTL_PSR_CAT_OP_SET_L3_CBM;
> +        break;
> +    default:
> +        return -1;

You should also set errno to an appropriate value, since calling code
will try and use it to log with.

There were several instances of this I think.

> +    }


> @@ -1513,6 +1520,19 @@ int libxl_psr_cmt_get_sample(libxl_ctx *ctx,
>                               uint64_t *tsc_r);
>  #endif
>  
> +#ifdef LIBXL_HAVE_PSR_CAT
> +
> +#define LIBXL_PSR_TARGET_ALL (~0U)
> +int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
> +                          libxl_psr_cat_type type, uint32_t target,
> +                          uint64_t cbm);
> +int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
> +                          libxl_psr_cat_type type, uint32_t target,
> +                          uint64_t *cbm_r);

What are the units of the various cbm*

If they are now more precisely typed (i.e. not the opaque data from last
time) then is the type parameter still needed?

> +int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, uint32_t socket,
> +                              uint32_t *cos_max_r, uint32_t *cbm_len_r);

Is there going to be any user documentation regarding what cos and cbm
are and how to interpret them and set them?

> @@ -247,6 +290,75 @@ out:
>      return rc;
>  }
>  
> +int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
> +                          libxl_psr_cat_type type, uint32_t target,
> +                          uint64_t cbm)
> +{
> +    GC_INIT(ctx);
> +    int rc;
> +
> +    uint32_t i, nr_sockets;
> +
> +    if (target != LIBXL_PSR_TARGET_ALL) {
> +        rc = xc_psr_cat_set_domain_data(ctx->xch, domid, type, target, cbm);
> +        if (rc < 0) {
> +            libxl__psr_cat_log_err_msg(gc, errno);
> +            rc = ERROR_FAIL;
> +        }
> +    } else {
> +        nr_sockets = libxl_count_physical_sockets(ctx);
> +        if (nr_sockets == 0) {
> +            LOGE(ERROR, "failed to get system socket count");
> +            rc = ERROR_FAIL;
> +            goto out;
> +        }
> +        for (i = 0; i < nr_sockets; i++) {
> +            rc = xc_psr_cat_set_domain_data(ctx->xch, domid, type, i, cbm);
> +            if (rc < 0) {
> +                libxl__psr_cat_log_err_msg(gc, errno);
> +                rc = ERROR_FAIL;

You neither error out nor latch this value, so you only return the
status of the final socket.

I think you probably want to exit on first error. And depending on the
semantics of this stuff you may also need to unwind any work already
done.

> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index f26a02d..ff963df 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -8038,6 +8038,152 @@ int main_psr_cmt_show(int argc, char **argv)
>  }
>  #endif
>  
> +#ifdef LIBXL_HAVE_PSR_CAT
> +static void psr_cat_print_one_domain_cbm(libxl_dominfo *dominfo,
> +                                         uint32_t socket)
> +{
> +    char *domain_name;
> +    uint64_t cbm;
> +
> +    domain_name = libxl_domid_to_name(ctx, dominfo->domid);

AFAICT you use dominfo here for domifo->domid, but you looked it up with
libxl_domain_info(,... domid) so you already had that in your hand.

IOW I think you can just pass the domid to this function, and omit the
call to libxl_domain_info in the callers, or use list->domid in the case
you have that in hand.

> +    printf("%5d%25s", dominfo->domid, domain_name);
> +    free(domain_name);
> +
> +    if (!libxl_psr_cat_get_cbm(ctx, dominfo->domid,
> +                               LIBXL_PSR_CAT_TYPE_L3_CBM, socket, &cbm))
> +         printf("%#16"PRIx64, cbm);
> +
> +    printf("\n");
> +}
> +
> +static int psr_cat_print_domain_cbm(uint32_t domid, uint32_t socket)
> +{
> +    int i, nr_domains;
> +
> +    if (domid != INVALID_DOMID) {
> +        libxl_dominfo dominfo;
> +
> +        if (libxl_domain_info(ctx, &dominfo, domid)) {
> +            fprintf(stderr, "Failed to get domain info for %d\n", domid);
> +            return -1;
> +        }
> +        psr_cat_print_one_domain_cbm(&dominfo, socket);
> +    } else {
> +        libxl_dominfo *list;
> +
> +        if (!(list = libxl_list_domain(ctx, &nr_domains))) {
> +            fprintf(stderr, "Failed to get domain info for domain list.\n");

"...for cbm something something."

> +            return -1;
> +        }
> +        for (i = 0; i < nr_domains; i++)
> +            psr_cat_print_one_domain_cbm(list + i, socket);
> +        libxl_dominfo_list_free(list, nr_domains);
> +    }
> +
> +    return 0;
> +}
> +
> +static int psr_cat_print_socket(uint32_t domid, uint32_t socket)
> +{
> +    uint32_t l3_cache_size, cos_max, cbm_len;
> +    int rc;
> +
> +    rc = libxl_psr_cmt_get_l3_cache_size(ctx, socket, &l3_cache_size);
> +    if (rc) {
> +        fprintf(stderr, "Failed to get l3 cache size for socket:%d\n", socket);
> +        return -1;
> +    }
> +
> +    rc = libxl_psr_cat_get_l3_info(ctx, socket, &cos_max, &cbm_len);

Would an interface which returns a list with information for all sockets
not be more convenient?

> +    if (rc) {
> +        fprintf(stderr, "Failed to get cat info for socket:%d\n", socket);
> +        return -1;
> +    }
> +
> +    /* Header */
> +    printf("SocketID:\t%u\n", socket);
> +    printf("L3 Cache:\t%uKB\n", l3_cache_size);
> +    printf("Maximum COS:\t%u\n", cos_max);
> +    printf("CBM length:\t%u\n", cbm_len);
> +    printf("Default CBM:\t%#"PRIx64"\n", (1ul << cbm_len) - 1);
> +    printf("%5s%25s%16s\n", "ID", "NAME", "CBM");
> +
> +    return psr_cat_print_domain_cbm(domid, socket);
> +}
> +
> +static int psr_cat_show(uint32_t domid)
> +{
> +    uint32_t socket, nr_sockets;
> +    int rc;
> +
> +    nr_sockets = libxl_count_physical_sockets(ctx);
> +    if (nr_sockets == 0) {
> +        fprintf(stderr, "Failed getting physinfo\n");

That wasn't a physinfo call.

Ian.

  reply	other threads:[~2015-03-31 16:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-26 12:38 [PATCH v3 0/8] enable Cache Allocation Technology (CAT) for VMs Chao Peng
2015-03-26 12:38 ` [PATCH v3 1/8] x86: clean up psr boot parameter parsing Chao Peng
2015-03-26 20:42   ` Andrew Cooper
2015-03-26 12:38 ` [PATCH v3 2/8] x86: improve psr scheduling code Chao Peng
2015-03-27 18:15   ` Andrew Cooper
2015-03-26 12:38 ` [PATCH v3 3/8] x86: detect and initialize Intel CAT feature Chao Peng
2015-03-27 18:31   ` Andrew Cooper
2015-04-13 10:51     ` Jan Beulich
2015-04-13 10:58       ` Andrew Cooper
2015-03-26 12:38 ` [PATCH v3 4/8] x86: add support for COS/CBM manangement Chao Peng
2015-03-27 20:16   ` Andrew Cooper
2015-03-31  8:40     ` Chao Peng
2015-03-26 12:38 ` [PATCH v3 5/8] x86: add scheduling support for Intel CAT Chao Peng
2015-03-26 12:38 ` [PATCH v3 6/8] xsm: add CAT related xsm policies Chao Peng
2015-03-26 12:38 ` [PATCH v3 7/8] tools/libxl: introduce libxl_count_physical_sockets Chao Peng
2015-03-30 14:51   ` Wei Liu
2015-03-31  8:51     ` Chao Peng
2015-03-31 16:11       ` Ian Campbell
2015-03-26 12:38 ` [PATCH v3 8/8] tools: add tools support for Intel CAT Chao Peng
2015-03-31 16:28   ` Ian Campbell [this message]
2015-04-01  7:55     ` Chao Peng
2015-04-01  8:41       ` Ian Campbell
2015-04-01  9:06         ` Chao Peng
2015-04-01  9:23           ` Ian Campbell
2015-04-02  3:15             ` Chao Peng
2015-04-07  8:57               ` Chao Peng

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=1427819334.2115.194.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=keir@xen.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=will.auld@intel.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.