All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	Paolo Bonzini <pbonzini@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Peter Xu <peterx@redhat.com>, Igor Mammedov <imammedo@redhat.com>
Subject: Re: [PATCH-for-5.2] memory: Display bigger regions first in 'info mtree' output
Date: Mon, 27 Jul 2020 19:36:28 +0100	[thread overview]
Message-ID: <CAFEAcA_n=WB-QjcF4XCHX14D3gL_1JRsfr0QSyCOcRmATRh0qg@mail.gmail.com> (raw)
In-Reply-To: <20200727174543.4219-1-f4bug@amsat.org>

On Mon, 27 Jul 2020 at 18:46, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> When different regions have the same address, we currently
> sort them by the priority. Also sort them by the region
> size.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  softmmu/memory.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index af25987518..c28dcaf4d6 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -2960,7 +2960,8 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
>          QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) {
>              if (new_ml->mr->addr < ml->mr->addr ||
>                  (new_ml->mr->addr == ml->mr->addr &&
> -                 new_ml->mr->priority > ml->mr->priority)) {
> +                 (MR_SIZE(new_ml->mr->size) > MR_SIZE(ml->mr->size) ||
> +                  new_ml->mr->priority > ml->mr->priority))) {
>                  QTAILQ_INSERT_BEFORE(ml, new_ml, mrqueue);
>                  new_ml = NULL;
>                  break;

I think this is the point where you want to factor out the
comparison-of-two-MRs function. Which then makes it easier
to implement the required logic, which as Peter Xu says
should be "address compare first; if those are equal look
at the priority; if those are also equal look at the size",
ie the usual comparison-with-multiple-fields.

thanks
-- PMM


      parent reply	other threads:[~2020-07-27 18:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 17:45 [PATCH-for-5.2] memory: Display bigger regions first in 'info mtree' output Philippe Mathieu-Daudé
2020-07-27 18:09 ` Peter Xu
2020-08-05 14:21   ` Philippe Mathieu-Daudé
2020-08-05 14:45     ` Philippe Mathieu-Daudé
2020-07-27 18:36 ` Peter Maydell [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='CAFEAcA_n=WB-QjcF4XCHX14D3gL_1JRsfr0QSyCOcRmATRh0qg@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=aik@ozlabs.ru \
    --cc=f4bug@amsat.org \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@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.