qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] Fix performance regression in qemu_get_ram_ptr


From: Anthony Liguori
Subject: [Qemu-devel] Re: [PATCH] Fix performance regression in qemu_get_ram_ptr
Date: Thu, 10 Mar 2011 17:17:42 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8

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<address@hidden>

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]