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

Re: [Xen-devel] [PATCH 11 of 12] Tools: Add a sharing command to xl for information about shared pages



On Mon, 2012-01-16 at 02:56 +0000, Andres Lagar-Cavilla wrote:
> docs/man/xl.pod.1           |  13 ++++++++
>  tools/libxl/libxl.c         |   2 +
>  tools/libxl/libxl_types.idl |   2 +
>  tools/libxl/xl.h            |   1 +
>  tools/libxl/xl_cmdimpl.c    |  66 
> +++++++++++++++++++++++++++++++++++++++++++++
>  tools/libxl/xl_cmdtable.c   |   5 +++
>  6 files changed, 89 insertions(+), 0 deletions(-)
> 
> 
> 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>

> 
> diff -r b596035ff0e2 -r 6522ae36bc61 docs/man/xl.pod.1
> --- a/docs/man/xl.pod.1
> +++ b/docs/man/xl.pod.1
> @@ -410,6 +410,19 @@ Leave domain running after creating the 
>  
>  =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 b596035ff0e2 -r 6522ae36bc61 tools/libxl/libxl.c
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -2518,6 +2518,8 @@ int libxl_get_physinfo(libxl_ctx *ctx, l
>      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 b596035ff0e2 -r 6522ae36bc61 tools/libxl/libxl_types.idl
> --- a/tools/libxl/libxl_types.idl
> +++ b/tools/libxl/libxl_types.idl
> @@ -366,6 +366,8 @@ libxl_physinfo = Struct("physinfo", [
>      ("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 b596035ff0e2 -r 6522ae36bc61 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 b596035ff0e2 -r 6522ae36bc61 tools/libxl/xl_cmdimpl.c
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -3693,6 +3693,8 @@ static void output_physinfo(void)
>          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)
> @@ -3776,6 +3778,70 @@ int main_info(int argc, char **argv)
>      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 b596035ff0e2 -r 6522ae36bc61 tools/libxl/xl_cmdtable.c
> --- a/tools/libxl/xl_cmdtable.c
> +++ b/tools/libxl/xl_cmdtable.c
> @@ -189,6 +189,11 @@ 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",
> +      "[Domain]", 
> +    },
>      { "sched-credit",
>        &main_sched_credit, 0,
>        "Get/set credit scheduler parameters",



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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