From: dongxiao.xu@intel.com
To: xen-devel@lists.xen.org
Subject: [PATCH 7/8] tools: get per domain CQM information
Date: Wed, 20 Nov 2013 11:27:37 +0800 [thread overview]
Message-ID: <1384918058-128466-8-git-send-email-dongxiao.xu@intel.com> (raw)
In-Reply-To: <1384918058-128466-1-git-send-email-dongxiao.xu@intel.com>
From: Dongxiao Xu <dongxiao.xu@intel.com>
Retrive CQM information for certain domain, which reflects the L3 cache
occupancy for a socket.
The xl command is "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 | 33 ++++++++++++++++
tools/libxc/xenctrl.h | 5 +++
tools/libxl/libxl.h | 5 +++
tools/libxl/libxl_pqos.c | 14 +++++++
tools/libxl/xl.h | 1 +
tools/libxl/xl_cmdimpl.c | 91 +++++++++++++++++++++++++++++++++++++++++++++
tools/libxl/xl_cmdtable.c | 5 +++
7 files changed, 154 insertions(+)
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 85c2d4d..96a1d50 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -1794,6 +1794,39 @@ int xc_domain_pqos_detach(xc_interface *xch, uint32_t domid, int flags)
return do_domctl(xch, &domctl);
}
+int xc_domain_getcqminfolist(xc_interface *xch,
+ uint32_t first_domain,
+ unsigned int max_domains,
+ sysctl_cqminfo_t *info)
+{
+ int ret = 0;
+ xen_domctl_getdomcqminfo_t *d_info = info->dom_cqminfo;
+ DECLARE_SYSCTL;
+
+ DECLARE_HYPERCALL_BOUNCE(d_info, max_domains*sizeof(*d_info), XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+
+ if ( xc_hypercall_bounce_pre(xch, d_info) )
+ return -1;
+
+ sysctl.cmd = XEN_SYSCTL_getdomcqminfolist;
+ sysctl.u.getdomcqminfolist.first_domain = first_domain;
+ sysctl.u.getdomcqminfolist.max_domains = max_domains;
+ set_xen_guest_handle(sysctl.u.getdomcqminfolist.buffer, d_info);
+
+ if ( xc_sysctl(xch, &sysctl) < 0 )
+ ret = -1;
+ else
+ {
+ ret = sysctl.u.getdomcqminfolist.num_domains;
+ info->resource_count = sysctl.u.getdomcqminfolist.resource_count;
+ info->resource_avail = sysctl.u.getdomcqminfolist.resource_avail;
+ }
+
+ xc_hypercall_bounce_post(xch, d_info);
+
+ return ret;
+}
+
/*
* Local variables:
* mode: C
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index a57f147..b0b1259 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -2395,6 +2395,11 @@ int xc_kexec_load(xc_interface *xch, uint8_t type, uint16_t arch,
*/
int xc_kexec_unload(xc_interface *xch, int type);
+typedef xen_sysctl_getcqminfo_t sysctl_cqminfo_t;
int xc_domain_pqos_attach(xc_interface *xch, uint32_t domid, int flags);
int xc_domain_pqos_detach(xc_interface *xch, uint32_t domid, int flags);
+int xc_domain_getcqminfolist(xc_interface *xch,
+ uint32_t first_domain,
+ unsigned int max_domains,
+ sysctl_cqminfo_t *info);
#endif /* XENCTRL_H */
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index a9a506f..530363c 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>
/* API compatibility. */
#ifdef LIBXL_API_VERSION
@@ -1053,6 +1054,10 @@ int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);
int libxl_pqos_attach(libxl_ctx *ctx, uint32_t domid, const char * qosres);
int libxl_pqos_detach(libxl_ctx *ctx, uint32_t domid, const char * qosres);
+int libxl_list_domain_cqm(libxl_ctx *ctx,
+ uint32_t first_domain,
+ unsigned int max_domains,
+ sysctl_cqminfo_t *info);
/* misc */
diff --git a/tools/libxl/libxl_pqos.c b/tools/libxl/libxl_pqos.c
index 6d8013a..e43c706 100644
--- a/tools/libxl/libxl_pqos.c
+++ b/tools/libxl/libxl_pqos.c
@@ -77,6 +77,20 @@ int libxl_pqos_detach(libxl_ctx *ctx, uint32_t domid, const char * qosres)
return rc;
}
+int libxl_list_domain_cqm(libxl_ctx *ctx,
+ uint32_t first_domain,
+ unsigned int max_domains,
+ sysctl_cqminfo_t *info)
+{
+ int ret;
+
+ ret = xc_domain_getcqminfolist(ctx->xch, first_domain, max_domains, info);
+ if (ret < 0)
+ return -EINVAL;
+
+ return ret;
+}
+
/*
* Local variables:
* mode: C
diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
index 78738b9..994d3be 100644
--- a/tools/libxl/xl.h
+++ b/tools/libxl/xl.h
@@ -107,6 +107,7 @@ int main_loadpolicy(int argc, char **argv);
int main_remus(int argc, char **argv);
int main_pqosattach(int argc, char **argv);
int main_pqosdetach(int argc, char **argv);
+int main_pqoslist(int argc, char **argv);
void help(const char *command);
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 1a12e8f..52c1321 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -7231,6 +7231,97 @@ int main_pqosdetach(int argc, char **argv)
return rc;
}
+static void print_cqm_info(const sysctl_cqminfo_t *info, int nb_domain)
+{
+ int i, j;
+ int socket_num = 0;
+ xen_domctl_getdomcqminfo_t *dom_cqminfo;
+
+ printf("RMID count %5d\tRMID available %5d\n", info->resource_count, info->resource_avail);
+ if (info->resource_count == 0)
+ printf("System doesn't supoort CQM\n");
+ else if (info->resource_count - info->resource_avail == 1)
+ printf("No RMID is assigned to domains\n");
+ else if (!nb_domain)
+ printf("No RMID is assgined to your monitoring domains\n");
+ else {
+ printf("Name ID");
+ do {
+ printf("\tSocketID\tL3C_Usage");
+ socket_num++;
+ } while (info->dom_cqminfo->socket_cqmdata[socket_num].valid);
+ printf("\n");
+ for (i = 0; i < nb_domain; i++) {
+ char *domname;
+ dom_cqminfo = info->dom_cqminfo + i;
+ domname = libxl_domid_to_name(ctx, dom_cqminfo->domain);
+ printf("%-40s %5d",
+ domname,
+ dom_cqminfo->domain);
+ free(domname);
+ for(j = 0; j < socket_num; j++)
+ printf("%10u %16lu ", j, dom_cqminfo->socket_cqmdata[j].l3c_occupancy);
+ printf("\n");
+ }
+ }
+}
+int main_pqoslist(int argc, char **argv)
+{
+ int opt;
+ const char *qosres = NULL;
+ uint32_t first_domain;
+ unsigned int max_domains;
+ int num_domains;
+ sysctl_cqminfo_t info;
+
+ SWITCH_FOREACH_OPT(opt, "", NULL, "pqos-list", 1) {
+ /* No options */
+ }
+
+ qosres = argv[optind];
+
+ if (!strcmp(qosres, "cqm")) {
+ if (optind + 1 >= argc) {
+ first_domain = 0;
+ max_domains = 1024;
+ } else if (optind + 1 == argc - 1) {
+ first_domain = find_domain(argv[optind + 1]);
+ max_domains = 1;
+ } else {
+ help("pqos-list");
+ return 2;
+ }
+
+ info.dom_cqminfo = calloc(max_domains,
+ sizeof(xen_domctl_getdomcqminfo_t));
+ if (!info.dom_cqminfo) {
+ fprintf(stderr, "allocating domain cqminfo failed.\n");
+ return ERROR_FAIL;
+ }
+
+ num_domains = libxl_list_domain_cqm(ctx, first_domain,
+ max_domains, &info);
+
+ if (num_domains < 0) {
+ fprintf(stderr, "Failed to get domain CQM info, "
+ "check whether CQM feature is supported.\n");
+ if (info.dom_cqminfo)
+ free(info.dom_cqminfo);
+ return 1;
+ }
+ print_cqm_info(&info, num_domains);
+
+ if (info.dom_cqminfo)
+ free(info.dom_cqminfo);
+ } else {
+ fprintf(stderr, "qos resource type supported is: cqm\n");
+ help("pqos-list");
+ return 2;
+ }
+
+ return 0;
+}
+
/*
* Local variables:
* mode: C
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index 02a2572..6ced416 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -498,6 +498,11 @@ struct cmd_spec cmd_table[] = {
"Reliquish qos resource",
"<Resource> <Domain>",
},
+ { "pqos-list",
+ &main_pqoslist, 0, 0,
+ "List qos information about all/some domains",
+ "<Resource> [Domain]",
+ },
};
int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
--
1.7.9.5
next prev parent reply other threads:[~2013-11-20 3:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-20 3:27 [PATCH 0/8] enable Cache QoS Monitoring (CQM) feature dongxiao.xu
2013-11-20 3:27 ` [PATCH 1/8] x86: detect and initialize Cache QoS Monitoring feature dongxiao.xu
2013-11-20 11:11 ` Andrew Cooper
2013-11-20 12:40 ` Xu, Dongxiao
2013-11-20 3:27 ` [PATCH 2/8] x86: handle CQM resource when creating/destroying guests dongxiao.xu
2013-11-20 11:32 ` Andrew Cooper
2013-11-20 12:49 ` Xu, Dongxiao
2013-11-20 3:27 ` [PATCH 3/8] tools: " dongxiao.xu
2013-11-20 3:27 ` [PATCH 4/8] x86: dynamically attach/detach CQM service for a guest dongxiao.xu
2013-11-20 11:44 ` Andrew Cooper
2013-11-20 13:19 ` Xu, Dongxiao
2013-11-20 3:27 ` [PATCH 5/8] tools: " dongxiao.xu
2013-11-20 3:27 ` [PATCH 6/8] x86: get per domain CQM information dongxiao.xu
2013-11-20 11:56 ` Andrew Cooper
2013-11-20 13:22 ` Xu, Dongxiao
2013-11-20 3:27 ` dongxiao.xu [this message]
2013-11-20 3:27 ` [PATCH 8/8] x86: enable CQM monitoring for each domain RMID dongxiao.xu
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=1384918058-128466-8-git-send-email-dongxiao.xu@intel.com \
--to=dongxiao.xu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).