From patchwork Tue Feb 19 23:34:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 158752 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4262437jaa; Tue, 19 Feb 2019 15:37:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IYjT/dXIY4XON4IEBMtpZLS7zPXtiLoGucoonL/GWgi2GrUns3VUYU2C2uBA7PeN2Dy16GR X-Received: by 2002:a0d:d5cd:: with SMTP id x196mr25449493ywd.303.1550619442144; Tue, 19 Feb 2019 15:37:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550619442; cv=none; d=google.com; s=arc-20160816; b=R9qF6SBy0KDWhsSZnv9bPjifhK56l9oqTtDpp50QL+eHI4u2TY4JpDbByFnvD+KKae A8e1fv4c5K2SStp9yAxArDtQL/bCcd7PUUP2NUlSBLGc+D1pMy4ALHN2qoHSMq7mvvsw wqSs7N3F0idYCZX1P8429LoR2JFsw+v/VF386FOiKrhTgXE3b8FQWcPwyTLfJPPSvuk3 ExPLjpP9nnV/kUVtl1jLoYevoAVRm8oIfCQ6RIiTgRD/kmiazo1PGbMGGJyl0+HRit4w c2ayIR+9tTFvZ77GPYXo1Ndb9ptr+C73Klo268SDnkyXApH1qWwEhrl/7SWVZHI6kn9H gmwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=KZSIV7kXwXdBP1jkhIO7XDLEXrURa9L1eRY1j8f1eOM=; b=ZA5UGzZi/FXC5KRwy2vDe9nfd5OfPbPoNQ2BY5L3KuL2yBfeAGKlY+SvRug4qJk8G2 eYN4L3LRlPJDx844OJQYVDwhVybaS8hOhJbWkM6MbjtTTI7uN53xeTTGJfeoSZksFfDi gwhKTVVZVrCVtmIZz9CnBp5Nkx4LzoHGseIeAtz3EAUTHc93h0fD1F/pYlgw6oNDMAo9 1qIkUYVUlEywUkQ6oszPuxsqxWb3kBd9BpaslZuHHMDl/J4hQBDqgXteQoRvX/vRCtf7 AVpxGyPGsiabPHK+NxhtEG+XxF7HSOvnq++hjFTbtpEr92BoKzx95xETmtApnbeJdhDW tofw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VUUSya37; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p6si10247050ybb.24.2019.02.19.15.37.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Feb 2019 15:37:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VUUSya37; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:56597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwEwz-0000tv-OS for patch@linaro.org; Tue, 19 Feb 2019 18:37:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwEuK-0007Xh-Bo for qemu-devel@nongnu.org; Tue, 19 Feb 2019 18:34:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwEuJ-0001Wd-If for qemu-devel@nongnu.org; Tue, 19 Feb 2019 18:34:36 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33000) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwEuH-0001Rn-MF for qemu-devel@nongnu.org; Tue, 19 Feb 2019 18:34:35 -0500 Received: by mail-pg1-x542.google.com with SMTP id h11so8511917pgl.0 for ; Tue, 19 Feb 2019 15:34:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KZSIV7kXwXdBP1jkhIO7XDLEXrURa9L1eRY1j8f1eOM=; b=VUUSya37KrctNc+3wZlO/xuTeOSMwrxbbT5F0K/mOTno7r4knK+/NKOH++RJn1lxXc skcb0JXiO39zQPy/6fsojBEG7O2JTa6GasGM1xu+AVtt089R10Fh2WdbbrUIAeC8cTp7 J4SedS+pnRnjJ9yhMwVfDxPWT6zUVRkrpD8t3smeiuUe8NGp0FYDscxHr4q8g/cumArP /6XmAnepIXgRq9QrAmu3YaGBk7HRtobmxObeRFzAsCJKhutaToXZ5HnH4Tn6mBKTcMQX lrRn/f1jsYBGms/MaEq6ZR6hfHoSx32+Ypi5eeDagosHwrIDSmekyTNKbHT+O249mEor hvSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KZSIV7kXwXdBP1jkhIO7XDLEXrURa9L1eRY1j8f1eOM=; b=tYtJ85n86aptGeJVRcA9Kh9ZI786+ogdH7zsECV+ePpkALG4AQjtX7p9TfQ4bUJUPo GUoIwGqdIZjSO3EGmCCE1aP9TUwgA7njEJ421U9oHrvCuse5nCglD6OEhfolTlwwKSrM IqaFzC8Qx6n/nXB1BJpuxM1AoYqDOlQw9v2dj8vF1w4kK/4Ppg5AhKkDQ8H1z37+AEEJ 4NIpXAieFD19zOf0r3OJb+YCiXJan+tJmTxl/rfqToWr2tTGiD8sezYCjDpKuNDh7Nvk 5vnvotoEOeqGzyVPTAtpnY+ls/KFpaqA1krVsEPyqMkBdlKxn5YqVvGD3TuC8Oxnrgj4 hczg== X-Gm-Message-State: AHQUAuYqt60d6lZqzCMhcTCwVSfNlXSA54dgfMO6RUvnKCw4frx4AjFg XK8zQB0Kb4uibk0SaPVNEU9656i5Bx4= X-Received: by 2002:a63:6184:: with SMTP id v126mr26226863pgb.277.1550619266915; Tue, 19 Feb 2019 15:34:26 -0800 (PST) Received: from localhost.localdomain (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id l184sm24356988pfc.41.2019.02.19.15.34.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 15:34:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 19 Feb 2019 15:34:21 -0800 Message-Id: <20190219233421.388-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190219233421.388-1-richard.henderson@linaro.org> References: <20190219233421.388-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v2 3/3] target/arm: Rely on hflags correct in cpu_get_tb_cpu_state 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@linaro.org, cota@braap.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is the payoff. >From perf record -g data of ubuntu 18 boot and shutdown: BEFORE: - 23.02% 2.82% qemu-system-aar [.] helper_lookup_tb_ptr - 20.22% helper_lookup_tb_ptr + 10.05% tb_htable_lookup - 9.13% cpu_get_tb_cpu_state 3.20% aa64_va_parameters_both 0.55% fp_exception_el - 11.66% 4.74% qemu-system-aar [.] cpu_get_tb_cpu_state - 6.96% cpu_get_tb_cpu_state 3.63% aa64_va_parameters_both 0.60% fp_exception_el 0.53% sve_exception_el AFTER: - 16.40% 3.40% qemu-system-aar [.] helper_lookup_tb_ptr - 13.03% helper_lookup_tb_ptr + 11.19% tb_htable_lookup 0.55% cpu_get_tb_cpu_state 0.98% 0.71% qemu-system-aar [.] cpu_get_tb_cpu_state 0.87% 0.24% qemu-system-aar [.] rebuild_hflags_a64 Before, helper_lookup_tb_ptr is the second hottest function in the application, consuming almost a quarter of the runtime. Within the entire execution, cpu_get_tb_cpu_state consumes about 12%. After, helper_lookup_tb_ptr has dropped to the fourth hottest function, with consumption dropping to a sixth of the runtime. Within the entire execution, cpu_get_tb_cpu_state has dropped below 1%, and the supporting function to rebuild hflags also consumes about 1%. Assertions are retained for --enable-debug-tcg. Signed-off-by: Richard Henderson --- v2: Retain asserts for future debugging. --- target/arm/helper.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée Tested-by: Alex Bennée diff --git a/target/arm/helper.c b/target/arm/helper.c index 909535a3e3..990a87876f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -14034,19 +14034,29 @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, uint32_t el) void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { - int current_el = arm_current_el(env); - uint32_t flags; + uint32_t flags = env->hflags; uint32_t pstate_for_ss; +#ifdef CONFIG_DEBUG_TCG + { + int el = arm_current_el(env); + uint32_t check_flags; + if (is_a64(env)) { + check_flags = rebuild_hflags_a64(env, el); + } else { + check_flags = rebuild_hflags_a32(env, el); + } + g_assert_cmphex(flags, ==, check_flags); + } +#endif + *cs_base = 0; - if (is_a64(env)) { + if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) { *pc = env->pc; - flags = rebuild_hflags_a64(env, current_el); flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); pstate_for_ss = env->pstate; } else { *pc = env->regs[15]; - flags = rebuild_hflags_a32(env, current_el); flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); flags = FIELD_DP32(flags, TBFLAG_A32, CONDEXEC, env->condexec_bits); pstate_for_ss = env->uncached_cpsr;