From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=50316 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKcHf-000390-Am for qemu-devel@nongnu.org; Mon, 22 Nov 2010 14:42:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKcHe-0005eB-0Q for qemu-devel@nongnu.org; Mon, 22 Nov 2010 14:42:39 -0500 Received: from smtp.ispras.ru ([83.149.198.201]:45358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKcHd-0005Yc-HB for qemu-devel@nongnu.org; Mon, 22 Nov 2010 14:42:37 -0500 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id 5A2455D40B8 for ; Mon, 22 Nov 2010 22:37:46 +0300 (MSK) Received: from [127.0.0.1] (ispserv.ispras.ru [83.149.198.72]) by ispserv.ispras.ru (Postfix) with ESMTP id E0FB63FC48 for ; Mon, 22 Nov 2010 22:42:12 +0300 (MSK) Message-ID: <4CEAC792.7040307@ispras.ru> Date: Mon, 22 Nov 2010 22:42:10 +0300 From: Kirill Batuzov MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050906050804020606000308" Subject: [Qemu-devel] [PATCH, RFT] Speedup 'tb_find_slow' by using the same heuristic as during memory page lookup List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------050906050804020606000308 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Signed-off-by: Pavel Yushchenko --- Hello. This patch gives significant boost to a used by us rather rich (for embedded one - featuring X-server, many daemons and applications) ARM-based system literally decreasing its boot to desktop time by TWO times! (Average number of traversed 'tb_phys_hash' entries in the main loop of the 'tb_find_slow' function reduced from 20 to 1.5.) We were able to shorten boot to login time by about 25% as well using Debian on versatilepb (no X-server, only basic system). Seems like kernel booting time is not affected. No problems were encountered during our experiments. We are looking forward for comments about this change and help with testing. Thanks in advance! cpu-exec.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 5d6dd51..55c4526 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -161,6 +161,11 @@ static TranslationBlock *tb_find_slow(target_ulong pc, tb = tb_gen_code(env, pc, cs_base, flags, 0); found: + if (*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; --------------050906050804020606000308 Content-Type: application/x-patch; name="tb_find_slow-locality-heuristic.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="tb_find_slow-locality-heuristic.patch" ZGlmZiAtLWdpdCBhL2NwdS1leGVjLmMgYi9jcHUtZXhlYy5jDQppbmRleCA1ZDZkZDUxLi41 NWM0NTI2IDEwMDY0NA0KLS0tIGEvY3B1LWV4ZWMuYw0KKysrIGIvY3B1LWV4ZWMuYw0KQEAg LTE2MSw2ICsxNjEsMTEgQEAgc3RhdGljIFRyYW5zbGF0aW9uQmxvY2sgKnRiX2ZpbmRfc2xv dyh0YXJnZXRfdWxvbmcgcGMsDQogICAgIHRiID0gdGJfZ2VuX2NvZGUoZW52LCBwYywgY3Nf YmFzZSwgZmxhZ3MsIDApOw0KIA0KICBmb3VuZDoNCisgICAgaWYgKCpwdGIxKSB7DQorICAg ICAgICAqcHRiMSA9IHRiLT5waHlzX2hhc2hfbmV4dDsNCisgICAgICAgIHRiLT5waHlzX2hh c2hfbmV4dCA9IHRiX3BoeXNfaGFzaFtoXTsNCisgICAgICAgIHRiX3BoeXNfaGFzaFtoXSA9 IHRiOw0KKyAgICB9DQogICAgIC8qIHdlIGFkZCB0aGUgVEIgaW4gdGhlIHZpcnR1YWwgcGMg aGFzaCB0YWJsZSAqLw0KICAgICBlbnYtPnRiX2ptcF9jYWNoZVt0Yl9qbXBfY2FjaGVfaGFz aF9mdW5jKHBjKV0gPSB0YjsNCiAgICAgcmV0dXJuIHRiOw0K --------------050906050804020606000308--