All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: Avi Kivity <avi@redhat.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v3] memory: simple memory tree printer
Date: Tue, 27 Sep 2011 14:35:44 +0200	[thread overview]
Message-ID: <4E81C320.9020804@siemens.com> (raw)
In-Reply-To: <CAAu8pHu6Ntj80NFBQA24c-9r4sehFFueVSmkJ1VbjS0Lg=JGig@mail.gmail.com>

On 2011-09-26 22:03, Blue Swirl wrote:
> 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>
> ---
> The alias addresses are unbiased (PPC):
> 00000000-fffffffe : system
>   800a0000-800affff : alias vga.chain4 @vga.vram 00000000-0000ffff
>   80880000-808fffff : macio
>     808e0000-808fffff : macio-nvram
>     808a0000-808a0fff : pmac-ide
>     80896000-80895fff : (null)
>     80893000-8089303f : alias escc-bar @escc 00000000-0000003f
>     80888000-80888fff : dbdma
>     80880000-80880fff : heathrow-pic
>   80800000-8080ffff : vga.rom
>   80000000-807fffff : vga.vram
>   800a0000-800bffff : vga-lowmem
>   80013000-8001303f : escc
>   fee00000-fee00fff : pci-data-idx
>   fec00000-fec00fff : pci-conf-idx
>   fe000000-fe1fffff : isa-mmio
> vga.vram
> 80000000-807fffff : vga.vram
> escc
> 80013000-8001303f : escc
> ---
>  memory.c  |   88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  memory.h  |    2 +
>  monitor.c |   13 +++++++++
>  3 files changed, 103 insertions(+), 0 deletions(-)
> 
> diff --git a/memory.c b/memory.c
> index 71e769e..53264be 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1271,3 +1271,91 @@ 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;

What's the point of printed? It's never true unless I'm missing
something fundamental.

> +    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;
> +
> +    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);

Region priority is still not printed. Will send a patch.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  parent reply	other threads:[~2011-09-27 12:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-26 20:03 [Qemu-devel] [PATCH v3] memory: simple memory tree printer Blue Swirl
2011-09-27  9:10 ` Avi Kivity
2011-09-27 12:35 ` Jan Kiszka [this message]
2011-09-27 17:13   ` 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=4E81C320.9020804@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.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.