From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Chao Peng <chao.p.peng@linux.intel.com>, xen-devel@lists.xen.org
Cc: keir@xen.org, Ian.Campbell@citrix.com,
stefano.stabellini@eu.citrix.com, Ian.Jackson@eu.citrix.com,
JBeulich@suse.com, wei.liu2@citrix.com
Subject: Re: [PATCH v2 2/5] tools: add routine to get CMT L3 event mask
Date: Wed, 7 Jan 2015 11:27:33 +0000 [thread overview]
Message-ID: <54AD1825.1060800@citrix.com> (raw)
In-Reply-To: <1420629125-17725-3-git-send-email-chao.p.peng@linux.intel.com>
On 07/01/15 11:12, Chao Peng wrote:
> This is the tools side wrapper for XEN_SYSCTL_PSR_CMT_get_l3_event_mask
> of XEN_SYSCTL_psr_cmt_op.
>
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> ---
> tools/libxc/include/xenctrl.h | 1 +
> tools/libxc/xc_psr.c | 24 ++++++++++++++++++++++++
> tools/libxl/libxl.h | 1 +
> tools/libxl/libxl_psr.c | 18 ++++++++++++++++++
> 4 files changed, 44 insertions(+)
>
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 0ad8b8d..96b357c 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -2697,6 +2697,7 @@ int xc_psr_cmt_get_domain_rmid(xc_interface *xch, uint32_t domid,
> int xc_psr_cmt_get_total_rmid(xc_interface *xch, uint32_t *total_rmid);
> int xc_psr_cmt_get_l3_upscaling_factor(xc_interface *xch,
> uint32_t *upscaling_factor);
> +int xc_psr_cmt_get_l3_event_mask(xc_interface *xch, uint32_t *event_mask);
> int xc_psr_cmt_get_l3_cache_size(xc_interface *xch, uint32_t cpu,
> uint32_t *l3_cache_size);
> int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid,
> diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
> index 872e6dc..e76a0f9 100644
> --- a/tools/libxc/xc_psr.c
> +++ b/tools/libxc/xc_psr.c
> @@ -112,6 +112,30 @@ int xc_psr_cmt_get_l3_upscaling_factor(xc_interface *xch,
> return rc;
> }
>
> +int xc_psr_cmt_get_l3_event_mask(xc_interface *xch, uint32_t *event_mask)
> +{
> + static int val = 0;
This should be uint32_t rather than int.
I am somewhat concerned about multithreaded use of libxc, but this is
not the first issue in libxc, and probably shouldn't be held against
this patch. As the result of the hypercall is going to be the same, the
worse that a race could achieve is a wasted hypercall.
> + int rc;
> + DECLARE_SYSCTL;
> +
> + if ( val )
> + {
> + *event_mask = val;
> + return 0;
> + }
> +
> + sysctl.cmd = XEN_SYSCTL_psr_cmt_op;
> + sysctl.u.psr_cmt_op.cmd =
> + XEN_SYSCTL_PSR_CMT_get_l3_event_mask;
> + sysctl.u.psr_cmt_op.flags = 0;
> +
> + rc = xc_sysctl(xch, &sysctl);
> + if ( !rc )
> + val = *event_mask = sysctl.u.psr_cmt_op.u.data;
> +
> + return rc;
> +}
> +
> int xc_psr_cmt_get_l3_cache_size(xc_interface *xch, uint32_t cpu,
> uint32_t *l3_cache_size)
> {
> diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> index 0a123f1..42ace76 100644
> --- a/tools/libxl/libxl.h
> +++ b/tools/libxl/libxl.h
> @@ -1453,6 +1453,7 @@ int libxl_psr_cmt_attach(libxl_ctx *ctx, uint32_t domid);
> int libxl_psr_cmt_detach(libxl_ctx *ctx, uint32_t domid);
> int libxl_psr_cmt_domain_attached(libxl_ctx *ctx, uint32_t domid);
> int libxl_psr_cmt_enabled(libxl_ctx *ctx);
> +int libxl_psr_cmt_type_supported(libxl_ctx *ctx, libxl_psr_cmt_type type);
> int libxl_psr_cmt_get_total_rmid(libxl_ctx *ctx, uint32_t *total_rmid);
> int libxl_psr_cmt_get_l3_cache_size(libxl_ctx *ctx, uint32_t socketid,
> uint32_t *l3_cache_size);
> diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
> index 0437465..3018a0d 100644
> --- a/tools/libxl/libxl_psr.c
> +++ b/tools/libxl/libxl_psr.c
> @@ -120,6 +120,24 @@ int libxl_psr_cmt_enabled(libxl_ctx *ctx)
> return xc_psr_cmt_enabled(ctx->xch);
> }
>
> +int libxl_psr_cmt_type_supported(libxl_ctx *ctx, libxl_psr_cmt_type type)
> +{
> + GC_INIT(ctx);
> + uint32_t event_mask;
> + int ret;
The libxl CODING_SYTLE states that this "ret" should be "rc"
~Andrew
> +
> + ret = xc_psr_cmt_get_l3_event_mask(ctx->xch, &event_mask);
> + if (ret < 0) {
> + libxl__psr_cmt_log_err_msg(gc, errno);
> + ret = 0;
> + } else {
> + ret = event_mask & (1 << (type - 1));
> + }
> +
> + GC_FREE;
> + return ret;
> +}
> +
> int libxl_psr_cmt_get_total_rmid(libxl_ctx *ctx, uint32_t *total_rmid)
> {
> GC_INIT(ctx);
next prev parent reply other threads:[~2015-01-07 11:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 11:12 [PATCH v2 0/5] enable Memory Bandwidth Monitoring (MBM) for VMs Chao Peng
2015-01-07 11:12 ` [PATCH v2 1/5] x86: expose CMT L3 event mask to user space Chao Peng
2015-01-07 11:12 ` [PATCH v2 2/5] tools: add routine to get CMT L3 event mask Chao Peng
2015-01-07 11:27 ` Andrew Cooper [this message]
2015-01-07 16:37 ` Ian Jackson
2015-01-07 16:54 ` Wei Liu
2015-01-07 17:04 ` Ian Campbell
2015-01-07 17:09 ` Andrew Cooper
2015-01-07 21:43 ` Ian Jackson
2015-01-08 3:19 ` Chao Peng
2015-01-07 11:12 ` [PATCH v2 3/5] tools: correct coding style for psr Chao Peng
2015-01-07 11:16 ` Wei Liu
2015-01-07 11:12 ` [PATCH v2 4/5] tools: code refactoring for MBM Chao Peng
2015-01-07 12:15 ` Wei Liu
2015-01-07 11:12 ` [PATCH v2 5/5] tools: add total/local memory bandwith monitoring Chao Peng
2015-01-07 12:23 ` Wei Liu
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=54AD1825.1060800@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=chao.p.peng@linux.intel.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.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.