From patchwork Fri Apr 21 13:24:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 675857 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp855626wrs; Fri, 21 Apr 2023 06:25:43 -0700 (PDT) X-Google-Smtp-Source: AKy350aqSUtssOyi8JWE/ZKANF9o/txuDRcG+4LLRIhLQUnL0y5VayevPZ+Yoqe8C08oDIurlDR6 X-Received: by 2002:a05:622a:11cf:b0:3e8:e986:b20a with SMTP id n15-20020a05622a11cf00b003e8e986b20amr9386890qtk.16.1682083543675; Fri, 21 Apr 2023 06:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682083543; cv=none; d=google.com; s=arc-20160816; b=NnSb821N+OvIqKdyRFgZRHjI+Wrg8LtSZG/PzsD0Oe1dxMUppFEWdJ9/KR82vZPE5S zrVeL9ep/CgKK8wyNGO50/JhKwcEdiIMyQZ9Y1e7rVI5++7WQAoFbBs9dasLPsOtqlMB OFe3s8K7XM8vzCrLMs8povvFkVxLjAVnTLvigO7ZvXA0U6jLiMNgA43cymjtYJ4kp4gF jtAjbMSh1zu3P5T/lTd3qwpW/hPhI0QyBsTqlKcrLr25PFPajl/+/GBFyUk2LADc+nuF rD/u0kRGBZL50kterdf1pFOQe3x2tutBBV9IdotQHIge+NeoIwcTEVBLJ3xkUVOSvjmi NPGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=mhqMiBJdzciWWhzsZbhtoE+XoQDWnvKwP/zZRqI+d7U=; b=OwGfuFt7owXW2MkZ3jbA8820niouwkMObJxcoPDc6YjeNK98TbKV9B5btEX7ERMxcS 6vSUw530m6t6L9osmlS4jSFjUXMzAkrL4vEW08rwNf9Ub+78RJKqPBgl2Okb6kxT2Bfw OizN2O2saouoK4fRjYsayyczN8Nj1tJI14L8NILbIQdw+b/03MRim7lnNIAvUyZfD3jQ liAJsCOuZp38TIKJ4hmQAZN7d9nSrn2EjHlbT2AHljqML18yUP91UiEcG89MfDN6OmJK B393+7I7p2TONU/7WldzabFrhgAN9tTOWxh2bfuyrJ5BKH6bSWgQHFGRzRU4ezwivP6I CqIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZJbLap89; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l24-20020a05620a0c1800b00746aa3d54e2si2756949qki.430.2023.04.21.06.25.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Apr 2023 06:25:43 -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=pass header.i=@intel.com header.s=Intel header.b=ZJbLap89; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppqlI-000120-HY; Fri, 21 Apr 2023 09:25:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqlG-00011Q-L9 for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:25:14 -0400 Received: from mga05.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqlF-0003KR-3n for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:25:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682083513; x=1713619513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WNIo84hU1QQcPGj401Y32N/rh4tOgg/o7Vpt12k6Trk=; b=ZJbLap89BgBbG7pAHSyLWRhN78fkyc4ujjdp8x/UlKFLJLym2/knmNUg pQNB84mhAeoUuF8s2qLCLhr4CSbDuGtrb6i5l1/s1uiAAisKXcpAuofeq Ux1S4JUXKDyJ8LZ5u9dl4FDIqx0ckQwj2ZYhcLzETbV0XRE3Fv3xmXQFR Ofb9QcWRseWIKKBn2aLoPly8b1NzSorFGErdG/qw8vCUQbWAHO+4STl58 AzDxqZMDqadv07Z9gDXLzHBhvtA/Vuqph/uUtZSZrqu1xHfXu/B4F/CyF UerwHxzcSOetu/2Xu5gLSc/J79SduXVnzXyZ/pue+36GhgV8KJ9ZsUwBk A==; X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="432268326" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="432268326" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2023 06:25:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="756906025" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="756906025" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by fmsmga008.fm.intel.com with ESMTP; 21 Apr 2023 06:25:09 -0700 From: Fei Wu To: alex.bennee@linaro.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PATCH v11 05/14] accel/tcg: move profiler dev_time to tb_stats Date: Fri, 21 Apr 2023 21:24:12 +0800 Message-Id: <20230421132421.1617479-6-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230421132421.1617479-1-fei2.wu@intel.com> References: <20230421132421.1617479-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.43; envelope-from=fei2.wu@intel.com; helo=mga05.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée This shouldn't live in the monitor code anyway. While we are at it make it an uint64_t as we won't be dealing in negative numbers. Signed-off-by: Alex Bennée --- accel/tcg/monitor.c | 2 -- accel/tcg/tb-stats.c | 2 ++ include/qemu/timer.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c index 1450e160e9..c9eec426ff 100644 --- a/accel/tcg/monitor.c +++ b/accel/tcg/monitor.c @@ -68,8 +68,6 @@ HumanReadableText *qmp_x_query_opcount(Error **errp) #ifdef CONFIG_PROFILER -int64_t dev_time; - HumanReadableText *qmp_x_query_profile(Error **errp) { g_autoptr(GString) buf = g_string_new(""); diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c index 434b235edb..a2438a1f51 100644 --- a/accel/tcg/tb-stats.c +++ b/accel/tcg/tb-stats.c @@ -28,6 +28,8 @@ enum TBStatsStatus { static enum TBStatsStatus tcg_collect_tb_stats; static uint32_t default_tbstats_flag; +uint64_t dev_time; + struct jit_profile_info { uint64_t translations; uint64_t aborted; diff --git a/include/qemu/timer.h b/include/qemu/timer.h index ee071e07d1..d86fc73a17 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -995,7 +995,7 @@ static inline int64_t profile_getclock(void) return get_clock(); } -extern int64_t dev_time; +extern uint64_t dev_time; #endif #endif From patchwork Fri Apr 21 13:24:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 675856 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp855625wrs; Fri, 21 Apr 2023 06:25:43 -0700 (PDT) X-Google-Smtp-Source: AKy350YNMWnEf2wazPlAO6xbmVpN6QB34yZYB8h/UEKTEZiVgGjAQYSv626BdFcDU/zTU2zCxiFB X-Received: by 2002:a05:622a:2c5:b0:3ef:625c:f31d with SMTP id a5-20020a05622a02c500b003ef625cf31dmr995945qtx.39.1682083543328; Fri, 21 Apr 2023 06:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682083543; cv=none; d=google.com; s=arc-20160816; b=jCLfmG72dQq1Pc3I4UHWkUGelIDIPqb7A1o8rw2PKs9fXqz2N5qds3eA8MYqv7zA7c roBO08XNSLM9LYKgh+LjRDqrQOv6R9NULL+b/E+XtlF4GSkg7LbaPUIPsvy2W6bm/Tn1 mOZ8WHgFrhCdYqX8kK3fV8pV0oq9GgryNj331KJdiJWe7C69MJSHfMjgl9kew6kKJV1s zpG1prqcPJ4EYKocZLCPtI09+/R3K3MMpsMUTH6Cu9Chi4kYCo24gZ5QWLqcPlxpMF4a ZBAwr8daQHpo5hE8aXf2nlr2baf8if/9APFi83F3W82wrPNHmzpxxFHltGhMeKFS6MTk hUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=oU2HOKvTK2RoQiErmml129uB5ytuTPri2i6CR3wLhLA=; b=jcMu1RKYv7d7NQ+GriSKu0LqBSn0aTVC4azVSlefJ4GBfCgNShrWfq0DkWekWrbpz9 boNmPU5yVuf9heIU9WBpVSpAOmSLiqZgAGArycWLsEGd1pgspB4FVvpIIH4AMmPq4EY4 K1RlYckJ/BP18g6zjFVre0sfEuAXpl46t4l0w8JMBPGE0EMsD5u8mpmVsEuh9eGtDZh1 CiW+lM+ZQe4eWsCVNcxFIB+QoBF5SyVCTWTDkhh3PSZg8BhYDY6Cp0IIpaLrhB/rwXFV 3njyYWn0auf/Lwm82763G9xW6Pu8N9hp5KCPJ7eoPP7IPcd3YXlUWXndt/XXw755cb7A ZgmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=n13T56XK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c18-20020ac85a92000000b003e388c7581csi3309026qtc.182.2023.04.21.06.25.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Apr 2023 06:25:43 -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=pass header.i=@intel.com header.s=Intel header.b=n13T56XK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppqlO-0001Dl-4p; Fri, 21 Apr 2023 09:25:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqlL-00014A-Or for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:25:19 -0400 Received: from mga05.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqlJ-0003Mk-IP for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:25:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682083517; x=1713619517; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y0ZpXw5w1L+wV1VOoDF+rpMnJxQnje3Ws+zndxkNz9Q=; b=n13T56XKNa4Ufo4/1kCSODfalGFQnCxRjV9kfzIoYtYr13MOwawVaFHh b17aXjBszQh3v33xMxeJh/cFeyVSWkUm8Be6NOAsOTjVU8hw9FQhq6mcx Ibs1Jrz377uegOIO6UAW/b/6c9+BjH52y4kyNXuSoriaUAjKiWqpfgzZf /5ebsP4Na0s6oDWo7nHdJIeBI/Ekg0AtZ9rq52F1sDqVBvo82HFbT79ml LYqXWd1qx9kDQLzsWttgqkHQnW4nF2grLLDt+u2vRL6j0T5rIsCK1AqRY vSDI9f0LnNj9QOMcJ9UAkGVbM6AqTuchQRB//mj1jOudIpFqQhvdDk+4a Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="432268350" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="432268350" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2023 06:25:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="756906026" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="756906026" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by fmsmga008.fm.intel.com with ESMTP; 21 Apr 2023 06:25:15 -0700 From: Fei Wu To: alex.bennee@linaro.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PATCH v11 06/14] accel/tcg: convert profiling of restore operations to TBStats Date: Fri, 21 Apr 2023 21:24:13 +0800 Message-Id: <20230421132421.1617479-7-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230421132421.1617479-1-fei2.wu@intel.com> References: <20230421132421.1617479-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.43; envelope-from=fei2.wu@intel.com; helo=mga05.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée This starts the conversion of CONFIG_PROFILER data collection to under the TBStats system. We introduce a new flag TB_JIT_TIME and start tracking how much time is spent restoring execution state from a given TB. Signed-off-by: Alex Bennée --- accel/tcg/translate-all.c | 23 ++++++++++++++--------- include/exec/tb-stats.h | 6 ++++++ include/qemu/timer.h | 3 --- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 8a51c291d8..bf10987450 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -200,10 +200,12 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, uintptr_t host_pc) { uint64_t data[TARGET_INSN_START_WORDS]; -#ifdef CONFIG_PROFILER - TCGProfile *prof = &tcg_ctx->prof; - int64_t ti = profile_getclock(); -#endif + uint64_t ti = 0; + + if (tb_stats_enabled(tb, TB_JIT_TIME)) { + ti = profile_getclock(); + } + int insns_left = cpu_unwind_data_from_tb(tb, host_pc, data); if (insns_left < 0) { @@ -221,11 +223,14 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, cpu->cc->tcg_ops->restore_state_to_opc(cpu, tb, data); -#ifdef CONFIG_PROFILER - qatomic_set(&prof->restore_time, - prof->restore_time + profile_getclock() - ti); - qatomic_set(&prof->restore_count, prof->restore_count + 1); -#endif + if (tb_stats_enabled(tb, TB_JIT_TIME)) { + TBStatistics *ts = tb->tb_stats; + uint64_t elapsed = profile_getclock() - ti; + qemu_mutex_lock(&ts->jit_stats_lock); + ts->tb_restore_time += elapsed; + ts->tb_restore_count++; + qemu_mutex_unlock(&ts->jit_stats_lock); + } } bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc) diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h index 0ccf025ae4..80314c50f9 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -91,6 +91,11 @@ struct TBStatistics { * this TBStats structure. Has to be reset on a tb_flush. */ GPtrArray *tbs; + + /* Recover state from TB */ + uint64_t tb_restore_time; + uint64_t tb_restore_count; + }; bool tb_stats_cmp(const void *ap, const void *bp); @@ -102,6 +107,7 @@ void dump_jit_profile_info(TCGProfile *s, GString *buf); #define TB_NOTHING (1 << 0) #define TB_EXEC_STATS (1 << 1) #define TB_JIT_STATS (1 << 2) +#define TB_JIT_TIME (1 << 3) void enable_collect_tb_stats(void); void disable_collect_tb_stats(void); diff --git a/include/qemu/timer.h b/include/qemu/timer.h index d86fc73a17..ad0da18a5f 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -989,7 +989,6 @@ static inline int64_t cpu_get_host_ticks(void) } #endif -#ifdef CONFIG_PROFILER static inline int64_t profile_getclock(void) { return get_clock(); @@ -997,5 +996,3 @@ static inline int64_t profile_getclock(void) extern uint64_t dev_time; #endif - -#endif From patchwork Fri Apr 21 13:24:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 675855 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp855551wrs; Fri, 21 Apr 2023 06:25:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Y4ao7VmmDWozc9RVPiME9QuJdyNNuRcK8B3DAGNGgzonK9g+lkU7cKa4MDhU2/gWcAJaZU X-Received: by 2002:a05:622a:1442:b0:3ef:54c9:170c with SMTP id v2-20020a05622a144200b003ef54c9170cmr8073790qtx.65.1682083536203; Fri, 21 Apr 2023 06:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682083536; cv=none; d=google.com; s=arc-20160816; b=WIswS87dY2AeM/y5U/oWZAjPwE2DiNpBUF43tprcmM4acts6JTsCkeTKEZ+p1848NW WdW+BN0tEO4nCYloYAVJM2oDj0Hq/1quCGauwLemoREaLNtu/d2VHbafIV7uIy3lMEID VXTBogYyfIIkubzF0e5xXG0sWC1RTzH0A0UdpvwhrU5yMckfl+8uRseat7pvGuB5JL1V mUmqWi/O51SgI4NH+volp06aVAwCQ9bW+/WnHkRrY2Dmw44RGlyZpsFyNywRsI7ELuc4 Az9WzLlotwmdrL9mjGo8d2gmZW6lxdwzdVceZx6ZE6nFKRHjJ63reYKZNi7dQrMV4oOc IzBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=Nw0qBM1PdHQ3cVpF7UcVu35HoqBUtgJ/RxEEAIyrGLU=; b=br/2KUzIPLWFM4lsK89HcbfDbOoM8IGUFSUtvYD6mK1SAmOkXMr8jiLW3kJIAXFDU5 tPD/4XKLMtuxM8T1A99h658PtPLWYdzripKHOHTOEXKhfLGGavg80rjzjIqXm2FUy2pv +tEBvr4Hh2m1Fu3p50mdwmbnVXSvnRwxLALrdX7/FCa7xLUzMD3zabadZVZtPbGF4vhv dVmssar3qhY7LkZDDmL0eDvQ3+kBfpZ/6Hw+lURFrdd7xlFAWHgeOuwimkmto3IH7DB3 T8aDarANiJm1WB7oYObLZ+2tJkIc+IurKi83bovYl94e+0kl47/af2SwjhOBYVwO/cn4 v7OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NTdbepTY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v10-20020a05620a440a00b00746b5597206si3159720qkp.114.2023.04.21.06.25.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Apr 2023 06:25:36 -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=pass header.i=@intel.com header.s=Intel header.b=NTdbepTY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppqlO-0001EJ-V5; Fri, 21 Apr 2023 09:25:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqlO-0001Du-5u for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:25:22 -0400 Received: from mga05.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqlM-0003Mk-1o for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:25:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682083520; x=1713619520; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6xFsTk3Xho4VHsJ3HBo/nRgn1WzJwc8CNVY7PbiuLAM=; b=NTdbepTYLpRCZq++PUjwF88XvgdNu8oMyWUEFZ2rPiCfYFsV6ZlG7z9Y tVaFXNPGTFDuZY54shD8EaKUVz5/Oj2sM7uQmsXFJggKZ/94iFRz6mNMp kvBlp4uv2USNJTytJJbab+ziX7pJ9j2Lsb619tt2xliOyi3wUfNqSTmii MGvwhNL1a6BES0f909Bh0xD6Dbi+kS1aVYDS7v0WZEE3CSJDa2YpKZaZS hdqA5iyD9DPzHfRVSqRJ9ObwfzsUe05Ve6ZtyhhZgPll5bedC8ZkUrYBv rAg3WMjE08BLQXS/8avYTLYVqqfor8qqNdJspsdbKez9m8DG4Dz20ht5u w==; X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="432268367" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="432268367" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2023 06:25:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="756906033" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="756906033" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by fmsmga008.fm.intel.com with ESMTP; 21 Apr 2023 06:25:17 -0700 From: Fei Wu To: alex.bennee@linaro.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PATCH v11 07/14] accel/tcg: convert profiling of code generation to TBStats Date: Fri, 21 Apr 2023 21:24:14 +0800 Message-Id: <20230421132421.1617479-8-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230421132421.1617479-1-fei2.wu@intel.com> References: <20230421132421.1617479-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.43; envelope-from=fei2.wu@intel.com; helo=mga05.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée We continue the conversion of CONFIG_PROFILER data to TBStats by measuring the time it takes to generate code. Instead of calculating elapsed time as we do we simply store key timestamps in the profiler structure and then calculate the totals and add them to TBStats under lock. Signed-off-by: Alex Bennée --- accel/tcg/tb-stats.c | 33 ------------------- accel/tcg/translate-all.c | 69 ++++++++++++++++++++++----------------- include/exec/tb-stats.h | 7 ++++ include/tcg/tcg.h | 14 ++++---- tcg/tcg.c | 17 ++++------ 5 files changed, 59 insertions(+), 81 deletions(-) diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c index a2438a1f51..01adbac2a0 100644 --- a/accel/tcg/tb-stats.c +++ b/accel/tcg/tb-stats.c @@ -88,39 +88,6 @@ void dump_jit_profile_info(TCGProfile *s, GString *buf) jpi->host / (double) jpi->translations); g_string_append_printf(buf, "avg search data/TB %0.1f\n", jpi->search_data / (double) jpi->translations); - - if (s) { - int64_t tot = s->interm_time + s->code_time; - g_string_append_printf(buf, "JIT cycles %" PRId64 - " (%0.3f s at 2.4 GHz)\n", - tot, tot / 2.4e9); - g_string_append_printf(buf, "cycles/op %0.1f\n", - jpi->ops ? (double)tot / jpi->ops : 0); - g_string_append_printf(buf, "cycles/in byte %0.1f\n", - jpi->guest ? (double)tot / jpi->guest : 0); - g_string_append_printf(buf, "cycles/out byte %0.1f\n", - jpi->host ? (double)tot / jpi->host : 0); - g_string_append_printf(buf, "cycles/search byte %0.1f\n", - jpi->search_data ? (double)tot / jpi->search_data : 0); - if (tot == 0) { - tot = 1; - } - g_string_append_printf(buf, " gen_interm time %0.1f%%\n", - (double)s->interm_time / tot * 100.0); - g_string_append_printf(buf, " gen_code time %0.1f%%\n", - (double)s->code_time / tot * 100.0); - g_string_append_printf(buf, "optim./code time %0.1f%%\n", - (double)s->opt_time / (s->code_time ? s->code_time : 1) - * 100.0); - g_string_append_printf(buf, "liveness/code time %0.1f%%\n", - (double)s->la_time / (s->code_time ? s->code_time : 1) - * 100.0); - g_string_append_printf(buf, "cpu_restore count %" PRId64 "\n", - s->restore_count); - g_string_append_printf(buf, " avg cycles %0.1f\n", - s->restore_count ? - (double)s->restore_time / s->restore_count : 0); - } } g_free(jpi); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index bf10987450..92285d0add 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -278,8 +278,9 @@ void page_init(void) */ static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb, target_ulong pc, void *host_pc, - int *max_insns, int64_t *ti) + int *max_insns) { + TCGProfile *prof = &tcg_ctx->prof; int ret = sigsetjmp(tcg_ctx->jmp_trans, 0); if (unlikely(ret != 0)) { return ret; @@ -293,11 +294,9 @@ static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb, tcg_ctx->cpu = NULL; *max_insns = tb->icount; -#ifdef CONFIG_PROFILER - qatomic_set(&tcg_ctx->prof.interm_time, - tcg_ctx->prof.interm_time + profile_getclock() - *ti); - *ti = profile_getclock(); -#endif + if (tb_stats_enabled(tb, TB_JIT_TIME)) { + prof->gen_ir_done_time = profile_getclock(); + } return tcg_gen_code(tcg_ctx, tb, pc); } @@ -348,7 +347,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tcg_insn_unit *gen_code_buf; int gen_code_size, search_size, max_insns; TCGProfile *prof = &tcg_ctx->prof; - int64_t ti; void *host_pc; assert_memory_lock(); @@ -392,10 +390,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tcg_ctx->gen_tb = tb; tb_overflow: -#ifdef CONFIG_PROFILER - ti = profile_getclock(); -#endif - trace_translate_block(tb, pc, tb->tc.ptr); /* @@ -407,11 +401,14 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (tb_stats_collection_enabled() && qemu_log_in_addr_range(tb->pc)) { tb->tb_stats = tb_get_stats(phys_pc, pc, cs_base, flags); + if (tb_stats_enabled(tb, TB_JIT_TIME)) { + prof->gen_start_time = profile_getclock(); + } } else { tb->tb_stats = NULL; } - gen_code_size = setjmp_gen_code(env, tb, pc, host_pc, &max_insns, &ti); + gen_code_size = setjmp_gen_code(env, tb, pc, host_pc, &max_insns); if (unlikely(gen_code_size < 0)) { switch (gen_code_size) { case -1: @@ -463,9 +460,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, */ perf_report_code(pc, tb, tcg_splitwx_to_rx(gen_code_buf)); -#ifdef CONFIG_PROFILER - qatomic_set(&prof->code_time, prof->code_time + profile_getclock() - ti); -#endif + if (tb_stats_enabled(tb, TB_JIT_TIME)) { + prof->gen_code_done_time = profile_getclock(); + } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && @@ -575,26 +572,38 @@ TranslationBlock *tb_gen_code(CPUState *cpu, * Collect JIT stats when enabled. We batch them all up here to * avoid spamming the cache with atomic accesses */ - if (tb_stats_enabled(tb, TB_JIT_STATS)) { + if (tb_stats_enabled(tb, (TB_JIT_STATS | TB_JIT_TIME))) { TBStatistics *ts = tb->tb_stats; qemu_mutex_lock(&ts->jit_stats_lock); - ts->code.num_guest_inst += prof->translation.nb_guest_insns; - ts->code.num_tcg_ops += prof->translation.nb_ops_pre_opt; - ts->code.num_tcg_ops_opt += tcg_ctx->nb_ops; - ts->code.spills += prof->translation.nb_spills; - ts->code.temps += prof->translation.temp_count; - ts->code.deleted_ops += prof->translation.del_op_count; - ts->code.in_len += tb->size; - ts->code.out_len += tb->tc.size; - ts->code.search_out_len += search_size; - - ts->translations.total++; - if (tb_page_addr1(tb) != -1) { - ts->translations.spanning++; + if (tb_stats_enabled(tb, TB_JIT_STATS)) { + ts->code.num_guest_inst += prof->translation.nb_guest_insns; + ts->code.num_tcg_ops += prof->translation.nb_ops_pre_opt; + ts->code.num_tcg_ops_opt += tcg_ctx->nb_ops; + ts->code.spills += prof->translation.nb_spills; + ts->code.temps += prof->translation.temp_count; + ts->code.deleted_ops += prof->translation.del_op_count; + ts->code.in_len += tb->size; + ts->code.out_len += tb->tc.size; + ts->code.search_out_len += search_size; + + ts->translations.total++; + if (tb_page_addr1(tb) != -1) { + ts->translations.spanning++; + } + + g_ptr_array_add(ts->tbs, tb); } - g_ptr_array_add(ts->tbs, tb); + if (tb_stats_enabled(tb, TB_JIT_TIME)) { + ts->gen_times.ir += prof->gen_ir_done_time - prof->gen_start_time; + ts->gen_times.ir_opt += + prof->gen_opt_done_time - prof->gen_ir_done_time; + ts->gen_times.la += + prof->gen_la_done_time - prof->gen_opt_done_time; + ts->gen_times.code += + prof->gen_code_done_time - prof->gen_la_done_time; + } qemu_mutex_unlock(&ts->jit_stats_lock); } diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h index 80314c50f9..a23b6320bd 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -96,6 +96,12 @@ struct TBStatistics { uint64_t tb_restore_time; uint64_t tb_restore_count; + struct { + uint64_t ir; + uint64_t ir_opt; + uint64_t la; + uint64_t code; + } gen_times; }; bool tb_stats_cmp(const void *ap, const void *bp); @@ -103,6 +109,7 @@ bool tb_stats_cmp(const void *ap, const void *bp); void init_tb_stats_htable(void); void dump_jit_profile_info(TCGProfile *s, GString *buf); +void dump_jit_exec_time_info(uint64_t dev_time); #define TB_NOTHING (1 << 0) #define TB_EXEC_STATS (1 << 1) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 645dbaa563..abad5d6a70 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -557,13 +557,13 @@ typedef struct TCGProfile { int64_t code_in_len; int64_t code_out_len; int64_t search_out_len; - int64_t interm_time; - int64_t code_time; - int64_t la_time; - int64_t opt_time; - int64_t restore_count; - int64_t restore_time; - int64_t table_op_count[NB_OPS]; + + /* Timestamps during translation */ + uint64_t gen_start_time; + uint64_t gen_ir_done_time; + uint64_t gen_opt_done_time; + uint64_t gen_la_done_time; + uint64_t gen_code_done_time; } TCGProfile; struct TCGContext { diff --git a/tcg/tcg.c b/tcg/tcg.c index 6f46c87dc1..716afbd980 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4957,18 +4957,13 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start) } #endif -#ifdef CONFIG_PROFILER - qatomic_set(&prof->opt_time, prof->opt_time - profile_getclock()); -#endif - #ifdef USE_TCG_OPTIMIZATIONS tcg_optimize(s); #endif -#ifdef CONFIG_PROFILER - qatomic_set(&prof->opt_time, prof->opt_time + profile_getclock()); - qatomic_set(&prof->la_time, prof->la_time - profile_getclock()); -#endif + if (tb_stats_enabled(tb, TB_JIT_TIME)) { + prof->gen_opt_done_time = profile_getclock(); + } reachable_code_pass(s); liveness_pass_0(s); @@ -4994,9 +4989,9 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start) } } -#ifdef CONFIG_PROFILER - qatomic_set(&prof->la_time, prof->la_time + profile_getclock()); -#endif + if (tb_stats_enabled(tb, TB_JIT_TIME)) { + prof->gen_la_done_time = profile_getclock(); + } #ifdef DEBUG_DISAS if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT) From patchwork Fri Apr 21 13:24:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 675858 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp856287wrs; Fri, 21 Apr 2023 06:27:11 -0700 (PDT) X-Google-Smtp-Source: AKy350bMTNEKDZ96XQLmIhGGHKfJPbAveArL5YYAtHpDAcoWqpukqCX9gCkrkVc8xyCz1NFe8ddg X-Received: by 2002:a05:6214:230f:b0:5f1:6892:743c with SMTP id gc15-20020a056214230f00b005f16892743cmr7916115qvb.24.1682083630906; Fri, 21 Apr 2023 06:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682083630; cv=none; d=google.com; s=arc-20160816; b=ic5ql+LOSXomyvQM6FtNFb36KWL6TI5+Xzc7v8aPblxthksQxFCJ0E6SPG39kD5vQJ b7kSK3dC+qw9C0NLFlkmru08+J/rgtfuKGV9qmcgJ9KHjzQy/Cj1ySn3HB1M0CcwyQER Kno3fb69ZJJkBcKOKRCknUqnpi40JHZ9BLbNJpnglMcEYMnvIOy1qFrmm3AsDQ0GYoy8 Uu2JbOlUfDbk75pb5ZHFpv+RkI/7qK8+Od6xZQzbMu8uWHT5Tw1nt3iXLKlVEvE5An4Q MqjyKa7TiYOKePQqNAODa7X3HDs645jTEnKrrKHeV8M9+rBsu2dAczo2on1aVzMFc86b dnyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=FIDEl/x3HRvbvk2hlw+CRv5KxbP1cI5QYTv5Nos39Ng=; b=kyiAEMEhdLgnSLmyKI5PdtRnUkCv+7GdzHjBi+19+wLt4D3s/0TAn7PE+TpmpGllDX BQmuqO3D6KNwdpBupzGqO77Oy4CpCzrr7xI2PKHL8j8AVB58oCVikO6LuhoCk7Tfiiv0 ycTPBKbYtf0OvI7DfNeUqKsopM4IfyTEio5tCxpnAVarMOvo7/x14UXMZ8Y9droEIMQM 4KUVT3nV/vXwRfdHZ4IgudTMibNtZCB8AHUOPS7j2DBM+gW3p7FcBSp/3YvljmVy9xXd QbHQBm3RtJVq1todE2DxxfZNmSr8uEgif64LfV11ab4U6U1/HhLyTl9eAGkYF0eBlV1Y NzGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=D+BmXccb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a12-20020a0562140c2c00b005ef79fa9aa7si679739qvd.216.2023.04.21.06.27.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Apr 2023 06:27:10 -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=pass header.i=@intel.com header.s=Intel header.b=D+BmXccb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppqld-0001un-7k; Fri, 21 Apr 2023 09:25:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqlb-0001oJ-OL for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:25:35 -0400 Received: from mga05.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqla-0003Mk-0D for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:25:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682083534; x=1713619534; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XNnCNPqtiqglf9cd5+XkKNUU7zTYSnGEAAtNJCADK4M=; b=D+BmXccbn2dlByYbpPClOOIhYWuwq4vPHH5Fp0QCJuZnLTHEfK0/+PcR yV1ctz2V0LVJvfgSVS8QBN4gB2Q29cd0r2TUn/larJkG2B1jSXnoeOsWa pJD16UUiETXnsNrYMc0CQwi3rtG+V+lrA7TEL5hnAsSielDoL3+B6XddG ez97/WU3vdMQDPoXHCPH3w1lDZyRSfdIMuiXrHNZFptIhAx/KI5naIG0O G8+4CFm+qqAcvEu317C8zffbc6fzxyLmN0uEg//HSzWKhuJOzArX53I8E tA4RmdlpKJfg1/XHoHG2d5/shGPPFrP1h2qfkHTUAJ6kug3As4sZHXHLZ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="432268434" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="432268434" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2023 06:25:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="756906076" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="756906076" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by fmsmga008.fm.intel.com with ESMTP; 21 Apr 2023 06:25:32 -0700 From: Fei Wu To: alex.bennee@linaro.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PATCH v11 11/14] tb-stats: reset the tracked TBs on a tb_flush Date: Fri, 21 Apr 2023 21:24:18 +0800 Message-Id: <20230421132421.1617479-12-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230421132421.1617479-1-fei2.wu@intel.com> References: <20230421132421.1617479-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.43; envelope-from=fei2.wu@intel.com; helo=mga05.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée We keep track of translations but can only do so up until the translation cache is flushed. At that point we really have no idea if we can re-create a translation because all the active tracking information has been reset. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- accel/tcg/tb-maint.c | 1 + accel/tcg/tb-stats.c | 19 +++++++++++++++++++ include/exec/tb-stats.h | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index ba1635aa4b..5f946e0285 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -762,6 +762,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE); tb_remove_all(); + tbstats_reset_tbs(); tcg_region_reset_all(); /* XXX: flush processor icache at this point if cache flush is expensive */ qatomic_mb_set(&tb_ctx.tb_flush_count, tb_ctx.tb_flush_count + 1); diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c index 61bfbe96fc..56e944b225 100644 --- a/accel/tcg/tb-stats.c +++ b/accel/tcg/tb-stats.c @@ -269,6 +269,25 @@ void do_hmp_tbstats_safe(CPUState *cpu, run_on_cpu_data icmd) g_free(cmdinfo); } +/* + * We have to reset the tbs array on a tb_flush as those + * TranslationBlocks no longer exist and we no loner know if the + * current mapping is still valid. + */ + +static void reset_tbs_array(void *p, uint32_t hash, void *userp) +{ + TBStatistics *tbs = p; + g_ptr_array_set_size(tbs->tbs, 0); +} + +void tbstats_reset_tbs(void) +{ + if (tb_ctx.tb_stats.map) { + qht_iter(&tb_ctx.tb_stats, reset_tbs_array, NULL); + } +} + void init_tb_stats_htable(void) { if (!tb_ctx.tb_stats.map && tb_stats_collection_enabled()) { diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h index 33eed8d385..ec47cbecc2 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -125,4 +125,12 @@ struct TbstatsCommand { void do_hmp_tbstats_safe(CPUState *cpu, run_on_cpu_data icmd); +/** + * tbstats_reset_tbs: reset the linked array of TBs + * + * Reset the list of tbs for a given array. Should be called from + * safe work during tb_flush. + */ +void tbstats_reset_tbs(void); + #endif From patchwork Fri Apr 21 13:24:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 675859 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp856288wrs; Fri, 21 Apr 2023 06:27:11 -0700 (PDT) X-Google-Smtp-Source: AKy350aTlitaGGaM4NtPFCp4mQLoyQXMQzaHKoBbPyn1YwElA3AgEi/QslSZiqhkXvZSw11z0UB/ X-Received: by 2002:ac8:598a:0:b0:3e6:941b:47e0 with SMTP id e10-20020ac8598a000000b003e6941b47e0mr8725434qte.11.1682083630958; Fri, 21 Apr 2023 06:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682083630; cv=none; d=google.com; s=arc-20160816; b=zCn51wDPZ7TO0rqOZH28vlMYynNnYM7FAJ6IMEgXJV7ODNLVZ93IpEiZReIIkaKvoV 1Nl8A/iXMawIb/lpHXsvD/RRkdFX6zBFypWHtD6pt741OVrWkHgu/AsH/UEQPTC86mQb N7coCFY6EDlyf1SuOYc8UBV0FNie6csDrirVhUVr73pqntldxToFsRS4ce6Ih2R7/K7+ TxTZRw4ZWCgYXha10e/RZQ/4yLRVclrazyK+RKHHlPExpG9C6RRQDl05VHjrzSwWEfAU EaFKnHIgxK0kM6WttvUdumKTGZI7VirvyCGYCQOzG3saPeYq+3t1x0WOsCaDZo5Va2PI hkyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=GR4kAAIreQBvmPZg8CSJQaztweWfqpedQ/ytlNcbXn0=; b=yPsP+sUIAB2iykiwP7qOg9Pf8ZJVhVpqspkF2kOpUk1Dv3LU4YhQGsVjpeZsyoZV9c zRD3xclpUfjVmJGqvAUE1oj66Prlvcb5AtEX2Ysracc0OJc7niQgK/Yi9x37Muom/m2f uNUPPl1OUAkh4toLsXPfg4h+rPvbZ2f3rEDZcSHFa5yWJv9kp9jf/D4HTHIhi5KOYl/R qOflX8NP4il5v3TKlFPvp9nfJO0TliAh1i5PFVgsfhV5FJ4jIUvKzeigADSbebLWNLd1 ezucvlAtT9u8shTGd6mPCA4Oh+qYZYvStmWRKm3yv32ap4eHH9YPjdL51kD2iQyjFhNj /7rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ku8Ernul; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s15-20020ac85ccf000000b003ef5289b59asi2560192qta.277.2023.04.21.06.27.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Apr 2023 06:27:10 -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=pass header.i=@intel.com header.s=Intel header.b=Ku8Ernul; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppqm3-0003KS-NN; Fri, 21 Apr 2023 09:26:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqm2-0003IM-5Y for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:26:02 -0400 Received: from mga05.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppqm0-0003To-Dt for qemu-devel@nongnu.org; Fri, 21 Apr 2023 09:26:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682083560; x=1713619560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VisIyIL59SJMs9taIQIxRXpTBeVwJwWgW9UPXLEeJ2Q=; b=Ku8ErnulHsDMsBwr386lIlM7lvWW27kXrMWlYGQsElSZGQMte1Qbiwku mfgfaEYCdbi9/TO7XnRYcrnwNLYJtlOJ2mzR2hmgZHdh24IUg4X8p+AgR xjOCUdeAL9MIaSB2ym/ol0HSRIj2w6LhE+LOKr6YRMBmjzg7XScw/GqKj L6/UbbL9plgMZoZQRaGZVOUXx9tT7zMXYFHS02HCNbGrCNd7gQBu0kduI a++Gwp6YlPnwFJ+7LrhVG3ZFBGYccLtcy7Y+3cMYCG0aLUhhAltqsKl7p nzDXQ20AkTcNF+aWAWxko4r8fiJL5XLHt7eM1WKyVSh5yNbXhZC/3nwrZ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="432268535" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="432268535" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Apr 2023 06:25:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="756906217" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="756906217" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by fmsmga008.fm.intel.com with ESMTP; 21 Apr 2023 06:25:57 -0700 From: Fei Wu To: alex.bennee@linaro.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v11 14/14] configure: remove the final bits of --profiler support Date: Fri, 21 Apr 2023 21:24:21 +0800 Message-Id: <20230421132421.1617479-15-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230421132421.1617479-1-fei2.wu@intel.com> References: <20230421132421.1617479-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.43; envelope-from=fei2.wu@intel.com; helo=mga05.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée Signed-off-by: Alex Bennée --- meson.build | 2 -- meson_options.txt | 2 -- scripts/meson-buildoptions.sh | 3 --- 3 files changed, 7 deletions(-) diff --git a/meson.build b/meson.build index 29f8644d6d..27627199d7 100644 --- a/meson.build +++ b/meson.build @@ -1872,7 +1872,6 @@ if numa.found() dependencies: numa)) endif config_host_data.set('CONFIG_OPENGL', opengl.found()) -config_host_data.set('CONFIG_PROFILER', get_option('profiler')) config_host_data.set('CONFIG_RBD', rbd.found()) config_host_data.set('CONFIG_RDMA', rdma.found()) config_host_data.set('CONFIG_SDL', sdl.found()) @@ -3823,7 +3822,6 @@ if 'objc' in all_languages summary_info += {'QEMU_OBJCFLAGS': ' '.join(qemu_objcflags)} endif summary_info += {'QEMU_LDFLAGS': ' '.join(qemu_ldflags)} -summary_info += {'profiler': get_option('profiler')} summary_info += {'link-time optimization (LTO)': get_option('b_lto')} summary_info += {'PIE': get_option('b_pie')} summary_info += {'static build': config_host.has_key('CONFIG_STATIC')} diff --git a/meson_options.txt b/meson_options.txt index fc9447d267..163233fda6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -320,8 +320,6 @@ option('qom_cast_debug', type: 'boolean', value: false, option('gprof', type: 'boolean', value: false, description: 'QEMU profiling with gprof', deprecated: true) -option('profiler', type: 'boolean', value: false, - description: 'profiler support') option('slirp_smbd', type : 'feature', value : 'auto', description: 'use smbd (at path --smbd=*) in slirp networking') diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 009fab1515..8a6d61ed90 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -34,7 +34,6 @@ meson_options_help() { printf "%s\n" ' jemalloc/system/tcmalloc)' printf "%s\n" ' --enable-module-upgrades try to load modules from alternate paths for' printf "%s\n" ' upgrades' - printf "%s\n" ' --enable-profiler profiler support' printf "%s\n" ' --enable-qom-cast-debug cast debugging support' printf "%s\n" ' --enable-rng-none dummy RNG, avoid using /dev/(u)random and' printf "%s\n" ' getrandom()' @@ -373,8 +372,6 @@ _meson_option_parse() { --with-pkgversion=*) quote_sh "-Dpkgversion=$2" ;; --enable-png) printf "%s" -Dpng=enabled ;; --disable-png) printf "%s" -Dpng=disabled ;; - --enable-profiler) printf "%s" -Dprofiler=true ;; - --disable-profiler) printf "%s" -Dprofiler=false ;; --enable-pvrdma) printf "%s" -Dpvrdma=enabled ;; --disable-pvrdma) printf "%s" -Dpvrdma=disabled ;; --enable-qcow1) printf "%s" -Dqcow1=enabled ;;