From patchwork Thu Oct 17 18:51:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176697 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1355916ill; Thu, 17 Oct 2019 12:07:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTL2scb64kfe6W8DloZveoe6Sd9EYTEg4Qs6oh+3Gtd3L3dQWYjmusiuUnVOLFGJ3Ob35t X-Received: by 2002:ac8:5343:: with SMTP id d3mr5572506qto.157.1571339228913; Thu, 17 Oct 2019 12:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571339228; cv=none; d=google.com; s=arc-20160816; b=EJYXxqrkZu7uE9lhDYlpT3ZCT6Tk3PzGPEB1/wwnK713xh7OeD94PbX5ZUy+5n7IO5 DD9Y/AauWwz8y7eTZJkwSFvQ0X0GBFdlbyJi0q5tCt50D/q3YCimujfK4RKIW9pV31oG nWEYuiKYY5odfmVV0LYSBp54WH3lyyKVu81jT4UquaFAQYC9fXvYsfcOTg9bboURUXE8 9oRjfprMSmivF8NOcwkRYoSIu1WVkcehIN+fCmuNryVFvWF6SKV5rDOAge5q18lQ+BIs 1hq8QyoF0K4fhwpCAUvtEUL3X/zJxIAEZnwCJuHg0y7Imq/nEDpjmscyqVpzX/mNNT0P wLWw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=5TK2BjuSMMDdIP7qbR+6sWroGlmanOV91VZR8RZQmXE=; b=jAsszbb5uVm/GfWkRedtV8n1oOn6GwAp69VsSWw6pjhOmuzymmf29mQsVw2Fzm7quq wm+ZhPo/mmIDitLzgnY6CBmy7b5d5TiEx8oJfb0kSUxOEr+JePmlk1BkxQmDQFL9c6fg TwJg64co+cT2EzPtLoVOuqWDmFCpdJ1YlDjElfZSAFbDj3ayLfCSaKT1u7D5IlWwe/7C RsI8sAqQIAhPizJaa6PmKnei2MLmA1mUo/IFzQn5+sGGgR+aHNDpS603D1cupXMc6bnD PYx79wDJCrL1LcQylwcurH60zxSJJI6beY/2D9a/TTLxMynDc32FapAFsDU7w5VFAKwG 63pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JcrQDLns; 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 h14si2660964qtr.22.2019.10.17.12.07.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 12:07:08 -0700 (PDT) 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=JcrQDLns; 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 ([::1]:57242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLB75-00023E-VW for patch@linaro.org; Thu, 17 Oct 2019 15:07:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35452) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLAsA-0001ME-LU for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLAs8-0000zT-Uw for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:42 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:36747) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLAs8-0000yl-Or for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:40 -0400 Received: by mail-pf1-x441.google.com with SMTP id y22so2221674pfr.3 for ; Thu, 17 Oct 2019 11:51:40 -0700 (PDT) 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=5TK2BjuSMMDdIP7qbR+6sWroGlmanOV91VZR8RZQmXE=; b=JcrQDLnsOHSe9OyD5Zy33o/NYsS5jm2PtO8t9wA+JNCeiNg/JNjUU/zTy9KXazvmhb JDz8qU5zMmSH5WHTefmctKIklYK1R1jN3JI5RVkCYedvhYV9+8r3hH70aQEdkXgrfdXY hhVvifhcN1p8omoFqNJfHooBdB3pu7wo6cV6bs9PQeBjUdQx+Xflm+0TPoRYlTt4nZrN x5vhKaaxlF4mzq3db994HFE75BE7Hj4WBDaXc/PYV8BcCVkDDhSt8/RnBY1f7QsNoaMK ETqjZj6jy6ljn/2UiVNogl2Z/bRaCl1TbttY9saqn1gFzVBomKQtN/eEv120/91dGkmu l5fg== 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=5TK2BjuSMMDdIP7qbR+6sWroGlmanOV91VZR8RZQmXE=; b=bY60ndDXBlddLATuaxqGk5kXE0tog3Z2DP8fIX194oSm2upeTbW1Czaj3/MbAGHTTJ l1wscbkSQPr42PWjf092/wmaV72sA4b/m3vxOIQ4pfst1MubaNZdfwzw5htTFeMmfi9R LafeYTJ+CuHFZ/YgdHV6KX3Iua7/AvENZ5vkNsWWx3YsbE5AscTFS6SwqOaVf5tQJmAm QQqjFnqEwFPODinH1PlUb0tHzYoywW2HuV+zggwm65fgkQLiYL4feOJbh8Xih/8LOUxn xaEvmMaEMs5sxXFC+q9xaq6skA+ZECc8hnghHaZ32HSpxoTY+nBmp0fTG6tDlkki7EQp W5zg== X-Gm-Message-State: APjAAAXSHq2xYDgwVdCqgPOxXvoVDcExu0WW3lDC5+18cU95TaZil1D5 jfPIv/VtG8ahrYxMWzqya240wIYkZ2E= X-Received: by 2002:a63:dd11:: with SMTP id t17mr5742808pgg.242.1571338299344; Thu, 17 Oct 2019 11:51:39 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id s97sm5009256pjc.4.2019.10.17.11.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 11:51:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 20/20] target/arm: Rely on hflags correct in cpu_get_tb_cpu_state Date: Thu, 17 Oct 2019 11:51:10 -0700 Message-Id: <20191017185110.539-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017185110.539-1-richard.henderson@linaro.org> References: <20191017185110.539-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::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index aae7b62458..c3e3dd2c41 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11249,12 +11249,15 @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { - uint32_t flags, pstate_for_ss; + uint32_t flags = env->hflags; + uint32_t pstate_for_ss; *cs_base = 0; - flags = rebuild_hflags_internal(env); +#ifdef CONFIG_DEBUG_TCG + assert(flags == rebuild_hflags_internal(env)); +#endif - if (is_a64(env)) { + if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) { *pc = env->pc; if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype);