From: Avi Kivity <avi@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Blue Swirl <blauwirbel@gmail.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 3/3] memory: Print regions in ascending order
Date: Sun, 02 Oct 2011 16:06:22 +0200 [thread overview]
Message-ID: <4E886FDE.9030005@redhat.com> (raw)
In-Reply-To: <4E81C8F9.3030305@siemens.com>
On 09/27/2011 04:00 PM, Jan Kiszka wrote:
> Makes reading the output more user friendly.
Thanks, applied all three.
> @@ -1339,12 +1339,13 @@ 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)
> + MemoryRegionListHead *alias_print_queue)
> {
> + MemoryRegionList *new_ml, *ml, *next_ml;
> + MemoryRegionListHead submr_print_queue;
> const MemoryRegion *submr;
> unsigned int i;
>
> -
> if (!mr) {
> return;
> }
> @@ -1358,7 +1359,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;
> }
> @@ -1368,7 +1369,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",
> @@ -1386,9 +1387,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);
> }
> }
>
Yuck, the whole thing would be a one-liner with a capable library
(std::map<> or std::sort())
--
error compiling committee.c: too many arguments to function
prev parent reply other threads:[~2011-10-02 14:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-27 13:00 [Qemu-devel] [PATCH 3/3] memory: Print regions in ascending order Jan Kiszka
2011-10-02 14:06 ` Avi Kivity [this message]
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=4E886FDE.9030005@redhat.com \
--to=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=jan.kiszka@siemens.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.