From patchwork Thu May 18 13:57:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 683379 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp387868wrt; Thu, 18 May 2023 06:57:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xDpEQFHznwBpFa4jymAzM9iWLU8DNDYtH4JAZ5hfdhVsMWDavJRqekBERBIlj0MFnVA/h X-Received: by 2002:a05:622a:1715:b0:3ec:47d5:ec65 with SMTP id h21-20020a05622a171500b003ec47d5ec65mr6332846qtk.60.1684418234540; Thu, 18 May 2023 06:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684418234; cv=none; d=google.com; s=arc-20160816; b=JF4gCaVQ/zyYI/6hnV1QWOdtZ9xGgQpL45x76ayTCZYZUTrhpYLFKa/jTUKH4roGcK IZyyfNRvZY10rxf+H281pX2eIGBdsEjcvN7/WZ7MaSAUQwtJCaL8B0gxp8pf1Ypp9lje QjfFGZly/sgC0c2WKVUhAK5j4d8ldewGG90XjTFOpHU3Ok8GrnXYyN6FvmLe54RveCkI 9PU4jOsLHrB0z/VV8y48kNuLmfWDfJ5HeBg6nql4WO6iX2eps1/+thVvbQcg0Qbf+YHG e3MOIEDsDf3Bt5Vr6UyK+uoX2BUu9yzTqA/Zdh0257sYDsO/fGYng1kgQ4meh8zynF5R H88Q== 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=HLB7DwRaNZTV0QF+Ig8JqQ8jWb7SajLj4Y1gVXAgucg=; b=bemIMOoT3WwFXBx6MmaLGJJKg7UAEx9V5Ah6eIO4KdY1TiOlQYwtcNFquCa01y2f91 2cbnS1l884W2jfNpMe7poxYkr3yxBUVSHY3STKSX1qjIrtOXzWMy4vyNbhhiQNg6t3vn Gl32Kt3tdkEFitasU8nYvKsx9dGePsH+aGYZlcxh1M0e7C3Pi59kwvJ/GK8ZnBLKIXX6 8rAhHReGXVRObgCQGzZVo2EDhYyNyRcjh7QFSFXXwmvVajdbc9oLhFP0qs7L/386GbAB 2opdSjNpAQErwPzRRDoCbBlyzXPK3X+u3Orzsa62mOavx61hgICYWch7e/k6VrDkeHcO 73Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hbBjVBlr; 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 h10-20020ac8584a000000b003f3909dde77si1004677qth.360.2023.05.18.06.57.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 May 2023 06:57:14 -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=hbBjVBlr; 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 1pze7d-00030R-TW; Thu, 18 May 2023 09:56:49 -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 1pze7c-000304-UN for qemu-devel@nongnu.org; Thu, 18 May 2023 09:56:48 -0400 Received: from mga12.intel.com ([192.55.52.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pze7b-0002MR-EH for qemu-devel@nongnu.org; Thu, 18 May 2023 09:56:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684418207; x=1715954207; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ArZMSSGO1qFoz9Hu/1LYlf34qg3L88AfoA5zxcaf5bU=; b=hbBjVBlrCAfX4kfCv8wdSVq4ww+zL+6fanDwhEdm22Ke7H8IreSJT2nW y4IliIpAyO2gH6RbjkQ2OouPWy9CsPrXv2akTiVHZaRRlTvwlRz6xZHy3 tEQkk26OhspJlHt+lrW02LOjujk6Y1HrINpVJ5cQsjINesNqPqnwlVE3Q ADH0metPFD8orIAtOr6m9VHp12Qtg57KuiJcyFtznIdKhHZ9qxeqRTHVy VwD49uPnILo320Mg+5dUC+wlqPulMUoatfitS/mx9wWFiXqX9fmETO09x n3KmvtSuLibM8CrEktg7kgDnHNuLIYvpR8wjK0UoEV5vs/wQuGjBxIGx3 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="331685718" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="331685718" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2023 06:56:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="876428823" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="876428823" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by orsmga005.jf.intel.com with ESMTP; 18 May 2023 06:56:44 -0700 From: Fei Wu To: qemu-devel@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, fei2.wu@intel.com Cc: Paolo Bonzini Subject: [PATCH v12 05/15] accel/tcg: move profiler dev_time to tb_stats Date: Thu, 18 May 2023 21:57:47 +0800 Message-Id: <20230518135757.1442654-6-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518135757.1442654-1-fei2.wu@intel.com> References: <20230518135757.1442654-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.136; envelope-from=fei2.wu@intel.com; helo=mga12.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_PASS=-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 Signed-off-by: Fei Wu --- 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 92fce580f1..d4e044f7f5 100644 --- a/accel/tcg/monitor.c +++ b/accel/tcg/monitor.c @@ -82,8 +82,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 74708d1f40..7deb617446 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 Thu May 18 13:57:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 683380 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp387880wrt; Thu, 18 May 2023 06:57:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4tj+Q+01+r9V2jFn1U5dq0Xu1WNwiP3RzNGWmqFXcU1kQTUpyk+yR4kMuj27aoWRwkYF68 X-Received: by 2002:ad4:5de6:0:b0:61b:5a46:11fd with SMTP id jn6-20020ad45de6000000b0061b5a4611fdmr5504791qvb.36.1684418235926; Thu, 18 May 2023 06:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684418235; cv=none; d=google.com; s=arc-20160816; b=BAM7x02+raYTKttTj+SnUyGsawWvvM4X5PmtADGtqS5YrOVsRcdEujw2r1yE/g9hX7 uKwmkQDE6sVvI+PWIkPz/vQsrxE7F++OQci4VCGMvXR9zAl2hkabzON6giw3mViDkdOx OgBJxaRMpuCzgqrs7XbKcIhD131xjKZfP6oILkBUsUhqIC9o3jo5Oe7UjAp7GOIYDAQ/ qRZYXA6vLvIL/FIogUuNIDhjrSD1T1sHA09kX/z9Qa0tJ+3Hn9jChYdTjEBT/Y4UxwWm RJt9g3vV9iHQCDdL34oZ7ountnduDCvtFvVOpRyEJf7mUpoAOTa8oim0bmSAoqX01/WX ucdg== 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=kfybuZy7OjqaIm2QS4YBNLmOWa2ps3Ekgn8QO5DKRj4=; b=FoME+WpmQ9qXBQ/jaZNLccd+W9bW8939Gj/8cFRRDeAUuYHuCBZSfnWidAsdIMrFHZ EwaeHnJ3UBv6x6SEzsk0xWCWCcHBeX5mXRKNFAlk5DT+XsIbnunb2RLIMG7wVMGdwbDm VG/Gk5GvNZJzIYf09srUxCs0ruw06wqbWhilEi8KGDdO7/vv9F/qA5C2Y2KFB1idwm51 K6toDadND3kAdoNK5hqO9X0O1b0KZmKUc/jj3J0ZHsKoEHYAUSwaWqmrmbo27pi8tM8R PSav9UfQDsJJbtMoACeLN3CsWQ9OYU9cHThl1+aN5llW+GK99ymTiqEIttRdFxUFk3/B ewDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=A0gTHQnT; 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 d12-20020a05622a05cc00b003f38b8a7570si1092833qtb.121.2023.05.18.06.57.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 May 2023 06:57:15 -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=A0gTHQnT; 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 1pze7j-00036D-Be; Thu, 18 May 2023 09:56:55 -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 1pze7g-000311-2E for qemu-devel@nongnu.org; Thu, 18 May 2023 09:56:52 -0400 Received: from mga12.intel.com ([192.55.52.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pze7d-0002Mt-UA for qemu-devel@nongnu.org; Thu, 18 May 2023 09:56:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684418209; x=1715954209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UewUYScSJzMgwxbTkmjVN4d/9L8PVOCdLPtUgmCIYWg=; b=A0gTHQnTXk6jrKQMGwC9dbCpri7IOioQJbtHUbOTijGKH/zWlgGSorov jCBU5sq6l+JQwsHHW405xCW3OfZIJK7PgZVbYyu3usmltttNUwlkMt9Lk F7Gw1Ab50iWvSZI91V/YaSljnL9rSu1Oy6qqUAg5qxSowcPJYqmSGkrFM +xuA0FDhi2+/hBonEtPKQX3eG0aJ4n5cqrknBKwTBKC6FE3wCgFW7agLp Y9i5VZ71w/c7oAaIUBChVG7EyNuB9VyyuUApQFE52envX/fC9hUg+3T+B 8pQdtwckP+Lb5yhppWt6RDGCs3dbmy79lkJ49MQKmI9QkwRCRTBVUUNun g==; X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="331685738" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="331685738" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2023 06:56:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="876428827" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="876428827" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by orsmga005.jf.intel.com with ESMTP; 18 May 2023 06:56:47 -0700 From: Fei Wu To: qemu-devel@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, fei2.wu@intel.com Cc: Paolo Bonzini Subject: [PATCH v12 06/15] accel/tcg: convert profiling of restore operations to TBStats Date: Thu, 18 May 2023 21:57:48 +0800 Message-Id: <20230518135757.1442654-7-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518135757.1442654-1-fei2.wu@intel.com> References: <20230518135757.1442654-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.136; envelope-from=fei2.wu@intel.com; helo=mga12.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_PASS=-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 Signed-off-by: Fei Wu --- accel/tcg/translate-all.c | 23 ++++++++++++++--------- include/exec/tb-stats-flags.h | 1 + include/exec/tb-stats.h | 5 +++++ include/qemu/timer.h | 3 --- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 48ce7df121..beaef03902 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -204,10 +204,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) { @@ -225,11 +227,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-flags.h b/include/exec/tb-stats-flags.h index b62eaaca50..f29eff7576 100644 --- a/include/exec/tb-stats-flags.h +++ b/include/exec/tb-stats-flags.h @@ -14,6 +14,7 @@ #define TB_NOTHING (1 << 0) #define TB_EXEC_STATS (1 << 1) #define TB_JIT_STATS (1 << 2) +#define TB_JIT_TIME (1 << 3) /* TBStatistic collection controls */ void enable_collect_tb_stats(void); diff --git a/include/exec/tb-stats.h b/include/exec/tb-stats.h index 43722ff59d..cc9ab686b8 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -92,6 +92,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); 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 Thu May 18 13:57:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 683382 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp388558wrt; Thu, 18 May 2023 06:58:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7goX8BpNm/mtQucaY7I+MZv9ckFBw3AVzjzf9HvmvWk/OsLEWFaF1QiCoGR1Z+ZyNSUpXC X-Received: by 2002:ac8:5f07:0:b0:3e9:243a:c35b with SMTP id x7-20020ac85f07000000b003e9243ac35bmr5750751qta.51.1684418333358; Thu, 18 May 2023 06:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684418333; cv=none; d=google.com; s=arc-20160816; b=Ijr9LfUI8EDWTfXaVrean7btqAkCVC2FmPBZw3Sj6atIQdlpq9tpzMZVjiEC3U8UgG UXZxB0aCDv5+zR9hc2MTzyPQqv8j6V7UNR4YAi4NY5FSslJbfWIpCq+MnZlg17XT3ilk oEgI1gzRPqAm1r/SZd3gCgkc3lQN0gDXM+RB/rWktDvbFbmKCSVP/WkkRLkXa0TKPcCq PeZEvEw6vorr9/dIy9uirWj0Cg6VHqf4mlJT3gELRya+iCOszKza3/Mjk6pkX0Y1QKt8 KdP/fBzDbdrNxWMZh89PwGJMjQlaiVfRH8hbAC7g/XorFo13aja5xQbA8MlUy+Z3oVlV uEkA== 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=xaMP5qLm8S6jNYW72zZDb770WDxihRYvSaOXKcllezE=; b=CMzmxMuN5S85/FA4Y18OnRzjfGWl8yG9CH+imQCv5z4jp00oZiaaFllGIrvEE9BHU4 axAvSo3IvHROxSz1ZRtqTJ0lXK328s1ONw1Av7H70e+C5HtNFUT5IpWsopmDeK+JF3iA veD/iJKvWKL6w9yvSyVb8du4HYnYGW5RQ99/prjf9UrKk7135ILeV4xlGKLCxAznFcab WGNi9LoyU+8eOx8O0fDtWG+lN2Hfew/o5MsxwA/Pj9FWPhqFNGRfFq21Ib7ml5E8KrXW RoVhoS8JtqA7LFiTUFwPf5xRb8jv1rWUyy0Ew+XHz5xz0lvzK+05fKZL3ZFcpOpxIU1I ayUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HpbUeRec; 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 u20-20020ac858d4000000b003f1a0ec00b1si1027069qta.220.2023.05.18.06.58.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 May 2023 06:58:53 -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=HpbUeRec; 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 1pze81-0003ej-1b; Thu, 18 May 2023 09:57:13 -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 1pze7r-0003Lc-PZ for qemu-devel@nongnu.org; Thu, 18 May 2023 09:57:04 -0400 Received: from mga12.intel.com ([192.55.52.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pze7i-0002Nb-0b for qemu-devel@nongnu.org; Thu, 18 May 2023 09:57:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684418213; x=1715954213; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/gZ1PedlpAhomQcxVZxkJ2uY5o2S3xnuNgEuP+lHrrE=; b=HpbUeReckes9cQ+aK4i4xIXmcybHJXnCH6Eaiqtw4tIpf4e+HTqGGyuw JnnCOQXtBe/O7jalyngpEE2nilCziZ0wxAwTFJEGSTuaPZSLukv/Txow+ 5hA8QHpKIIRb3hlkwMWvQxxoALwTN0lREKkJDaCUFskzWSf9WM3++r30q 4t3i3VQMw37eC3/cYNE4Tl1wwe0rWLd+hQKAjA7McIf/PzETy5QO8oOHL q6us8+cGQ4O89kMRDW316GyZsKTGSjU1zvMUOAB3MvcP7UIJ8CJGttYOT vyeBsTCaWXcw8TJx9OYl54Gu4D0Fx1pj3aXUicBi2HgnaWS4zhmka6Dmk Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="331685752" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="331685752" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2023 06:56:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="876428831" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="876428831" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by orsmga005.jf.intel.com with ESMTP; 18 May 2023 06:56:50 -0700 From: Fei Wu To: qemu-devel@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, fei2.wu@intel.com Cc: Paolo Bonzini Subject: [PATCH v12 07/15] accel/tcg: convert profiling of code generation to TBStats Date: Thu, 18 May 2023 21:57:49 +0800 Message-Id: <20230518135757.1442654-8-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518135757.1442654-1-fei2.wu@intel.com> References: <20230518135757.1442654-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.136; envelope-from=fei2.wu@intel.com; helo=mga12.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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=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 Signed-off-by: Fei Wu --- 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 7deb617446..c40c9a748e 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 beaef03902..ea2b648ffd 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -282,8 +282,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; @@ -297,11 +298,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); } @@ -352,7 +351,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(); @@ -403,10 +401,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb_overflow: -#ifdef CONFIG_PROFILER - ti = profile_getclock(); -#endif - trace_translate_block(tb, pc, tb->tc.ptr); /* @@ -418,11 +412,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: @@ -474,9 +471,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) && @@ -586,26 +583,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 cc9ab686b8..2543367c70 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -97,6 +97,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); @@ -104,5 +110,6 @@ 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); #endif diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 69df21ce4c..9b74c5acce 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 a3a42ef387..9e657719fa 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -6005,18 +6005,13 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t 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); @@ -6042,9 +6037,9 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t 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 Thu May 18 13:57:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 683381 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp388348wrt; Thu, 18 May 2023 06:58:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4UBP9Ra3Hejxq/+0SEYteX4NeAMs2bnCwqYWLf1weJiS6psHnq1O/yPRTHMSOrSAkiOwDM X-Received: by 2002:a05:6214:29e4:b0:5e9:2bad:c8fa with SMTP id jv4-20020a05621429e400b005e92badc8famr5190640qvb.33.1684418298046; Thu, 18 May 2023 06:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684418297; cv=none; d=google.com; s=arc-20160816; b=ZC8yPXjNFb5BC7jEVmQMmDX5Fwa+hQtqVCrPXDuvnFX5Cv4XJv1Ht1pEOuNw2zogQy dcHi7ge1agLGyZkhdYRzTwvh6Z0MeQpJ0j1mDpd+haaEFndELsMjzbkWBOnObhvLRb6g 6dKID4eSvQSm3xZjgSp82/I97m9mfqFNtRK+g+DJPN3/H8Z8hVsZKlgToc6PNnxtjPv5 PctLz+TL5F442NJZG0IdNV1t3F0uMx1uciLS1UyBiTRMQhynI4qrOBPyvDMlx2XKr291 QPMwhiKYG0G3hv3Z6BmrvnxC5/xl08gKDRiwjSza4gHgab3ee7+iLxNyySpxFKtEZetu 7OBg== 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=zXxMnVJh1cVXN5FUGI9LQdzufQ8yDiKbW+XjS2gz2U8=; b=C5PNcWu88NFqJcr7FxZqzm31/jAWpLODuZ2TL5J+gymuH98h80wWuPfsbgYXaSCzQQ aGIbTee10z/GuEqLgrpDrXFa3evQ/HJHrpWeIGfd9oGOdD9OTa1kXEG69E7d7nX5vCNC 2R1MqW7jwHnvTw+eJ9dhg6Kix4YHGjJ4w6vHaksbO3OM7fbSuHZxNFfG9o0kodWFJEHG 0WeDsdy6S36JYLBuzw8Km3vS4joSg/W+Q9B0mO6NTQuCINidEoxA1rEWM/VlKSkQsA/k 6blCxQKxcFGR7yPsUxoVv1DBzTa+HS0nVdb935TUmdIEKxz8WLSe3VjoGpX6ni2m5AXv R/0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jGoONBGa; 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 pt1-20020a056214048100b005ab0738009dsi1150418qvb.263.2023.05.18.06.58.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 May 2023 06:58:17 -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=jGoONBGa; 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 1pze83-0003t5-1X; Thu, 18 May 2023 09:57:15 -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 1pze7x-0003ah-3v for qemu-devel@nongnu.org; Thu, 18 May 2023 09:57:09 -0400 Received: from mga12.intel.com ([192.55.52.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pze7v-0002Nb-DY for qemu-devel@nongnu.org; Thu, 18 May 2023 09:57:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684418227; x=1715954227; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7QNFyBNeGgGdgzd9L+ISvRpqm2xPqBQGWM5cf/izB2Q=; b=jGoONBGaBsgdyqYzRniTG85UiILHgNLXIbXJU/Gs/F5Ax6KpMM2sa3/x 19rn9GgjM62wG1XQM/oy7C+FI0rUfMXmRY+b6ZflSyYvOeH6n5cWqR1JJ Q7oIv1ibVTyQf33b2BKkkHPZmDPulzpyu2V704UANOHMigcjqJ0/kxtQA ERQvhisapIFtFhezdWity/NO2KT259CxTtHSZAdPbRKk+Bn1A9hTRbgHe ArOhTOc7WwFEG1uj3GB+N/cK+sIh6Ql6Plny4WlyyeoljXcXi2raiarCF uDy/kh3T7QV1Fyr1dClv65RXs2JqhKzVsBFlDwV3ooCTWtZVmfUpt/n+f A==; X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="331685841" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="331685841" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2023 06:57:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="876428853" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="876428853" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by orsmga005.jf.intel.com with ESMTP; 18 May 2023 06:57:05 -0700 From: Fei Wu To: qemu-devel@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, fei2.wu@intel.com Cc: Paolo Bonzini Subject: [PATCH v12 11/15] tb-stats: reset the tracked TBs on a tb_flush Date: Thu, 18 May 2023 21:57:53 +0800 Message-Id: <20230518135757.1442654-12-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518135757.1442654-1-fei2.wu@intel.com> References: <20230518135757.1442654-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.136; envelope-from=fei2.wu@intel.com; helo=mga12.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_PASS=-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 Signed-off-by: Fei Wu --- 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 0980fca358..11ff0ddd90 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -763,6 +763,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_inc(&tb_ctx.tb_flush_count); diff --git a/accel/tcg/tb-stats.c b/accel/tcg/tb-stats.c index 55afe6e489..469e3e024b 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 4bb343870b..30b788f7b2 100644 --- a/include/exec/tb-stats.h +++ b/include/exec/tb-stats.h @@ -124,4 +124,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 Thu May 18 13:57:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fei Wu X-Patchwork-Id: 683383 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp388875wrt; Thu, 18 May 2023 06:59:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Xl0LpVWa/7IKZOzufE8l59CWcwRiMAuInPqUjLx9TzEKR39rBcO8DXY8ECgKyTy8esjgz X-Received: by 2002:a05:6214:763:b0:623:8494:9946 with SMTP id f3-20020a056214076300b0062384949946mr5581434qvz.45.1684418374031; Thu, 18 May 2023 06:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684418374; cv=none; d=google.com; s=arc-20160816; b=oSCBzFMRsCe1l6bcZGydLVDwFk0u3M1Ncakth6nqgFdokbJ7hqVI65XWpNgoggs2Ui AeuBRWq/UOTDV4PX3fmo7xi1bcIiVW1uWffSCH5IiJuRQDJ+5vheUzfx09KG4my8a2bt q9UrTLS8a37i9rFR/UcTOSVNhcE4STTSchip3bWjgZOWDvLy6kvAjMdwcY3qIg6rAdD0 IUpM+U/L71ikDjpUL8xon8kfUjdMQp6YBATJtPkdqYsiu8U1BBmvUguS7L93RYExVPIV LRyrc0pAClBe9fHNSjLhRHW2kTFiFoL9m/EQdC3cU2N/MXUkiHL4qFF3AKaBzGlaqrfi oaDg== 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=X3JV11RQF1+wa94BpwFul40z5zrU741X4ptKsWljMMQ=; b=yUDtdpGUmdR5QTequ67f2YrkgYtjK40DHWTqVqVfPp+jzPprLQk6fvG2GayH7DmnkH zR04tNYsAg4eZr6B/6yKKUeuQNuNi7bLP5mZaLt5fV0ZN1m5fnEFWmGuPEdOHFrc3sVQ 1TbCPsIQoI4T663RipP0Ra7CbTF/ZUh4HtyIFbVgsLXOmEODZiQ27GYlQqkxAwEWnIhP DSSXS25wqFJpHmI8rdBX/jcHXT6ln3dN9YhlykprjAHV7S2gDZd3ZG3+Xpei3MBj+cwT oVYTXVW3f5DKGGD13qNcTJdi0sW0CWiYpCcD5DtEiBby9yIhzJXn5FE4oFn1lTsDjQbs 8GTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dYex0jg5; 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 4-20020a05621420c400b0062387bfd1acsi1213495qve.582.2023.05.18.06.59.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 May 2023 06:59:34 -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=dYex0jg5; 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 1pze8A-0004aq-Ba; Thu, 18 May 2023 09:57: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 1pze89-0004aP-GT for qemu-devel@nongnu.org; Thu, 18 May 2023 09:57:21 -0400 Received: from mga12.intel.com ([192.55.52.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pze87-0002T5-RT for qemu-devel@nongnu.org; Thu, 18 May 2023 09:57:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684418239; x=1715954239; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hNy0EL7LNfaBhcec/LSO+OfhCuDllSqA/YNjUll1Ck0=; b=dYex0jg50C9agdISKQUwZQpj+zP4bK6DpFp9gf/v/6/rYCnL6hQc/rTK a0/QzzJI1Cfwz5tva1SGuHj5nJxlE9l3fJdhAEiEaRirrOqRkoEhqyzLu fhlg7fvCiWlmBhb3eATidO/5r+TDBOJ1G9QPekuQdpGAn9PE8wZT36QQp IhwadOeSMdG+BaVOWdOOOlb7kp0bEeWDwPGBR+GBhw/D2Jyt9MsCfLyYZ MntYHy/ISn/SiVXARiSgAudfEJ13IMNtkq6sdUxFoo4+AlyBr3fkLzvrK BUazevpcoGkvKcR1w2Z9tMHVlRWHfDi9OGMujWLg/k2de1T1OpWwNtGmt Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="331685914" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="331685914" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2023 06:57:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="876428871" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="876428871" Received: from wufei-optiplex-7090.sh.intel.com ([10.238.200.247]) by orsmga005.jf.intel.com with ESMTP; 18 May 2023 06:57:16 -0700 From: Fei Wu To: qemu-devel@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org, fei2.wu@intel.com 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 v12 14/15] configure: remove the final bits of --profiler support Date: Thu, 18 May 2023 21:57:56 +0800 Message-Id: <20230518135757.1442654-15-fei2.wu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518135757.1442654-1-fei2.wu@intel.com> References: <20230518135757.1442654-1-fei2.wu@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=192.55.52.136; envelope-from=fei2.wu@intel.com; helo=mga12.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_PASS=-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 Signed-off-by: Fei Wu --- 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 4dddccb890..4be21c9d57 100644 --- a/meson.build +++ b/meson.build @@ -1888,7 +1888,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()) @@ -3859,7 +3858,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 11aec2a441..9692fa7cdc 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -332,8 +332,6 @@ option('qom_cast_debug', type: 'boolean', value: true, 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 52fb079a60..28c7d21a15 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -38,7 +38,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-rng-none dummy RNG, avoid using /dev/(u)random and' printf "%s\n" ' getrandom()' printf "%s\n" ' --enable-strip Strip targets on install' @@ -386,8 +385,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 ;;