From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, marcandre.lureau@gmail.com
Subject: Re: [Qemu-devel] [PATCH v4 2/2] memory: hmp: add "-f" for "info mtree"
Date: Tue, 17 Jan 2017 17:37:25 +0000 [thread overview]
Message-ID: <20170117173724.GF2053@work-vm> (raw)
In-Reply-To: <1484556005-29701-3-git-send-email-peterx@redhat.com>
* Peter Xu (peterx@redhat.com) wrote:
> Adding one more option "-f" for "info mtree" to dump the flat views of
> all the address spaces.
>
> This will be useful to debug the memory rendering logic, also it'll be
> much easier with it to know what memory region is handling what address
> range.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> hmp-commands-info.hx | 6 +++---
> include/exec/memory.h | 2 +-
> memory.c | 41 ++++++++++++++++++++++++++++++++++++++++-
> monitor.c | 4 +++-
> 4 files changed, 47 insertions(+), 6 deletions(-)
>
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index 55d50c4..b0f35e6 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -249,9 +249,9 @@ ETEXI
>
> {
> .name = "mtree",
> - .args_type = "",
> - .params = "",
> - .help = "show memory tree",
> + .args_type = "flatview:-f",
> + .params = "[-f]",
> + .help = "show memory tree (-f: dump flat view for address spaces)",
> .cmd = hmp_info_mtree,
> },
>
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index bec9756..71db380 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -1254,7 +1254,7 @@ void memory_global_dirty_log_start(void);
> */
> void memory_global_dirty_log_stop(void);
>
> -void mtree_info(fprintf_function mon_printf, void *f);
> +void mtree_info(fprintf_function mon_printf, void *f, bool flatview);
>
> /**
> * memory_region_dispatch_read: perform a read directly to the specified
> diff --git a/memory.c b/memory.c
> index c42bde4..6498727 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -2564,12 +2564,51 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
> }
> }
>
> -void mtree_info(fprintf_function mon_printf, void *f)
> +static void mtree_print_flatview(fprintf_function p, void *f,
> + AddressSpace *as)
> +{
> + FlatView *view = address_space_get_flatview(as);
> + FlatRange *range = &view->ranges[0];
> + MemoryRegion *mr;
> + int n = view->nr;
> +
> + if (n <= 0) {
> + p(f, MTREE_INDENT "No rendered FlatView for "
> + "address space '%s'\n", as->name);
> + flatview_unref(view);
> + return;
> + }
> +
> + while (n--) {
> + mr = range->mr;
> + p(f, MTREE_INDENT TARGET_FMT_plx "-"
> + TARGET_FMT_plx " (prio %d, %s): %s\n",
> + int128_get64(range->addr.start),
> + int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
> + mr->priority,
> + memory_region_type(mr),
> + memory_region_name(mr));
> + range++;
> + }
> +
> + flatview_unref(view);
> +}
> +
> +void mtree_info(fprintf_function mon_printf, void *f, bool flatview)
> {
> MemoryRegionListHead ml_head;
> MemoryRegionList *ml, *ml2;
> AddressSpace *as;
>
> + if (flatview) {
> + QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
> + mon_printf(f, "address-space (flat view): %s\n", as->name);
> + mtree_print_flatview(mon_printf, f, as);
> + mon_printf(f, "\n");
> + }
> + return;
> + }
> +
> QTAILQ_INIT(&ml_head);
>
> QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
> diff --git a/monitor.c b/monitor.c
> index 0841d43..679cd52 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1529,7 +1529,9 @@ static void hmp_boot_set(Monitor *mon, const QDict *qdict)
>
> static void hmp_info_mtree(Monitor *mon, const QDict *qdict)
> {
> - mtree_info((fprintf_function)monitor_printf, mon);
> + bool flatview = qdict_get_try_bool(qdict, "flatview", false);
> +
> + mtree_info((fprintf_function)monitor_printf, mon, flatview);
> }
>
> static void hmp_info_numa(Monitor *mon, const QDict *qdict)
> --
> 2.7.4
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-01-17 17:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-16 8:40 [Qemu-devel] [PATCH v4 0/2] memory: extend "info mtree" with flat view dump Peter Xu
2017-01-16 8:40 ` [Qemu-devel] [PATCH v4 1/2] memory: tune mtree_print_mr() to dump mr type Peter Xu
2017-01-17 19:23 ` Dr. David Alan Gilbert
2017-01-16 8:40 ` [Qemu-devel] [PATCH v4 2/2] memory: hmp: add "-f" for "info mtree" Peter Xu
2017-01-17 17:37 ` Dr. David Alan Gilbert [this message]
2017-01-18 9:05 ` [Qemu-devel] [PATCH v4 0/2] memory: extend "info mtree" with flat view dump Paolo Bonzini
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=20170117173724.GF2053@work-vm \
--to=dgilbert@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.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.