All of lore.kernel.org
 help / color / mirror / Atom feed
From: Blue Swirl <blauwirbel@gmail.com>
To: qemu-devel <qemu-devel@nongnu.org>, Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] [PATCH] memory: simple memory tree printer
Date: Sun, 11 Sep 2011 20:31:36 +0000	[thread overview]
Message-ID: <CAAu8pHvpbYBuOKa6Krsd6R00qidBx+J6ObaqZT40zuYh+SZn9g@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 7268 bytes --]

Add a monitor command 'info mtree' to show the memory hierarchy.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
Example output:
qemu-system-i386 -monitor stdio
QEMU 0.15.50 monitor - type 'help' for more information
(qemu) info mtree
memory
system addr 0000000000000000 off 0000000000000000 size 7fffffffffffffff
-pam-ram addr 00000000000ec000 off 0000000000000000 size 4000
-pam-ram addr 00000000000e8000 off 0000000000000000 size 4000
-pam-ram addr 00000000000e4000 off 0000000000000000 size 4000
-pam-ram addr 00000000000e0000 off 0000000000000000 size 4000
-pam-ram addr 00000000000dc000 off 0000000000000000 size 4000
-pam-ram addr 00000000000d8000 off 0000000000000000 size 4000
-pam-ram addr 00000000000d4000 off 0000000000000000 size 4000
-pam-ram addr 00000000000d0000 off 0000000000000000 size 4000
-pam-ram addr 00000000000cc000 off 0000000000000000 size 4000
-pam-rom addr 00000000000c8000 off 0000000000000000 size 4000
-pam-rom addr 00000000000c4000 off 0000000000000000 size 4000
-pam-rom addr 00000000000c0000 off 0000000000000000 size 4000
-pam-rom addr 00000000000f0000 off 0000000000000000 size 10000
-smram-region addr 00000000000a0000 off 0000000000000000 size 20000
-pci-hole64 addr 4000000000000000 off 0000000000000000 size 4000000000000000
-pci-hole addr 0000000008000000 off 0000000000000000 size f8000000
-ram-below-4g addr 0000000000000000 off 0000000000000000 size 8000000
-apic addr 00000000fee00000 off 0000000000000000 size 100000
I/O
io addr 0000000000000000 off 0000000000000000 size 10000
-e1000-io addr 000000000000c000 off 0000000000000000 size 40
-piix-bmdma-container addr 000000000000c040 off 0000000000000000 size 10
--bmdma addr 000000000000000c off 0000000000000000 size 4
--piix-bmdma addr 0000000000000008 off 0000000000000000 size 4
--bmdma addr 0000000000000004 off 0000000000000000 size 4
--piix-bmdma addr 0000000000000000 off 0000000000000000 size 4
-pci-conf-data addr 0000000000000cfc off 0000000000000000 size 4
-pci-conf-idx addr 0000000000000cf8 off 0000000000000000 size 4

Sparc
memory
system addr 0000000000000000 off 0000000000000000 size 7fffffffffffffff
-escc addr 0000000071100000 off 0000000000000000 size 8
-escc addr 0000000071000000 off 0000000000000000 size 8
-lance-mmio addr 0000000078c00000 off 0000000000000000 size 4
I/O
io addr 0000000000000000 off 0000000000000000 size 10000

Sparc64
memory
system addr 0000000000000000 off 0000000000000000 size 7fffffffffffffff
-pci-mmio addr 000001ff00000000 off 0000000000000000 size 100000000
--vga.chain4 addr 00000000000a0000 off 0000000000000000 size 10000
--isa-mmio addr 0000000003000000 off 0000000000000000 size 800000
--isa-mmio addr 0000000002000000 off 0000000000000000 size 1000000
--vga.rom addr 0000000001000000 off 0000000000000000 size 10000
--vga.vram addr 0000000000800000 off 0000000000000000 size 800000
--vga-lowmem addr 000001fe020a0000 off 0000000000000000 size 20000
-apb-pci-ioport addr 000001fe02000000 off 0000000000000000 size 10000
-apb-pci-config addr 000001fe01000000 off 0000000000000000 size 1000000
-apb-config addr 000001fe00000000 off 0000000000000000 size 10000
I/O
io addr 0000000000000000 off 0000000000000000 size 10000
-cmd646-bmdma addr 0000000000000700 off 0000000000000000 size 10
--cmd646-bmdma-ioport addr 000000000000000c off 0000000000000000 size 4
--cmd646-bmdma-bus addr 0000000000000008 off 0000000000000000 size 4
--cmd646-bmdma-ioport addr 0000000000000004 off 0000000000000000 size 4
--cmd646-bmdma-bus addr 0000000000000000 off 0000000000000000 size 4
-cmd646-cmd addr 0000000000000680 off 0000000000000000 size 4
-cmd646-data addr 0000000000000600 off 0000000000000000 size 8
-cmd646-cmd addr 0000000000000580 off 0000000000000000 size 4
-cmd646-data addr 0000000000000500 off 0000000000000000 size 8
-ne2000 addr 0000000000000400 off 0000000000000000 size 100

PPC
memory
system addr 00000000 off 00000000 size 7fffffffffffffff
-vga.chain4 addr 000a0000 off 00000000 size 10000
-macio addr 80880000 off 00000000 size 80000
--macio-nvram addr 00060000 off 00000000 size 20000
--pmac-ide addr 00020000 off 00000000 size 1000
--(null) addr 00016000 off 00000000 size 0
--escc-bar addr 00013000 off 00000000 size 40
--dbdma addr 00008000 off 00000000 size 1000
--heathrow-pic addr 00000000 off 00000000 size 1000
-vga.rom addr 80800000 off 00000000 size 10000
-vga.vram addr 80000000 off 00000000 size 800000
-vga-lowmem addr 800a0000 off 00000000 size 20000
-escc addr 80013000 off 00000000 size 40
-pci-data-idx addr fee00000 off 00000000 size 1000
-pci-conf-idx addr fec00000 off 00000000 size 1000
-isa-mmio addr fe000000 off 00000000 size 200000
I/O
io addr 00000000 off 00000000 size 10000
-cmd646-bmdma addr 00000700 off 00000000 size 10
--cmd646-bmdma-ioport addr 0000000c off 00000000 size 4
--cmd646-bmdma-bus addr 00000008 off 00000000 size 4
--cmd646-bmdma-ioport addr 00000004 off 00000000 size 4
--cmd646-bmdma-bus addr 00000000 off 00000000 size 4
-cmd646-cmd addr 00000680 off 00000000 size 4
-cmd646-data addr 00000600 off 00000000 size 8
-cmd646-cmd addr 00000580 off 00000000 size 4
-cmd646-data addr 00000500 off 00000000 size 8
-ne2000 addr 00000400 off 00000000 size 100

NB: (null) does not look OK.

Field 'offset' is always zero, maybe that is not interesting. Will it
become one day?

---
 memory.c  |   27 +++++++++++++++++++++++++++
 memory.h  |    2 ++
 monitor.c |    7 +++++++
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/memory.c b/memory.c
index 57f0fa4..0bcef84 100644
--- a/memory.c
+++ b/memory.c
@@ -17,6 +17,7 @@
 #include "bitops.h"
 #include "kvm.h"
 #include <assert.h>
+#include "monitor.h"

 unsigned memory_region_transaction_depth = 0;

@@ -1253,3 +1254,29 @@ void set_system_io_map(MemoryRegion *mr)
     address_space_io.root = mr;
     memory_region_update_topology();
 }
+
+static void mtree_print_mr(Monitor *mon, MemoryRegion *mr, unsigned int level)
+{
+    MemoryRegion *submr;
+    unsigned int i;
+
+    for (i = 0; i < level; i++) {
+        monitor_printf(mon, "-");
+    }
+    monitor_printf(mon, "%s addr " TARGET_FMT_plx " off " TARGET_FMT_plx
+                   " size %" PRIx64 "\n",
+                   mr->name, mr->addr, mr->offset, mr->size);
+
+    QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
+        mtree_print_mr(mon, submr, level + 1);
+    }
+}
+
+void mtree_info(Monitor *mon)
+{
+    monitor_printf(mon, "memory\n");
+    mtree_print_mr(mon, address_space_memory.root, 0);
+
+    monitor_printf(mon, "I/O\n");
+    mtree_print_mr(mon, address_space_io.root, 0);
+}
diff --git a/memory.h b/memory.h
index 06b83ae..09d8e29 100644
--- a/memory.h
+++ b/memory.h
@@ -500,6 +500,8 @@ void memory_region_transaction_begin(void);
  */
 void memory_region_transaction_commit(void);

+void mtree_info(Monitor *mon);
+
 #endif

 #endif
diff --git a/monitor.c b/monitor.c
index 03ae997..0302446 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2968,6 +2968,13 @@ static const mon_cmd_t info_cmds[] = {
     },
 #endif
     {
+        .name       = "mtree",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show memory tree",
+        .mhandler.info = mtree_info,
+    },
+    {
         .name       = "jit",
         .args_type  = "",
         .params     = "",
-- 
1.6.2.4

[-- Attachment #2: 0001-memory-simple-memory-tree-printer.patch --]
[-- Type: text/x-diff, Size: 2398 bytes --]

From 5e01e21490994a538b70ff27f1caf9e4865aeba1 Mon Sep 17 00:00:00 2001
Message-Id: <5e01e21490994a538b70ff27f1caf9e4865aeba1.1315772597.git.blauwirbel@gmail.com>
From: Blue Swirl <blauwirbel@gmail.com>
Date: Sun, 11 Sep 2011 20:22:05 +0000
Subject: [PATCH] memory: simple memory tree printer

Add a monitor command 'info mtree' to show the memory hierarchy.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 memory.c  |   27 +++++++++++++++++++++++++++
 memory.h  |    2 ++
 monitor.c |    7 +++++++
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/memory.c b/memory.c
index 57f0fa4..0bcef84 100644
--- a/memory.c
+++ b/memory.c
@@ -17,6 +17,7 @@
 #include "bitops.h"
 #include "kvm.h"
 #include <assert.h>
+#include "monitor.h"
 
 unsigned memory_region_transaction_depth = 0;
 
@@ -1253,3 +1254,29 @@ void set_system_io_map(MemoryRegion *mr)
     address_space_io.root = mr;
     memory_region_update_topology();
 }
+
+static void mtree_print_mr(Monitor *mon, MemoryRegion *mr, unsigned int level)
+{
+    MemoryRegion *submr;
+    unsigned int i;
+
+    for (i = 0; i < level; i++) {
+        monitor_printf(mon, "-");
+    }
+    monitor_printf(mon, "%s addr " TARGET_FMT_plx " off " TARGET_FMT_plx
+                   " size %" PRIx64 "\n",
+                   mr->name, mr->addr, mr->offset, mr->size);
+
+    QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
+        mtree_print_mr(mon, submr, level + 1);
+    }
+}
+
+void mtree_info(Monitor *mon)
+{
+    monitor_printf(mon, "memory\n");
+    mtree_print_mr(mon, address_space_memory.root, 0);
+
+    monitor_printf(mon, "I/O\n");
+    mtree_print_mr(mon, address_space_io.root, 0);
+}
diff --git a/memory.h b/memory.h
index 06b83ae..09d8e29 100644
--- a/memory.h
+++ b/memory.h
@@ -500,6 +500,8 @@ void memory_region_transaction_begin(void);
  */
 void memory_region_transaction_commit(void);
 
+void mtree_info(Monitor *mon);
+
 #endif
 
 #endif
diff --git a/monitor.c b/monitor.c
index 03ae997..0302446 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2968,6 +2968,13 @@ static const mon_cmd_t info_cmds[] = {
     },
 #endif
     {
+        .name       = "mtree",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show memory tree",
+        .mhandler.info = mtree_info,
+    },
+    {
         .name       = "jit",
         .args_type  = "",
         .params     = "",
-- 
1.7.2.5


             reply	other threads:[~2011-09-11 20:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-11 20:31 Blue Swirl [this message]
2011-09-12  6:43 ` [Qemu-devel] [PATCH] memory: simple memory tree printer Richard Henderson
2011-09-12  9:01   ` Jan Kiszka
2011-09-12  9:11     ` Avi Kivity
2011-09-12  9:19       ` Jan Kiszka
2011-09-14 15:10         ` Richard Henderson
2011-09-14 15:23           ` Avi Kivity
2011-09-14 15:27             ` Richard Henderson
2011-09-14 15:29               ` Avi Kivity
2011-09-14 15:36                 ` Richard Henderson
2011-09-14 15:46                   ` Avi Kivity
2011-09-14 17:58           ` Jan Kiszka
2011-09-14 18:10             ` Jan Kiszka
2011-09-14 19:24               ` Avi Kivity
2011-09-15  9:30                 ` Jan Kiszka
2011-09-15  9:53                   ` Avi Kivity
2011-09-15 10:18                     ` Jan Kiszka
2011-09-15 11:21                       ` Avi Kivity
2011-09-14 18:26             ` Richard Henderson
2011-09-12  7:00 ` Peter Maydell
2011-09-12  8:46 ` Avi Kivity
2011-09-12  8:53   ` Jan Kiszka
2011-09-12  9:12     ` Avi Kivity
2011-09-12 10:37 ` Gerd Hoffmann
2011-09-12 10:53   ` Avi Kivity
2011-09-12 20:07     ` Blue Swirl

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=CAAu8pHvpbYBuOKa6Krsd6R00qidBx+J6ObaqZT40zuYh+SZn9g@mail.gmail.com \
    --to=blauwirbel@gmail.com \
    --cc=avi@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.