From: Chao Peng <chao.p.peng@linux.intel.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: keir@xen.org, Ian.Campbell@citrix.com,
stefano.stabellini@eu.citrix.com, Ian.Jackson@eu.citrix.com,
xen-devel@lists.xen.org, JBeulich@suse.com, wei.liu2@citrix.com
Subject: Re: [PATCH 2/4] tools: libxc: add routine to get CMT L3 event mask
Date: Wed, 24 Dec 2014 16:33:48 +0800 [thread overview]
Message-ID: <20141224083348.GA10595@pengc-linux.bj.intel.com> (raw)
In-Reply-To: <54998E61.8020103@citrix.com>
On Tue, Dec 23, 2014 at 03:46:41PM +0000, Andrew Cooper wrote:
>
> On 23/12/2014 08:54, Chao Peng wrote:
> >This is the xc side wrapper for XEN_SYSCTL_PSR_CMT_get_l3_event_mask
> >of XEN_SYSCTL_psr_cmt_op. Additional check for event id against value
> >got from this routine is also added.
> >
> >Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> >---
> > tools/libxc/include/xenctrl.h | 1 +
> > tools/libxc/xc_psr.c | 32 ++++++++++++++++++++++++++++++++
> > 2 files changed, 33 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..94c8698 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;
> >+ 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)
> > {
> >@@ -144,6 +168,7 @@ int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid,
> > xc_resource_op_t op;
> > xc_resource_entry_t entries[2];
> > uint32_t evtid;
> >+ uint32_t event_mask;
> > int rc;
> > switch ( type )
> >@@ -155,6 +180,13 @@ int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid,
> > return -1;
> > }
> >+ rc = xc_psr_cmt_get_l3_event_mask(xch, &event_mask);
> >+ if ( rc < 0 )
> >+ return rc;
> >+
> >+ if ( !(event_mask & (1 << (evtid - 1))) )
> >+ return -1;
> >+
>
> This adds an extra hypercall on a common path to return a constant. As libxc
> is mostly a set of basic hypercall wrappers, I don't it should be validating
> its parameters like this.
>
> The caller of xc_psr_cmt_get_data() must be aware of all the details, and
> whether certain events are supported or not. I woud simply let the
> xc_resourse_op() fail (faulting on the wrmsr) if the caller passes a bad
> event id.
>
Sounds reasonable. I'd move the validation to the caller, that's, the xl side.
Thanks Andrew.
>
> > entries[0].u.cmd = XEN_RESOURCE_OP_MSR_WRITE;
> > entries[0].idx = MSR_IA32_CMT_EVTSEL;
> > entries[0].val = (uint64_t)rmid << 32 | evtid;
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-12-24 8:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-23 8:54 [PATCH 0/4] enable Memory Bandwidth Monitoring (MBM) for VMs Chao Peng
2014-12-23 8:54 ` [PATCH 1/4] x86: expose CMT L3 event mask to user space Chao Peng
2014-12-23 15:47 ` Andrew Cooper
2015-01-07 8:53 ` Jan Beulich
2014-12-23 8:54 ` [PATCH 2/4] tools: libxc: add routine to get CMT L3 event mask Chao Peng
2014-12-23 15:46 ` Andrew Cooper
2014-12-24 8:33 ` Chao Peng [this message]
2014-12-23 8:54 ` [PATCH 3/4] tools: libxl: code preparation for MBM Chao Peng
2015-01-05 12:25 ` Wei Liu
2015-01-06 9:46 ` Chao Peng
2015-01-06 9:51 ` Wei Liu
2015-01-06 10:12 ` Chao Peng
2014-12-23 8:54 ` [PATCH 4/4] tools: add total/local memory bandwith monitoring Chao Peng
2015-01-05 12:39 ` Wei Liu
2015-01-06 10:09 ` Chao Peng
2015-01-06 10:29 ` Andrew Cooper
2015-01-07 0:54 ` Chao Peng
2015-01-15 8:46 ` Chao Peng
2014-12-23 15:47 ` [PATCH 0/4] enable Memory Bandwidth Monitoring (MBM) for VMs Andrew Cooper
2014-12-24 8:35 ` 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=20141224083348.GA10595@pengc-linux.bj.intel.com \
--to=chao.p.peng@linux.intel.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.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.