From patchwork Fri Feb 22 02:41:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 158970 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1225875jaa; Thu, 21 Feb 2019 19:01:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ6m1zz5rI7Di5NeVi2uqFtS0bPEGHmcyxyHAQ5tYavGuik0nvtqE4L/QeZmKqCI9jdkp1H X-Received: by 2002:a5b:706:: with SMTP id g6mr1522654ybq.330.1550804487762; Thu, 21 Feb 2019 19:01:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550804487; cv=none; d=google.com; s=arc-20160816; b=iuHZSSi1bd7NKkRqpniCpfej/ifVkp+NbWUE5hbaOmd2qFdOescSaij1yJ2Z3M5GcQ dLnHJdXEduG421dJjhqR4yiroyqirJhngglNPXeLnFNlLnti46tWYAtnuw6gcAytUL+m K2j5LkxNcVMWanFnq2DE22Caqu2t5kvFA6fgtRdhUtVgPnZt9ditXGO+vaPOKbXXYYEd tkvFNeE3Ao2traE5xpgmXl+FTjSrhoSzUgONCASnCnTsvRH4IyC4EH8hw/A5nAOaz4p1 9gWFPG+Srql6Vi5i7La4TUWatHlBn9x0qjQBN2mP2vl/6Sdy4ubA5rBexCqR6rxM1gsB IGZg== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7za0oe+S+pDjXtPVWoLW1jUXBpKdAwHxIVRqazhFQik=; b=cOaEEsC659EpgpIe3249q4AK0DdPgDOc9nwIABno5CvBUk2ijvNhi3z0VOB94UddXP S0dU+qCFTm/pJKlaMGKykTEV0fMfY9PGZweMsPY/0XJVafFpVPFrww2MI6Plq3+gDBXh ZEDPXpaE9NhpwleJXJ9Z+5GxtZ0JJ0JQEQYkQqk9qeNrv0KD9sBvkzX+0/fdbzkaWRH+ m4SbZ6LHh+BWnvmX9hwwpu+nzaZZEMVgTeojcFU/lOhITH8tzzuFACO3lbRX7zKYgw5D XptWilDIg2Ht0i3HAIigFdigVOfWqriEj0WIcGc0LOZCcCITW2mHzz9XdnlVDTxPXTZz rUzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Bo+ALpEg; 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 t12si145560ybc.91.2019.02.21.19.01.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 19:01:27 -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=Bo+ALpEg; 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]:43207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gx15b-0002TL-C6 for patch@linaro.org; Thu, 21 Feb 2019 22:01:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gx0mj-0005EY-MW for qemu-devel@nongnu.org; Thu, 21 Feb 2019 21:41:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gx0mX-0005Fm-0F for qemu-devel@nongnu.org; Thu, 21 Feb 2019 21:41:49 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:35540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gx0mW-0004dH-EK for qemu-devel@nongnu.org; Thu, 21 Feb 2019 21:41:44 -0500 Received: by mail-pf1-x442.google.com with SMTP id j5so393412pfa.2 for ; Thu, 21 Feb 2019 18:41:13 -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 :mime-version:content-transfer-encoding; bh=7za0oe+S+pDjXtPVWoLW1jUXBpKdAwHxIVRqazhFQik=; b=Bo+ALpEgvkJjPayK/eZg++ocYuLYY9QI0hTefDosQ0uK5/f3KM0Ot1ylzCG9E1bEiB ygvRgoPCMDeSaS1fgOMvo7ZIE0nG2NBhzm0HohTxYNB2wtEVLfXIyoW8sYqwBhre1Viu 5QPrY6oyi8IOsnMTml6nnOv9wv0XSfx+qBbnY//EpIyfI3Wc6TPfL1dbiy1VNHu8yG1E nfjOCF+7z1NiNVQoWOzpCt0F2bHGCN4kunMVvrTVgxL0xVtKBkfEBgM4LsjU1RujzGBg Eugn9GVwLXkLjjiPSYJ6TyBgE8UiFMRK1xHHFIvUzq5cq61MsJ5GlJcBCrPll8L3BnhF r0WA== 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:mime-version:content-transfer-encoding; bh=7za0oe+S+pDjXtPVWoLW1jUXBpKdAwHxIVRqazhFQik=; b=WxsmbNbVahAnEBkrBCn/e0acvgKCbJ2bqtVgfyDylkm9XWjm0DhnRqD6ivVxPogKVv 4dq4rwDkb3Wb+zJclRj43nslwqXZOqDda8TfHFbSmTuWKHt/6M/yb/mgKTp6i0IbLbxZ S7u/rwHzWhsNe/C+1DdQHlCiGiHNPwOKma92tOz3W6PbXKu4rpSI2j2ma4bLzcYVpSwK afj84QRfx1I3yKubwqNb7viv+IcxpUW/S2IiZyszw5xGwNGenCRzgX7fXygJQA67UJsz u/RL2gBA/hW/mkCt0ft7cOvCgT2MLYwBfUgACkzo1vHgqeRBzMzbSrn2qaxjK/tK2T+v b9Mw== X-Gm-Message-State: AHQUAuaspAJ+euA+VhZMTESOIcv+YCWcpk7+PgGH7oK1O5yn3VbT4nYe T71+WqmIlLk4awMjYpIvxdLJ7JnVlig= X-Received: by 2002:aa7:80c8:: with SMTP id a8mr1782344pfn.27.1550803272603; Thu, 21 Feb 2019 18:41:12 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id v6sm187429pgb.2.2019.02.21.18.41.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Feb 2019 18:41:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:41:06 -0800 Message-Id: <20190222024106.9167-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190222024106.9167-1-richard.henderson@linaro.org> References: <20190222024106.9167-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v3 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. Tested-by: Alex Bennée Reviewed-by: Alex Bennée 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.2 diff --git a/target/arm/helper.c b/target/arm/helper.c index 1140739d6b..0d19333be0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -14027,19 +14027,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); flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, env->vfp.vec_len);