From patchwork Mon Nov 22 19:42:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Batuzov X-Patchwork-Id: 72584 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7AAE7B70EF for ; Tue, 23 Nov 2010 06:44:09 +1100 (EST) Received: from localhost ([127.0.0.1]:53330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKcJ2-0003V1-Sk for incoming@patchwork.ozlabs.org; Mon, 22 Nov 2010 14:44:05 -0500 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 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6 MIME-Version: 1.0 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH, RFT] Speedup 'tb_find_slow' by using the same heuristic as during memory page lookup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;