[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 7/8] tools: get per domain CQM information



From: Dongxiao Xu <dongxiao.xu@xxxxxxxxx>

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@xxxxxxxxx>
Signed-off-by: Dongxiao Xu <dongxiao.xu@xxxxxxxxx>
---
 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


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.