All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xensource.com
Cc: ian.campbell@citrix.com, andres@gridcentric.ca, tim@xen.org,
	keir.xen@gmail.com, JBeulich@suse.com, ian.jackson@citrix.com,
	adin@gridcentric.ca
Subject: [PATCH 08 of 18] Tools: Add a sharing command to xl for information about shared pages
Date: Thu, 08 Dec 2011 02:47:23 -0500	[thread overview]
Message-ID: <24d514cd4dee7d0d0cc9.1323330443@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1323330435@xdev.gridcentric.ca>

 tools/libxl/xl.h          |   1 +
 tools/libxl/xl_cmdimpl.c  |  85 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/xl_cmdtable.c |   6 +++
 3 files changed, 92 insertions(+), 0 deletions(-)


Signed-off-by: Adin Scannell <adin@scannell.ca>

diff -r 8d2a8094ace5 -r 24d514cd4dee tools/libxl/xl.h
--- a/tools/libxl/xl.h
+++ b/tools/libxl/xl.h
@@ -28,6 +28,7 @@ struct cmd_spec {
 
 int main_vcpulist(int argc, char **argv);
 int main_info(int argc, char **argv);
+int main_sharing(int argc, char **argv);
 int main_cd_eject(int argc, char **argv);
 int main_cd_insert(int argc, char **argv);
 int main_console(int argc, char **argv);
diff -r 8d2a8094ace5 -r 24d514cd4dee tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3755,6 +3755,91 @@ int main_info(int argc, char **argv)
     return 0;
 }
 
+static void sharing(int totals, const libxl_dominfo *info, int nb_domain)
+{
+    int i;
+
+    printf("Name                                        ID   Mem Shared\n");
+
+    for (i = 0; i < nb_domain; i++) {
+        char *domname;
+        unsigned shutdown_reason;
+        domname = libxl_domid_to_name(ctx, info[i].domid);
+        shutdown_reason = info[i].shutdown ? info[i].shutdown_reason : 0;
+        printf("%-40s %5d %5lu  %5lu\n",
+                domname,
+                info[i].domid,
+                (unsigned long) (info[i].current_memkb / 1024),
+                (unsigned long) (info[i].shared_memkb / 1024));
+        free(domname);
+    }
+
+    if (totals)
+    {
+        /* To be added with a future patch. */
+    }
+}
+
+int main_sharing(int argc, char **argv)
+{
+    int opt;
+    int option_index = 0;
+    static struct option long_options[] = {
+        {"help", 0, 0, 'h'},
+        {"totals", 0, 0, 't'},
+        {0, 0, 0, 0}
+    };
+    int totals = 0;
+
+    libxl_dominfo info_buf;
+    libxl_dominfo *info, *info_free=0;
+    int nb_domain, rc;
+
+    while ((opt = getopt_long(argc, argv, "ht", long_options, &option_index)) != -1) {
+        switch (opt) {
+        case 'h':
+            help("sharing");
+            return 0;
+        case 't':
+            totals = 1;
+            break;
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", optopt);
+            break;
+        }
+    }
+
+    if (optind >= argc) {
+        info = libxl_list_domain(ctx, &nb_domain);
+        if (!info) {
+            fprintf(stderr, "libxl_domain_infolist failed.\n");
+            return 1;
+        }
+        info_free = info;
+    } else if (optind == argc-1) {
+        find_domain(argv[optind]);
+        rc = libxl_domain_info(ctx, &info_buf, domid);
+        if (rc == ERROR_INVAL) {
+            fprintf(stderr, "Error: Domain \'%s\' does not exist.\n",
+                argv[optind]);
+            return -rc;
+        }
+        if (rc) {
+            fprintf(stderr, "libxl_domain_info failed (code %d).\n", rc);
+            return -rc;
+        }
+        info = &info_buf;
+        nb_domain = 1;
+    } else {
+        help("sharing");
+        return 2;
+    }
+
+    sharing(totals, info, nb_domain);
+
+    return 0;
+}
+
 static int sched_credit_domain_get(
     int domid, libxl_sched_credit *scinfo)
 {
diff -r 8d2a8094ace5 -r 24d514cd4dee tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -189,6 +189,12 @@ struct cmd_spec cmd_table[] = {
       "Get information about Xen host",
       "-n, --numa         List host NUMA topology information",
     },
+    { "sharing",
+      &main_sharing, 0,
+      "Get information about page sharing",
+      "[options] [Domain]", 
+      "-t, --totals              Include host totals in the output",
+    },
     { "sched-credit",
       &main_sched_credit, 0,
       "Get/set credit scheduler parameters",

  parent reply	other threads:[~2011-12-08  7:47 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-08  7:47 [PATCH 00 of 18] Memory sharing overhaul Andres Lagar-Cavilla
2011-12-08  7:47 ` [PATCH 01 of 18] x86/mm: Code style fixes in mem_sharing.c Andres Lagar-Cavilla
2011-12-08 11:11   ` Tim Deegan
2011-12-08 16:16     ` Andres Lagar-Cavilla
2011-12-08 21:54       ` Tim Deegan
2011-12-08  7:47 ` [PATCH 02 of 18] x86/mm: Making a page sharable sets PGT_validated, but making a page private doesn't expect it Andres Lagar-Cavilla
2011-12-08 11:16   ` Tim Deegan
2011-12-08  7:47 ` [PATCH 03 of 18] x86/mm: Eliminate hash table in sharing code as index of shared mfns Andres Lagar-Cavilla
2011-12-08 22:13   ` Tim Deegan
2011-12-08  7:47 ` [PATCH 04 of 18] x86/mm: Update mem sharing interface to (re)allow sharing of grants Andres Lagar-Cavilla
2011-12-08 22:20   ` Tim Deegan
2011-12-09  2:57     ` Andres Lagar-Cavilla
2011-12-08  7:47 ` [PATCH 05 of 18] Tools: Do not assume sharing target is dom0 in libxc wrappers Andres Lagar-Cavilla
2011-12-09 10:01   ` Ian Jackson
2011-12-08  7:47 ` [PATCH 06 of 18] Tools: Update libxc mem sharing interface Andres Lagar-Cavilla
2011-12-09  9:59   ` Ian Jackson
2011-12-08  7:47 ` [PATCH 07 of 18] Tools: Update memshr tool to use new sharing API Andres Lagar-Cavilla
2011-12-09  9:59   ` Ian Jackson
2011-12-08  7:47 ` Andres Lagar-Cavilla [this message]
2011-12-09 10:08   ` [PATCH 08 of 18] Tools: Add a sharing command to xl for information about shared pages Ian Jackson
2011-12-09 14:43     ` Andres Lagar-Cavilla
2011-12-09 10:10   ` Ian Campbell
2011-12-09 11:29     ` Ian Jackson
2011-12-08  7:47 ` [PATCH 09 of 18] x86/mm: Check how many mfns are shared, in addition to how many are saved Andres Lagar-Cavilla
2011-12-08 22:27   ` Tim Deegan
2011-12-08  7:47 ` [PATCH 10 of 18] Tools: Expose to libxc the total number of shared frames and space saved Andres Lagar-Cavilla
2011-12-08  7:47 ` [PATCH 11 of 18] Tools: Allow libxl/xl to expose " Andres Lagar-Cavilla
2011-12-09 10:02   ` Ian Jackson
2011-12-08  7:47 ` [PATCH 12 of 18] x86/mm: Make page_lock/unlock() in arch/x86/mm.c externally callable Andres Lagar-Cavilla
2011-12-08 22:38   ` Tim Deegan
2011-12-08 23:06     ` Keir Fraser
2011-12-09  3:01       ` Andres Lagar-Cavilla
2011-12-09  8:17         ` Keir Fraser
2011-12-09 14:47           ` Andres Lagar-Cavilla
2011-12-09  2:54     ` Andres Lagar-Cavilla
2011-12-09  8:51       ` Jan Beulich
2011-12-09 14:53         ` Andres Lagar-Cavilla
2011-12-09 15:06           ` Jan Beulich
2011-12-09 17:34             ` Andres Lagar-Cavilla
2011-12-09 14:57       ` Tim Deegan
2011-12-09 14:59         ` Andres Lagar-Cavilla
2011-12-09 15:02         ` Keir Fraser

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=24d514cd4dee7d0d0cc9.1323330443@xdev.gridcentric.ca \
    --to=andres@lagarcavilla.org \
    --cc=JBeulich@suse.com \
    --cc=adin@gridcentric.ca \
    --cc=andres@gridcentric.ca \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@citrix.com \
    --cc=keir.xen@gmail.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /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.