All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: wei.liu2@citrix.com, Ian.Campbell@citrix.com,
	George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
	Dongxiao Xu <dongxiao.xu@intel.com>,
	JBeulich@suse.com, Chao Peng <chao.p.peng@linux.intel.com>
Subject: [RFC PATCH 6/7] xl: report per-CPU cache occupancy up to libxl
Date: Sat, 04 Apr 2015 04:15:06 +0200	[thread overview]
Message-ID: <20150404021506.22875.85668.stgit@Solace.station> (raw)
In-Reply-To: <20150404020423.22875.23590.stgit@Solace.station>

Now that the functionallity is wired, from within Xen
up to libxl, use that to implement a new mode for
`xl psr-cmt-show', by means of the '-c' switch.

With some pCPUs attached to CMT, the output looks as
follows:

  [root@redbrick ~]# xl psr-cmt-show -c cache_occupancy
  Socket 0:      46080 KB Total L3 Cache Size
   CPU 0:         936 KB
   CPU 1:          72 KB
   CPU 3:           0 KB
  Socket 1:      46080 KB Total L3 Cache Size
   CPU 36:         144 KB
   CPU 48:           0 KB
  Socket 2:      46080 KB Total L3 Cache Size
   CPU 74:           0 KB
   CPU 92:           0 KB
  Socket 3:      46080 KB Total L3 Cache Size
   CPU 121:           0 KB

XXX Columns can be aligned better, I know. ;-P

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
 tools/libxl/xl_cmdimpl.c  |   88 +++++++++++++++++++++++++++++++++++++++++----
 tools/libxl/xl_cmdtable.c |    2 +
 2 files changed, 82 insertions(+), 8 deletions(-)

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 394b55d..d314947 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -8098,6 +8098,62 @@ static void psr_cmt_print_domain_info(libxl_dominfo *dominfo,
     printf("\n");
 }
 
+static bool psr_cmt_print_cpu_info(unsigned int cpu)
+{
+    uint32_t l3_occ;
+
+    if (libxl_psr_cmt_get_cpu_cache_occupancy(ctx, cpu, &l3_occ)) {
+        fprintf(stderr, "can't read the cache occupancy for cpu %u\n", cpu);
+        return false;
+    }
+
+    fprintf(stdout, " CPU %u: %11"PRIu32" KB\n", cpu, l3_occ);
+
+    return true;
+}
+
+static int psr_cmt_show_cpus(int cpu)
+{
+    libxl_cputopology *info;
+    int i, rc = 0, nr_cpus = 0;
+    int socket;
+
+    info = libxl_get_cpu_topology(ctx, &nr_cpus);
+    if (info == NULL) {
+        fprintf(stderr, "libxl_get_topologyinfo failed.\n");
+        return 1;
+    }
+
+    socket = -1;
+    for (i = cpu > 0 ? cpu : 0; i <= (cpu > 0 ? cpu : nr_cpus-1); i++) {
+        uint32_t l3_size;
+
+        if (!libxl_psr_cmt_cpu_attached(ctx, i))
+            continue;
+
+        if (socket != info[i].socket) {
+            if (libxl_psr_cmt_get_l3_cache_size(ctx, info[i].socket,
+                                                &l3_size)) {
+                fprintf(stderr, "Failed to get L3 cache size for socket:%d\n",
+                        info[i].socket);
+                rc = 1;
+                goto out;
+            }
+            fprintf(stdout, "Socket %u:%11"PRIu32" KB Total L3 Cache Size\n",
+                    info[i].socket, l3_size);
+            socket = info[i].socket;
+        }
+        if (!psr_cmt_print_cpu_info(i)) {
+            rc = 1;
+            goto out;
+        }
+    }
+
+ out:
+    libxl_cputopology_list_free(info, nr_cpus);
+    return rc;
+}
+
 static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
 {
     uint32_t i, socketid, nr_sockets, total_rmid;
@@ -8105,11 +8161,6 @@ static int psr_cmt_show(libxl_psr_cmt_type type, uint32_t domid)
     libxl_physinfo info;
     int rc, nr_domains;
 
-    if (!libxl_psr_cmt_enabled(ctx)) {
-        fprintf(stderr, "CMT is disabled in the system\n");
-        return -1;
-    }
-
     if (!libxl_psr_cmt_type_supported(ctx, type)) {
         fprintf(stderr, "Monitor type '%s' is not supported in the system\n",
                 libxl_psr_cmt_type_to_string(type));
@@ -8213,11 +8264,20 @@ int main_psr_cmt_detach(int argc, char **argv)
 int main_psr_cmt_show(int argc, char **argv)
 {
     int opt, ret = 0;
+    bool cpus = false;
     uint32_t domid;
     libxl_psr_cmt_type type;
+    static struct option opts[] = {
+        {"cpus", 0, 0, 'c'},
+        COMMON_LONG_OPTS,
+        {0, 0, 0, 0}
+    };
 
-    SWITCH_FOREACH_OPT(opt, "", NULL, "psr-cmt-show", 1) {
-        /* No options */
+
+    SWITCH_FOREACH_OPT(opt, "c", opts, "psr-cmt-show", 1) {
+        case 'c':
+            cpus = true;
+            break;
     }
 
     if (!strcmp(argv[optind], "cache_occupancy"))
@@ -8231,6 +8291,15 @@ int main_psr_cmt_show(int argc, char **argv)
         return 2;
     }
 
+    if (cpus) {
+        if (type != LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY) {
+            fprintf(stderr, "CPU monitoring supported for cache only\n");
+            return -1;
+        }
+        ret = psr_cmt_show_cpus(-1);
+        return ret;
+    }
+
     if (optind + 1 >= argc)
         domid = INVALID_DOMID;
     else if (optind + 1 == argc - 1)
@@ -8240,6 +8309,11 @@ int main_psr_cmt_show(int argc, char **argv)
         return 2;
     }
 
+    if (!libxl_psr_cmt_enabled(ctx)) {
+        fprintf(stderr, "CMT is disabled in the system\n");
+        return -1;
+    }
+
     ret = psr_cmt_show(type, domid);
 
     return ret;
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index 9284887..5bbe406 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -537,7 +537,7 @@ struct cmd_spec cmd_table[] = {
     { "psr-cmt-show",
       &main_psr_cmt_show, 0, 1,
       "Show Cache Monitoring Technology information",
-      "<PSR-CMT-Type> <Domain>",
+      "<PSR-CMT-Type> [-c | <Domain>]",
       "Available monitor types:\n"
       "\"cache_occupancy\":         Show L3 cache occupancy(KB)\n"
       "\"total_mem_bandwidth\":     Show total memory bandwidth(KB/s)\n"

  parent reply	other threads:[~2015-04-04  2:15 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-04  2:14 [RFC PATCH 0/7] Intel Cache Monitoring: Current Status and Future Opportunities Dario Faggioli
2015-04-04  2:14 ` [RFC PATCH 1/7] x86: improve psr scheduling code Dario Faggioli
2015-04-06 13:48   ` Konrad Rzeszutek Wilk
2015-04-04  2:14 ` [RFC PATCH 2/7] Xen: x86: print max usable RMID during init Dario Faggioli
2015-04-06 13:48   ` Konrad Rzeszutek Wilk
2015-04-07 10:11     ` Dario Faggioli
2015-04-04  2:14 ` [RFC PATCH 3/7] xen: psr: reserve an RMID for each core Dario Faggioli
2015-04-06 13:59   ` Konrad Rzeszutek Wilk
2015-04-07 10:19     ` Dario Faggioli
2015-04-07 13:57       ` Konrad Rzeszutek Wilk
2015-04-07  8:24   ` Chao Peng
2015-04-07 10:07     ` Dario Faggioli
2015-04-08 13:28   ` George Dunlap
2015-04-08 14:03     ` Dario Faggioli
2015-04-04  2:14 ` [RFC PATCH 4/7] xen: libxc: libxl: report per-CPU cache occupancy up to libxl Dario Faggioli
2015-04-04  2:14 ` [RFC PATCH 5/7] xen: libxc: libxl: allow for attaching and detaching a CPU to CMT Dario Faggioli
2015-04-04  2:15 ` Dario Faggioli [this message]
2015-04-04  2:15 ` [RFC PATCH 7/7] xl: " Dario Faggioli
2015-04-07  8:19 ` [RFC PATCH 0/7] Intel Cache Monitoring: Current Status and Future Opportunities Chao Peng
2015-04-07  9:51   ` Dario Faggioli
2015-04-07 10:27 ` Andrew Cooper
2015-04-07 13:10   ` Dario Faggioli
2015-04-08  5:59     ` Chao Peng
2015-04-08  8:23       ` Dario Faggioli
2015-04-08  8:53         ` Andrew Cooper
2015-04-08  8:55         ` Chao Peng
2015-04-09 15:44     ` Meng Xu
2015-04-08 11:27   ` George Dunlap
2015-04-08 13:29     ` Dario Faggioli
2015-04-08 11:30 ` George Dunlap
2015-04-08 13:16   ` Dario Faggioli
2015-04-09 15:37 ` Meng 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=20150404021506.22875.85668.stgit@Solace.station \
    --to=dario.faggioli@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=dongxiao.xu@intel.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.