* [Qemu-devel] [PULL 0/4] Memory tree printer
@ 2011-10-02 14:32 Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 1/4] memory: simple memory " Avi Kivity
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Avi Kivity @ 2011-10-02 14:32 UTC (permalink / raw)
To: Anthony Liguori, Blue Swirl, qemu-devel
Please pull from
git://github.com/avikivity/qemu memory/core
to get the new 'info mtree' command, which is a great debugging aid.
Blue Swirl (1):
memory: simple memory tree printer
Jan Kiszka (3):
memory: Print region priority
memory: Do not print empty PIO root
memory: Print regions in ascending order
memory.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
memory.h | 2 +
monitor.c | 13 +++++++
3 files changed, 136 insertions(+), 0 deletions(-)
--
1.7.6.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/4] memory: simple memory tree printer
2011-10-02 14:32 [Qemu-devel] [PULL 0/4] Memory tree printer Avi Kivity
@ 2011-10-02 14:32 ` Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 2/4] memory: Print region priority Avi Kivity
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2011-10-02 14:32 UTC (permalink / raw)
To: Anthony Liguori, Blue Swirl, qemu-devel
From: Blue Swirl <blauwirbel@gmail.com>
Add a monitor command 'info mtree' to show the memory hierarchy
much like /proc/iomem in Linux.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
memory.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
memory.h | 2 +
monitor.c | 13 +++++++++
3 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/memory.c b/memory.c
index 71e769e..a85d118 100644
--- a/memory.c
+++ b/memory.c
@@ -1271,3 +1271,94 @@ void set_system_io_map(MemoryRegion *mr)
address_space_io.root = mr;
memory_region_update_topology();
}
+
+typedef struct MemoryRegionList MemoryRegionList;
+
+struct MemoryRegionList {
+ const MemoryRegion *mr;
+ bool printed;
+ QTAILQ_ENTRY(MemoryRegionList) queue;
+};
+
+typedef QTAILQ_HEAD(queue, MemoryRegionList) MemoryRegionListHead;
+
+static void mtree_print_mr(fprintf_function mon_printf, void *f,
+ const MemoryRegion *mr, unsigned int level,
+ target_phys_addr_t base,
+ MemoryRegionListHead *print_queue)
+{
+ const MemoryRegion *submr;
+ unsigned int i;
+
+
+ if (!mr) {
+ return;
+ }
+
+ for (i = 0; i < level; i++) {
+ mon_printf(f, " ");
+ }
+
+ if (mr->alias) {
+ MemoryRegionList *ml;
+ bool found = false;
+
+ /* check if the alias is already in the queue */
+ QTAILQ_FOREACH(ml, print_queue, queue) {
+ if (ml->mr == mr->alias && !ml->printed) {
+ found = true;
+ }
+ }
+
+ if (!found) {
+ ml = g_new(MemoryRegionList, 1);
+ ml->mr = mr->alias;
+ ml->printed = false;
+ QTAILQ_INSERT_TAIL(print_queue, ml, queue);
+ }
+ mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " : alias %s @%s "
+ TARGET_FMT_plx "-" TARGET_FMT_plx "\n",
+ base + mr->addr,
+ base + mr->addr + (target_phys_addr_t)mr->size - 1,
+ mr->name,
+ mr->alias->name,
+ mr->alias_offset,
+ mr->alias_offset + (target_phys_addr_t)mr->size - 1);
+ } else {
+ mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " : %s\n",
+ base + mr->addr,
+ base + mr->addr + (target_phys_addr_t)mr->size - 1,
+ mr->name);
+ }
+ QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
+ mtree_print_mr(mon_printf, f, submr, level + 1, base + mr->addr,
+ print_queue);
+ }
+}
+
+void mtree_info(fprintf_function mon_printf, void *f)
+{
+ MemoryRegionListHead ml_head;
+ MemoryRegionList *ml, *ml2;
+
+ QTAILQ_INIT(&ml_head);
+
+ mon_printf(f, "memory\n");
+ mtree_print_mr(mon_printf, f, address_space_memory.root, 0, 0, &ml_head);
+
+ /* print aliased regions */
+ QTAILQ_FOREACH(ml, &ml_head, queue) {
+ if (!ml->printed) {
+ mon_printf(f, "%s\n", ml->mr->name);
+ mtree_print_mr(mon_printf, f, ml->mr, 0, 0, &ml_head);
+ }
+ }
+
+ QTAILQ_FOREACH_SAFE(ml, &ml_head, queue, ml2) {
+ g_free(ml2);
+ }
+
+ QTAILQ_INIT(&ml_head);
+ mon_printf(f, "I/O\n");
+ mtree_print_mr(mon_printf, f, address_space_io.root, 0, 0, &ml_head);
+}
diff --git a/memory.h b/memory.h
index e93e65a..d5b47da 100644
--- a/memory.h
+++ b/memory.h
@@ -501,6 +501,8 @@ void memory_region_transaction_begin(void);
*/
void memory_region_transaction_commit(void);
+void mtree_info(fprintf_function mon_printf, void *f);
+
#endif
#endif
diff --git a/monitor.c b/monitor.c
index 8ec2c5e..d323ea5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -63,6 +63,7 @@
#endif
#include "trace/control.h"
#include "ui/qemu-spice.h"
+#include "memory.h"
//#define DEBUG
//#define DEBUG_COMPLETION
@@ -2470,6 +2471,11 @@ static void tlb_info(Monitor *mon)
}
#endif
+static void do_info_mtree(Monitor *mon)
+{
+ mtree_info((fprintf_function)monitor_printf, mon);
+}
+
static void do_info_kvm_print(Monitor *mon, const QObject *data)
{
QDict *qdict;
@@ -2978,6 +2984,13 @@ int monitor_get_fd(Monitor *mon, const char *fdname)
},
#endif
{
+ .name = "mtree",
+ .args_type = "",
+ .params = "",
+ .help = "show memory tree",
+ .mhandler.info = do_info_mtree,
+ },
+ {
.name = "jit",
.args_type = "",
.params = "",
--
1.7.6.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/4] memory: Print region priority
2011-10-02 14:32 [Qemu-devel] [PULL 0/4] Memory tree printer Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 1/4] memory: simple memory " Avi Kivity
@ 2011-10-02 14:32 ` Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 3/4] memory: Do not print empty PIO root Avi Kivity
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2011-10-02 14:32 UTC (permalink / raw)
To: Anthony Liguori, Blue Swirl, qemu-devel
From: Jan Kiszka <jan.kiszka@siemens.com>
Useful to discover eclipses.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
memory.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/memory.c b/memory.c
index a85d118..eae67be 100644
--- a/memory.c
+++ b/memory.c
@@ -1316,18 +1316,20 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
ml->printed = false;
QTAILQ_INSERT_TAIL(print_queue, ml, queue);
}
- mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " : alias %s @%s "
+ mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): alias %s @%s "
TARGET_FMT_plx "-" TARGET_FMT_plx "\n",
base + mr->addr,
base + mr->addr + (target_phys_addr_t)mr->size - 1,
+ mr->priority,
mr->name,
mr->alias->name,
mr->alias_offset,
mr->alias_offset + (target_phys_addr_t)mr->size - 1);
} else {
- mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " : %s\n",
+ mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): %s\n",
base + mr->addr,
base + mr->addr + (target_phys_addr_t)mr->size - 1,
+ mr->priority,
mr->name);
}
QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
--
1.7.6.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 3/4] memory: Do not print empty PIO root
2011-10-02 14:32 [Qemu-devel] [PULL 0/4] Memory tree printer Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 1/4] memory: simple memory " Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 2/4] memory: Print region priority Avi Kivity
@ 2011-10-02 14:32 ` Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 4/4] memory: Print regions in ascending order Avi Kivity
2011-10-02 21:14 ` [Qemu-devel] [PULL 0/4] Memory tree printer Blue Swirl
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2011-10-02 14:32 UTC (permalink / raw)
To: Anthony Liguori, Blue Swirl, qemu-devel
From: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
memory.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/memory.c b/memory.c
index eae67be..19f1d36 100644
--- a/memory.c
+++ b/memory.c
@@ -1360,7 +1360,10 @@ void mtree_info(fprintf_function mon_printf, void *f)
g_free(ml2);
}
- QTAILQ_INIT(&ml_head);
- mon_printf(f, "I/O\n");
- mtree_print_mr(mon_printf, f, address_space_io.root, 0, 0, &ml_head);
+ if (address_space_io.root &&
+ !QTAILQ_EMPTY(&address_space_io.root->subregions)) {
+ QTAILQ_INIT(&ml_head);
+ mon_printf(f, "I/O\n");
+ mtree_print_mr(mon_printf, f, address_space_io.root, 0, 0, &ml_head);
+ }
}
--
1.7.6.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 4/4] memory: Print regions in ascending order
2011-10-02 14:32 [Qemu-devel] [PULL 0/4] Memory tree printer Avi Kivity
` (2 preceding siblings ...)
2011-10-02 14:32 ` [Qemu-devel] [PATCH 3/4] memory: Do not print empty PIO root Avi Kivity
@ 2011-10-02 14:32 ` Avi Kivity
2011-10-02 21:14 ` [Qemu-devel] [PULL 0/4] Memory tree printer Blue Swirl
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2011-10-02 14:32 UTC (permalink / raw)
To: Anthony Liguori, Blue Swirl, qemu-devel
From: Jan Kiszka <jan.kiszka@siemens.com>
Makes reading the output more user friendly.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
memory.c | 37 +++++++++++++++++++++++++++++++------
1 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/memory.c b/memory.c
index 19f1d36..f46e626 100644
--- a/memory.c
+++ b/memory.c
@@ -1285,12 +1285,13 @@ struct MemoryRegionList {
static void mtree_print_mr(fprintf_function mon_printf, void *f,
const MemoryRegion *mr, unsigned int level,
target_phys_addr_t base,
- MemoryRegionListHead *print_queue)
+ MemoryRegionListHead *alias_print_queue)
{
+ MemoryRegionList *new_ml, *ml, *next_ml;
+ MemoryRegionListHead submr_print_queue;
const MemoryRegion *submr;
unsigned int i;
-
if (!mr) {
return;
}
@@ -1304,7 +1305,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
bool found = false;
/* check if the alias is already in the queue */
- QTAILQ_FOREACH(ml, print_queue, queue) {
+ QTAILQ_FOREACH(ml, alias_print_queue, queue) {
if (ml->mr == mr->alias && !ml->printed) {
found = true;
}
@@ -1314,7 +1315,7 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
ml = g_new(MemoryRegionList, 1);
ml->mr = mr->alias;
ml->printed = false;
- QTAILQ_INSERT_TAIL(print_queue, ml, queue);
+ QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue);
}
mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d): alias %s @%s "
TARGET_FMT_plx "-" TARGET_FMT_plx "\n",
@@ -1332,9 +1333,33 @@ static void mtree_print_mr(fprintf_function mon_printf, void *f,
mr->priority,
mr->name);
}
+
+ QTAILQ_INIT(&submr_print_queue);
+
QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
- mtree_print_mr(mon_printf, f, submr, level + 1, base + mr->addr,
- print_queue);
+ new_ml = g_new(MemoryRegionList, 1);
+ new_ml->mr = submr;
+ QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
+ if (new_ml->mr->addr < ml->mr->addr ||
+ (new_ml->mr->addr == ml->mr->addr &&
+ new_ml->mr->priority > ml->mr->priority)) {
+ QTAILQ_INSERT_BEFORE(ml, new_ml, queue);
+ new_ml = NULL;
+ break;
+ }
+ }
+ if (new_ml) {
+ QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);
+ }
+ }
+
+ QTAILQ_FOREACH(ml, &submr_print_queue, queue) {
+ mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,
+ alias_print_queue);
+ }
+
+ QTAILQ_FOREACH_SAFE(next_ml, &submr_print_queue, queue, ml) {
+ g_free(ml);
}
}
--
1.7.6.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PULL 0/4] Memory tree printer
2011-10-02 14:32 [Qemu-devel] [PULL 0/4] Memory tree printer Avi Kivity
` (3 preceding siblings ...)
2011-10-02 14:32 ` [Qemu-devel] [PATCH 4/4] memory: Print regions in ascending order Avi Kivity
@ 2011-10-02 21:14 ` Blue Swirl
4 siblings, 0 replies; 6+ messages in thread
From: Blue Swirl @ 2011-10-02 21:14 UTC (permalink / raw)
To: Avi Kivity; +Cc: qemu-devel
Thanks, pulled.
On Sun, Oct 2, 2011 at 2:32 PM, Avi Kivity <avi@redhat.com> wrote:
> Please pull from
>
> git://github.com/avikivity/qemu memory/core
>
> to get the new 'info mtree' command, which is a great debugging aid.
>
> Blue Swirl (1):
> memory: simple memory tree printer
>
> Jan Kiszka (3):
> memory: Print region priority
> memory: Do not print empty PIO root
> memory: Print regions in ascending order
>
> memory.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> memory.h | 2 +
> monitor.c | 13 +++++++
> 3 files changed, 136 insertions(+), 0 deletions(-)
>
> --
> 1.7.6.3
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-10-02 21:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-02 14:32 [Qemu-devel] [PULL 0/4] Memory tree printer Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 1/4] memory: simple memory " Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 2/4] memory: Print region priority Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 3/4] memory: Do not print empty PIO root Avi Kivity
2011-10-02 14:32 ` [Qemu-devel] [PATCH 4/4] memory: Print regions in ascending order Avi Kivity
2011-10-02 21:14 ` [Qemu-devel] [PULL 0/4] Memory tree printer Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).