All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Vincent Palatin <vpalatin@chromium.org>
Cc: Chris Wright <chrisw@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Qemu devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Re: [PATCH] Fix performance regression in qemu_get_ram_ptr
Date: Thu, 10 Mar 2011 17:17:42 -0600	[thread overview]
Message-ID: <4D795C16.9090806@us.ibm.com> (raw)
In-Reply-To: <1299790066-768-1-git-send-email-vpalatin@chromium.org>

On 03/10/2011 02:47 PM, Vincent Palatin wrote:
> When the commit f471a17e9d869df3c6573f7ec02c4725676d6f3a converted the
> ram_blocks structure to QLIST, it also removed the conditional check before
> switching the current block at the beginning of the list.
>
> In the common use case where ram_blocks has a few blocks with only one
> frequently accessed (the main RAM), this has a performance impact as it
> performs the useless list operations on each call (which are on a really
> hot path).
>
> On my machine emulation (ARM on amd64), this patch reduces the
> percentage of CPU time spent in qemu_get_ram_ptr from 6.3% to 2.1% in the
> profiling of a full boot.
>
> Signed-off-by: Vincent Palatin<vpalatin@chromium.org>

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   exec.c |    7 +++++--
>   1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index d611100..81f08b7 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2957,8 +2957,11 @@ void *qemu_get_ram_ptr(ram_addr_t addr)
>
>       QLIST_FOREACH(block,&ram_list.blocks, next) {
>           if (addr - block->offset<  block->length) {
> -            QLIST_REMOVE(block, next);
> -            QLIST_INSERT_HEAD(&ram_list.blocks, block, next);
> +            /* Move this entry to to start of the list.  */
> +            if (block != QLIST_FIRST(&ram_list.blocks)) {
> +                QLIST_REMOVE(block, next);
> +                QLIST_INSERT_HEAD(&ram_list.blocks, block, next);
> +            }
>               return block->host + (addr - block->offset);
>           }
>       }

      parent reply	other threads:[~2011-03-10 23:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-10 20:47 [Qemu-devel] [PATCH] Fix performance regression in qemu_get_ram_ptr Vincent Palatin
2011-03-10 21:14 ` [Qemu-devel] " Alex Williamson
2011-03-10 21:52 ` Chris Wright
2011-03-10 23:17 ` Anthony Liguori [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=4D795C16.9090806@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=chrisw@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vpalatin@chromium.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.