All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: Dongxiao Xu <dongxiao.xu@intel.com>
Cc: keir@xen.org, Ian.Campbell@citrix.com,
	stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com,
	Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org,
	JBeulich@suse.com, dgdegra@tycho.nsa.gov
Subject: Re: [PATCH v4 7/7] tools: enable Cache QoS Monitoring feature for libxl/libxc
Date: Tue, 3 Dec 2013 13:17:01 +0100	[thread overview]
Message-ID: <1386073021.5338.320.camel@Solace> (raw)
In-Reply-To: <1386060479-17205-8-git-send-email-dongxiao.xu@intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 4185 bytes --]

On mar, 2013-12-03 at 16:47 +0800, Dongxiao Xu wrote:
> Introduced two new xl commands to attach/detach CQM service for a guest
> $ xl pqos-attach cqm domid
> $ xl pqos-detach cqm domid
> 
> Introduce one new xl command to retrive guest CQM information
> $ xl pqos-list cqm (domid)
> 
> Signed-off-by: Jiongxi Li <jiongxi.li@intel.com>
> Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
> ---
>  tools/libxc/xc_domain.c   |   47 +++++++++++++++
>  tools/libxc/xenctrl.h     |   11 ++++
>  tools/libxl/Makefile      |    3 +-
>  tools/libxl/libxl.h       |    5 ++
>  tools/libxl/libxl_pqos.c  |  108 +++++++++++++++++++++++++++++++++
>  tools/libxl/xl.h          |    3 +
>  tools/libxl/xl_cmdimpl.c  |  146 +++++++++++++++++++++++++++++++++++++++++++++
>  tools/libxl/xl_cmdtable.c |   15 +++++
>  8 files changed, 337 insertions(+), 1 deletion(-)
>  create mode 100644 tools/libxl/libxl_pqos.c
> 
Would it be possible to split this patch in 3, one for libxc, one for
libxl and one for xl?


> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index c7dceda..fdca92d 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -285,6 +285,7 @@
>  
>  #include <libxl_uuid.h>
>  #include <_libxl_list.h>
> +#include <xenctrl.h>
>
Is this really necessary? I think it shouldn't... <xenctrl.h> is already
included in "libxl_internal.h", which you are including yourself below,
so...

> diff --git a/tools/libxl/libxl_pqos.c b/tools/libxl/libxl_pqos.c
> new file mode 100644
> index 0000000..bf7593a
> --- /dev/null
> +++ b/tools/libxl/libxl_pqos.c
> @@ -0,0 +1,108 @@
> +/*
> + * Copyright (C) 2013      Intel Corporation
> + * Author Jiongxi Li <jiongxi.li@intel.com>
> + * Author Dongxiao Xu <dongxiao.xu@intel.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU Lesser General Public License as published
> + * by the Free Software Foundation; version 2.1 only. with the special
> + * exception on linking described in file LICENSE.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
> + */
> +
> +#include "libxl_osdeps.h" /* must come before any other headers */
> +#include "libxl_internal.h"

> +int libxl_pqos_attach(libxl_ctx *ctx, uint32_t domid, const char * qos_type)
> +{
> +    int rc;
> +    uint32_t flags = 0;
> +
> +    if (!strncmp(qos_type, "cqm", 3))
> +        flags |= XEN_DOMCTL_pqos_cqm;
> +    else {
> +        rc = -EINVAL;
> +        LIBXL__LOG(ctx, XTL_ERROR, "%s", msg[EINVAL]);
>
I think new code should use the LOG() / LOGE() variant of the logging
macros.

> +        return rc;
> +    }
>
libxl functions should return libxl error codes.

> +
> +    rc = xc_domain_pqos_attach(ctx->xch, domid, flags);
> +    if (rc < 0) {
> +        switch(errno) {
> +        case EINVAL:
> +        case ENODEV:
> +        case EEXIST:
> +        case EUSERS:
> +        case ESRCH:
> +            LIBXL__LOG(ctx, XTL_ERROR, "%s", msg[errno]);
> +            break;
> +        default:
> +            LIBXL__LOG(ctx, XTL_ERROR, "errno: %d", errno);
> +        }
> +    }
> +
Mmm... Isn't there a better place where to do this demultiplexing and
printing the correct message? Looking around, in libxl, what usually
happens is printing something generic enough, together with the errno
value/message (with LOGE), and then rely on lower layers to provide a
more detailed explanation of what happened.

This is certainly up to a maintainer to decide, but I think you at least
(you're doing this twice) should do it in a function rather than
duplicating the whole switch.

Regards,
Dario

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2013-12-03 12:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03  8:47 [PATCH v4 0/7] enable Cache QoS Monitoring (CQM) feature Dongxiao Xu
2013-12-03  8:47 ` [PATCH v4 1/7] x86: detect and initialize Cache QoS Monitoring feature Dongxiao Xu
2013-12-03 11:46   ` Andrew Cooper
2013-12-03 12:54     ` Jan Beulich
2013-12-03 13:45       ` Andrew Cooper
2013-12-03 14:01         ` Jan Beulich
2013-12-03 20:32   ` Konrad Rzeszutek Wilk
2013-12-04 11:37     ` Ian Jackson
2013-12-03  8:47 ` [PATCH v4 2/7] x86: dynamically attach/detach CQM service for a guest Dongxiao Xu
2013-12-03  8:47 ` [PATCH v4 3/7] x86: initialize per socket cpu map Dongxiao Xu
2013-12-03  9:56   ` Dario Faggioli
2013-12-03  8:47 ` [PATCH v4 4/7] x86: collect CQM information from all sockets Dongxiao Xu
2013-12-03 11:52   ` Andrew Cooper
2013-12-03  8:47 ` [PATCH v4 5/7] x86: enable CQM monitoring for each domain RMID Dongxiao Xu
2013-12-03  8:47 ` [PATCH v4 6/7] xsm: add platform QoS related xsm policies Dongxiao Xu
2013-12-03 13:53   ` Daniel De Graaf
2013-12-03  8:47 ` [PATCH v4 7/7] tools: enable Cache QoS Monitoring feature for libxl/libxc Dongxiao Xu
2013-12-03 12:17   ` Dario Faggioli [this message]
2013-12-04  2:44     ` Xu, Dongxiao
2013-12-04  8:14       ` 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=1386073021.5338.320.camel@Solace \
    --to=dario.faggioli@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=dongxiao.xu@intel.com \
    --cc=keir@xen.org \
    --cc=stefano.stabellini@eu.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.