From patchwork Wed Apr 12 01:17:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 9676381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B5A9160384 for ; Wed, 12 Apr 2017 01:22:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F6192768C for ; Wed, 12 Apr 2017 01:22:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93B452857B; Wed, 12 Apr 2017 01:22:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33BB928490 for ; Wed, 12 Apr 2017 01:22:20 +0000 (UTC) Received: from localhost ([::1]:41779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cy6zD-0002Bl-6V for patchwork-qemu-devel@patchwork.kernel.org; Tue, 11 Apr 2017 21:22:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cy6ux-00082H-Fa for qemu-devel@nongnu.org; Tue, 11 Apr 2017 21:17:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cy6uw-0006QK-Hp for qemu-devel@nongnu.org; Tue, 11 Apr 2017 21:17:55 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:53483) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cy6ur-0006LY-Lu; Tue, 11 Apr 2017 21:17:49 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0CBA120B5F; Tue, 11 Apr 2017 21:17:47 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Tue, 11 Apr 2017 21:17:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=FHV 879t6kYzIF3kjiS1A3wMW1cEkA+YddMExwl10tQM=; b=ooir3iLI7mjSLpcu1bI MwQrRwrxJvY+kmh9937yxBit8y+0zpE9S5Ir6uBC4tUItkaqJMWtuDiXx3bX8Ozw XFKQIzf+DzR+NnJyYqb+JP3TxWRvZYc0rxvC4en1yDW2fGBWNh+hBcAka1k2dy34 DlwvJEmeAmcDFEsp5M+km/Nw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=FHV879t6kYzIF3kjiS1A3wMW1cEkA+YddMExwl10t QM=; b=lUaT10XWcZyBQyHEs02OCZuV6XDBTwTUB2KE/bHE9W4zAxAiv/xnhLHUD cOE0ROGkoVND3+LdEf5njd4toyFUZl4Ul6fbQ62OE3sVG40vyAYxo16QXjfsRcsU gRg/gHGetuib0nJC3jJkPkGE2xRD7R8w/3wzA7JFQu4rFmuJdA1OXGZvZ9bya2qS T84lZVgmFXrwsI0G5ShHr/xErCyublxxFWYwNfaIt37QNiezxQ23UPxogMqY6cm4 0scdYwTQXiLkLyPr62Ft2QlKGQkGO1SQx91s5QlssdnsAO27Yd85MmpCfrvQz4uM hM/JQpl1u+WdJ2xBCHZLO0P+ngZrw== X-ME-Sender: X-Sasl-enc: lc4V+0S6agwHgrQWVWKtgQkKErDIxaFwR3n+DYN/qAw9 1491959866 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id BFDB1241ED; Tue, 11 Apr 2017 21:17:46 -0400 (EDT) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 21:17:22 -0400 Message-Id: <1491959850-30756-3-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491959850-30756-1-git-send-email-cota@braap.org> References: <1491959850-30756-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH 02/10] exec-all: inline tb_from_jmp_cache 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Claudio Fontana , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The inline improves performance, as shown in subsequent commits' logs. This commit is kept separate to ease review, since the inclusion of tb-hash.h might be controversial. The problem here, which was introduced before this commit, is that tb_hash_func() depends on page_addr_t: this defeats the original purpose of tb-hash.h, which was to be self-contained and CPU-agnostic. Signed-off-by: Emilio G. Cota --- cpu-exec.c | 19 ------------------- include/exec/exec-all.h | 24 +++++++++++++++++++++++- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index ce9750a..748cb66 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -309,25 +309,6 @@ static bool tb_cmp(const void *p, const void *d) return false; } -TranslationBlock *tb_from_jmp_cache(CPUArchState *env, target_ulong vaddr) -{ - CPUState *cpu = ENV_GET_CPU(env); - TranslationBlock *tb; - target_ulong cs_base, pc; - uint32_t flags; - - if (unlikely(atomic_read(&cpu->exit_request))) { - return NULL; - } - cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); - tb = atomic_rcu_read(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(vaddr)]); - if (likely(tb && tb->pc == vaddr && tb->cs_base == cs_base && - tb->flags == flags)) { - return tb; - } - return NULL; -} - static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, target_ulong cs_base, diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 18b80bc..bd76987 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -367,7 +367,29 @@ struct TranslationBlock { void tb_free(TranslationBlock *tb); void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); -TranslationBlock *tb_from_jmp_cache(CPUArchState *env, target_ulong vaddr); + +/* tb_hash_func() in tb-hash.h needs tb_page_addr_t, defined above */ +#include "tb-hash.h" + +static inline +TranslationBlock *tb_from_jmp_cache(CPUArchState *env, target_ulong vaddr) +{ + CPUState *cpu = ENV_GET_CPU(env); + TranslationBlock *tb; + target_ulong cs_base, pc; + uint32_t flags; + + if (unlikely(atomic_read(&cpu->exit_request))) { + return NULL; + } + cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); + tb = atomic_rcu_read(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(vaddr)]); + if (likely(tb && tb->pc == vaddr && tb->cs_base == cs_base && + tb->flags == flags)) { + return tb; + } + return NULL; +} #if defined(USE_DIRECT_JUMP)