From patchwork Thu Dec 2 13:12:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Batuzov X-Patchwork-Id: 73984 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 3BD2EB6EE9 for ; Fri, 3 Dec 2010 03:30:36 +1100 (EST) Received: from localhost ([127.0.0.1]:42228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POAlL-0003Bp-Qn for incoming@patchwork.ozlabs.org; Thu, 02 Dec 2010 10:08:00 -0500 Received: from [140.186.70.92] (port=52362 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PO90k-0000yZ-Pt for qemu-devel@nongnu.org; Thu, 02 Dec 2010 08:18:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PO8yD-00079c-SD for qemu-devel@nongnu.org; Thu, 02 Dec 2010 08:15:45 -0500 Received: from smtp.ispras.ru ([83.149.198.201]:50809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PO8yD-00074L-GG for qemu-devel@nongnu.org; Thu, 02 Dec 2010 08:13:09 -0500 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id BE7705D4102 for ; Thu, 2 Dec 2010 16:07:37 +0300 (MSK) Received: from spartak.intra.ispras.ru (winnie.ispras.ru [83.149.198.236]) by ispserv.ispras.ru (Postfix) with ESMTP id 0E4293FC48 for ; Thu, 2 Dec 2010 16:12:46 +0300 (MSK) Date: Thu, 2 Dec 2010 16:12:46 +0300 (MSK) From: Kirill Batuzov To: qemu-devel@nongnu.org Message-ID: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH] 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 --- 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;