From patchwork Wed Aug 24 22:17:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 662598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sKMKg6f7Mz9sdm for ; Thu, 25 Aug 2016 08:24:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=braap.org header.i=@braap.org header.b=zKaClohS; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b=IfD11s9n; dkim-atps=neutral Received: from localhost ([::1]:53609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcgab-000315-UF for incoming@patchwork.ozlabs.org; Wed, 24 Aug 2016 18:24:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcgVD-0006oD-AN for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcgUy-0004Jz-UY for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:31 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:45947) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcgUw-0004FB-5J for qemu-devel@nongnu.org; Wed, 24 Aug 2016 18:18:16 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 69CC2203D0; Wed, 24 Aug 2016 18:18:04 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 24 Aug 2016 18:18:04 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=TqgMhyuYAott3PrlywLT0varI3Q =; b=zKaClohSDcNR1j4qR53uJLsGOnvuqSqDZ+NFMGmpOhuB7KtbNAkgYNtfthE 7XYxgEjLkjmDqre7W1o8hwTCSyHEKNrj8VXd0gTIoywNOWql+oOscm2OA/Bg0/WF 2qkUYH6vSd7gR3GvV4nKPdr7kziEXZ44upd+JFf0SigFtySE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=TqgM hyuYAott3PrlywLT0varI3Q=; b=IfD11s9naF9uxJnIjG8Wv9l6VaAPmKJtrPcF KcF6949kikJ8MTflyJnJ6x1JWX5UHAkqMI3Zd/mivzTY2i/oMS0Ke7iDx96J06Yx NCRUJ5bHXpmVpt8Duga3ZUPL2DxPrug0/7D6d/3x8/eluqvfNh+orFilwd2ZFH7C ANyCtAM= X-Sasl-enc: P7z6BIvbR2JljndMN39bSj8oAo9YEjXQGvrJNPyLvbFT 1472077084 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 1FBF2CCE70; Wed, 24 Aug 2016 18:18:04 -0400 (EDT) From: "Emilio G. Cota" To: Richard Henderson Date: Wed, 24 Aug 2016 18:17:57 -0400 Message-Id: <1472077083-15022-2-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1472077083-15022-1-git-send-email-cota@braap.org> References: <20160824211240.GA26546@flamenco> <1472077083-15022-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.26 Subject: [Qemu-devel] [PATCH 2/8] cpu-exec: remove tb_lock from hot path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mttcg@greensocs.com, peter.maydell@linaro.org, claudio.fontana@huawei.com, nikunj@linux.vnet.ibm.com, crosthwaite.peter@gmail.com, jan.kiszka@siemens.com, mark.burton@greensocs.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, serge.fdrv@gmail.com, pbonzini@redhat.com, bobby.prani@gmail.com, alex.bennee@linaro.org, dgilbert@redhat.com, fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Emilio G. Cota --- cpu-exec.c | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 041f8b7..63d739a 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -309,34 +309,18 @@ static TranslationBlock *tb_find_slow(CPUState *cpu, TranslationBlock *tb; tb = tb_find_physical(cpu, pc, cs_base, flags); - if (tb) { - goto found; - } - -#ifdef CONFIG_USER_ONLY - /* mmap_lock is needed by tb_gen_code, and mmap_lock must be - * taken outside tb_lock. Since we're momentarily dropping - * tb_lock, there's a chance that our desired tb has been - * translated. - */ - tb_unlock(); - mmap_lock(); - tb_lock(); - tb = tb_find_physical(cpu, pc, cs_base, flags); - if (tb) { + if (!tb) { + mmap_lock(); + tb_lock(); + tb = tb_find_physical(cpu, pc, cs_base, flags); + if (!tb) { + /* if no translated code available, then translate it now */ + tb = tb_gen_code(cpu, pc, cs_base, flags, 0); + } + tb_unlock(); mmap_unlock(); - goto found; } -#endif - - /* if no translated code available, then translate it now */ - tb = tb_gen_code(cpu, pc, cs_base, flags, 0); - -#ifdef CONFIG_USER_ONLY - mmap_unlock(); -#endif -found: /* we add the TB in the virtual pc hash table */ cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb; return tb; @@ -355,7 +339,6 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, always be the same before a given translated block is executed. */ cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); - tb_lock(); tb = cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]; if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base || tb->flags != flags)) { @@ -379,9 +362,10 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, #endif /* See if we can patch the calling TB. */ if (*last_tb && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { + tb_lock(); tb_add_jump(*last_tb, tb_exit, tb); + tb_unlock(); } - tb_unlock(); return tb; }