qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] Speedup 'tb_find_slow' by using the same heuristic


From: Kirill Batuzov
Subject: [Qemu-devel] [PATCH] Speedup 'tb_find_slow' by using the same heuristic as during memory page lookup
Date: Thu, 2 Dec 2010 16:12:46 +0300 (MSK)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

Move the last found TB to the head of the list so it will be found more quickly 
next time it will be looked for.

Signed-off-by: Kirill Batuzov <address@hidden>
Signed-off-by: Pavel Yushchenko <address@hidden>
---

This patch appeared during investigation of performance issues with
S5PC110 emulation for Samsung. It increses OS startup speed significantly.

Changes from previous version, submitted with RFT tag:
 - 'likely' was added to if condition,
 - comment was added.


diff --git a/cpu-exec.c b/cpu-exec.c
index dbdfdcc..39e5eea 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -167,6 +167,12 @@ static TranslationBlock *tb_find_slow(target_ulong pc,
     tb = tb_gen_code(env, pc, cs_base, flags, 0);
 
  found:
+    /* Move the last found TB to the head of the list */
+    if (likely(*ptb1)) {
+        *ptb1 = tb->phys_hash_next;
+        tb->phys_hash_next = tb_phys_hash[h];
+        tb_phys_hash[h] = tb;
+    }
     /* we add the TB in the virtual pc hash table */
     env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
     return tb;

Attachment: tb_find_slow-locality-heuristic.patch
Description: Text Data


reply via email to

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