From patchwork Tue Aug 20 21:07:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 171857 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp90867ily; Tue, 20 Aug 2019 14:29:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+jlsJJ+MglQGUr9IKkXQBMurKpkrD1mzfzBXVJVC95KywMULsne73cLcIlN9xFUDj64HL X-Received: by 2002:ac8:295d:: with SMTP id z29mr28572272qtz.168.1566336567508; Tue, 20 Aug 2019 14:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566336567; cv=none; d=google.com; s=arc-20160816; b=TftfGViGa5ifXjz35qXcS2V+a1l41anhoKJmQFjM9XIceBxKsXSBv14Iqv+GZb0IFA qdabPEH59iMbfaaBHnA73ZiEOZRKhEtURhX/xW6roYnre/8Qe+Wa/AkGQ0/H6+mQB1h9 1Ec0+sVAnXKhaX1xP5R3SbcUV23JbT7PV1kHFDE0xazHNKqDC1dXJ+whVT77gji9CQeU l7hDuZmZ8gasHYIdKHhHbinzGQzlxMlMO7NabAELgmh7Hcs2Zm5c1d2RJF1GPOH6eKaU ny8Z1ueOfNsBrNMoltzIZk8TcS6nulBafmBxiiVa9lu5ZOxQEBGd6alhBlpF9nZvS/Oj 0SbA== 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=uEuMTFJPriSi6tDBht/B2C/M+eVLAfQCMhLFMcHsiGA=; b=aDrsThwI1HL1awNJOGNirYGQzN0QFo7FlVINydm4bqHJy8s2dL7anHzb8Kt0DkQq+8 DRU+Z8EtCrjrDT1U46zvOOF3cpk/DrXqtWI5oTM+BIc8PR0ya+5VTvuoRgFfkj5atjIz poXiXcgfcioAWZ7B9MSResM0ULxMGSGl1hEK6rLMvVDrdhvgyvQxp6g9kR0qFwBGSLgJ MGnq8NpNc7hObh7vNDrlO1ijqvoJSRhvPHTvpZze64UWQ68sgJLflwAlwPvT7taVExLR tP4ChJWTN9Ug3+JCm5ZFuX1QmlN+ciC9Gp48A/XR1jzx6v6DRJ4yP/N/XV89JZg1WgZm SITQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=seU9CvbP; 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 e24si11673846qkl.56.2019.08.20.14.29.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Aug 2019 14:29:27 -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=seU9CvbP; 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]:41990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0Bh0-0002PF-Od for patch@linaro.org; Tue, 20 Aug 2019 17:29:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54042) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0BM3-0000OP-U8 for qemu-devel@nongnu.org; Tue, 20 Aug 2019 17:07:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0BM2-0000F8-LV for qemu-devel@nongnu.org; Tue, 20 Aug 2019 17:07:47 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:42841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i0BM2-0000EZ-Fl for qemu-devel@nongnu.org; Tue, 20 Aug 2019 17:07:46 -0400 Received: by mail-pf1-x444.google.com with SMTP id i30so4112262pfk.9 for ; Tue, 20 Aug 2019 14:07:46 -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=uEuMTFJPriSi6tDBht/B2C/M+eVLAfQCMhLFMcHsiGA=; b=seU9CvbPFWQC6HXFlU4qGeJJOEoKi3ivDF7hxy/kTPUlSwz+PanrBNm6RCvT2te+He wa1zY3vZI5hIVXtpr6XAieAWB9ejmxhi0ayDvZUBPOEtkJmHwikSRoYmoWc5OIl5hE/Q ROJJcZMaeAA8itUVPGVM1WCJMVPDTZO7iV75WtgXXH1crLSa3jjYdDwnKZfDrqzcxMly enPgJj8H+6XE4Gg2E/GpJfVbeXi4pz+dlWG/cQes34VEXWyKEla5nwEuh4soR9H20m5M JAvs0kHCIzAFCOUyXoVdvF/e8lCbnl6ZTnYo6sp/H3SK39N8jIhjT2PgGfSO/IumBJ43 U0Vw== 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=uEuMTFJPriSi6tDBht/B2C/M+eVLAfQCMhLFMcHsiGA=; b=iW9vEkIrym/vOs42ZFJ1sdoxcWEUDWJME4DMI4Px2/jB5aiuZo05Jc56gW3qFqP+v8 zktbnWygKej5S4oTo/65SEtU5dOuey1sgs7XGCodyGwg+IJtdu6py/uibqHYw4zN0Rxz K5QatHNh1hJYDsGRk/1ATp61aY3jXS99w1nyp+dhQ5hkFAcPwkI2sdoyraQpGsZnpmpE E0vtO8s4GIA8emmDW2ckjMyZv8QSjgQ/mOnzZN3Xqg0SedR1KHrPLDnu30/TomHPCoEi hYCvCSgyVPCiXY3uIResKqb754wfXn//1ASnpgjgqehVhQKwifcriAqxPhDfD6auKHVQ Zkbw== X-Gm-Message-State: APjAAAU/Y8zNvPWswuGJET0Rlw7m23C19DRoaDnk6uEFGoRSYLiaa9Dq Ud9niCDLth0U6FjDnOcZ65BLQsuLujs= X-Received: by 2002:aa7:95b8:: with SMTP id a24mr31913578pfk.103.1566335265240; Tue, 20 Aug 2019 14:07:45 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id k22sm21690743pfk.157.2019.08.20.14.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 14:07:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 20 Aug 2019 14:07:20 -0700 Message-Id: <20190820210720.18976-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820210720.18976-1-richard.henderson@linaro.org> References: <20190820210720.18976-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::444 Subject: [Qemu-devel] [PATCH v5 17/17] target/arm: Rely on hflags correct in cpu_get_tb_cpu_state 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 d1bf71a260..5e4f996882 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11211,12 +11211,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_TCG_DEBUG + 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);