[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Tools: Add a sharing command to xl for information about shared pages
# HG changeset patch # User Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx> # Date 1327581986 0 # Node ID aadccbbbb84664a907d3c5287ca39cbceb4e3fa3 # Parent 1a3e534cd11e7ed93ccd98b892a8c255c2d05287 Tools: Add a sharing command to xl for information about shared pages Also add the global sharing statistics to the libxl physinfo. This is a slight departure from libxc, but there's no reason libxl physinfo can't include extra bits of useful and relevant information. Signed-off-by: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx> Signed-off-by: Adin Scannell <adin@xxxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Committed-by: Tim Deegan <tim@xxxxxxx> --- diff -r 1a3e534cd11e -r aadccbbbb846 docs/man/xl.pod.1 --- a/docs/man/xl.pod.1 Thu Jan 26 12:46:26 2012 +0000 +++ b/docs/man/xl.pod.1 Thu Jan 26 12:46:26 2012 +0000 @@ -410,6 +410,19 @@ =back +=item B<sharing> [I<domain-id>] + +List count of shared pages. + +B<OPTIONS> + +=over 4 + +=item I<domain_id> + +List specifically for that domain. Otherwise, list for all domains. + +=back =item B<shutdown> [I<OPTIONS>] I<domain-id> diff -r 1a3e534cd11e -r aadccbbbb846 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Thu Jan 26 12:46:26 2012 +0000 +++ b/tools/libxl/libxl.c Thu Jan 26 12:46:26 2012 +0000 @@ -2507,6 +2507,8 @@ physinfo->total_pages = xcphysinfo.total_pages; physinfo->free_pages = xcphysinfo.free_pages; physinfo->scrub_pages = xcphysinfo.scrub_pages; + physinfo->sharing_freed_pages = xc_sharing_freed_pages(ctx->xch); + physinfo->sharing_used_frames = xc_sharing_used_frames(ctx->xch); physinfo->nr_nodes = xcphysinfo.nr_nodes; memcpy(physinfo->hw_cap,xcphysinfo.hw_cap, sizeof(physinfo->hw_cap)); physinfo->phys_cap = xcphysinfo.capabilities; diff -r 1a3e534cd11e -r aadccbbbb846 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Thu Jan 26 12:46:26 2012 +0000 +++ b/tools/libxl/libxl_types.idl Thu Jan 26 12:46:26 2012 +0000 @@ -367,6 +367,8 @@ ("total_pages", uint64), ("free_pages", uint64), ("scrub_pages", uint64), + ("sharing_freed_pages", uint64), + ("sharing_used_frames", uint64), ("nr_nodes", uint32), ("hw_cap", libxl_hwcap), diff -r 1a3e534cd11e -r aadccbbbb846 tools/libxl/xl.h --- a/tools/libxl/xl.h Thu Jan 26 12:46:26 2012 +0000 +++ b/tools/libxl/xl.h Thu Jan 26 12:46:26 2012 +0000 @@ -28,6 +28,7 @@ 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 1a3e534cd11e -r aadccbbbb846 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Thu Jan 26 12:46:26 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Thu Jan 26 12:46:26 2012 +0000 @@ -3701,6 +3701,8 @@ i = (1 << 20) / vinfo->pagesize; printf("total_memory : %"PRIu64"\n", info.total_pages / i); printf("free_memory : %"PRIu64"\n", info.free_pages / i); + printf("sharing_freed_memory : %"PRIu64"\n", info.sharing_freed_pages / i); + printf("sharing_used_memory : %"PRIu64"\n", info.sharing_used_frames / i); } if (!libxl_get_freecpus(ctx, &cpumap)) { libxl_for_each_cpu(i, cpumap) @@ -3784,6 +3786,70 @@ return 0; } +static void sharing(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); + } +} + +int main_sharing(int argc, char **argv) +{ + int opt = 0; + libxl_dominfo info_buf; + libxl_dominfo *info, *info_free = NULL; + int nb_domain, rc; + + if ((opt = def_getopt(argc, argv, "", "sharing", 0)) != -1) + return opt; + + 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(info, nb_domain); + + if (info_free) + free(info_free); + + return 0; +} + static int sched_credit_domain_get( int domid, libxl_sched_credit *scinfo) { diff -r 1a3e534cd11e -r aadccbbbb846 tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c Thu Jan 26 12:46:26 2012 +0000 +++ b/tools/libxl/xl_cmdtable.c Thu Jan 26 12:46:26 2012 +0000 @@ -189,6 +189,11 @@ "Get information about Xen host", "-n, --numa List host NUMA topology information", }, + { "sharing", + &main_sharing, 0, + "Get information about page sharing", + "[Domain]", + }, { "sched-credit", &main_sched_credit, 0, "Get/set credit scheduler parameters", _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |