Re: [Qemu-devel] [PATCH v2 2/2] memory: hmp: dump flat view for 'info mtree'

2017-01-11 Thread Peter Xu
On Wed, Jan 11, 2017 at 06:13:11PM +0100, Paolo Bonzini wrote:
> 
> 
> On 21/12/2016 08:58, Peter Xu wrote:
> > Dumping flat view 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 
> 
> This is useful, but dumping both makes the output very long.  What about
> adding a -f option to "info mtree"?

Sure. :)

After I confirm how I should improve on the first patch, I'll cook
another version for the series with "-f".

Thanks,

-- peterx



Re: [Qemu-devel] [PATCH v2 2/2] memory: hmp: dump flat view for 'info mtree'

2017-01-11 Thread Paolo Bonzini


On 21/12/2016 08:58, Peter Xu wrote:
> Dumping flat view 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 

This is useful, but dumping both makes the output very long.  What about
adding a -f option to "info mtree"?

Paolo

> ---
>  memory.c | 31 +++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/memory.c b/memory.c
> index 5dcc2e1..91341d3 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -2545,6 +2545,36 @@ static void mtree_print_mr(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 = >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);
> +return;
> +}
> +
> +p(f, MTREE_INDENT "FlatView (address space '%s'):\n", as->name);
> +
> +while (n--) {
> +mr = range->mr;
> +p(f, MTREE_INDENT MTREE_INDENT TARGET_FMT_plx "-"
> +  TARGET_FMT_plx " (prio %d, %c%c): %s\n",
> +  int128_get64(range->addr.start),
> +  int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
> +  mr->priority, MR_CHAR_RD(mr), MR_CHAR_WR(mr),
> +  memory_region_name(mr));
> +range++;
> +}
> +
> +flatview_unref(view);
> +}
> +
>  void mtree_info(fprintf_function mon_printf, void *f)
>  {
>  MemoryRegionListHead ml_head;
> @@ -2556,6 +2586,7 @@ void mtree_info(fprintf_function mon_printf, void *f)
>  QTAILQ_FOREACH(as, _spaces, address_spaces_link) {
>  mon_printf(f, "address-space: %s\n", as->name);
>  mtree_print_mr(mon_printf, f, as->root, 1, 0, _head);
> +mtree_print_flatview(mon_printf, f, as);
>  mon_printf(f, "\n");
>  }
>  
> 



[Qemu-devel] [PATCH v2 2/2] memory: hmp: dump flat view for 'info mtree'

2016-12-21 Thread Peter Xu
Dumping flat view 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 
---
 memory.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/memory.c b/memory.c
index 5dcc2e1..91341d3 100644
--- a/memory.c
+++ b/memory.c
@@ -2545,6 +2545,36 @@ static void mtree_print_mr(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 = >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);
+return;
+}
+
+p(f, MTREE_INDENT "FlatView (address space '%s'):\n", as->name);
+
+while (n--) {
+mr = range->mr;
+p(f, MTREE_INDENT MTREE_INDENT TARGET_FMT_plx "-"
+  TARGET_FMT_plx " (prio %d, %c%c): %s\n",
+  int128_get64(range->addr.start),
+  int128_get64(range->addr.start) + MR_SIZE(range->addr.size),
+  mr->priority, MR_CHAR_RD(mr), MR_CHAR_WR(mr),
+  memory_region_name(mr));
+range++;
+}
+
+flatview_unref(view);
+}
+
 void mtree_info(fprintf_function mon_printf, void *f)
 {
 MemoryRegionListHead ml_head;
@@ -2556,6 +2586,7 @@ void mtree_info(fprintf_function mon_printf, void *f)
 QTAILQ_FOREACH(as, _spaces, address_spaces_link) {
 mon_printf(f, "address-space: %s\n", as->name);
 mtree_print_mr(mon_printf, f, as->root, 1, 0, _head);
+mtree_print_flatview(mon_printf, f, as);
 mon_printf(f, "\n");
 }
 
-- 
2.7.4