* [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor
@ 2025-07-15 10:40 Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
` (6 more replies)
0 siblings, 7 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:40 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Philippe Mathieu-Daudé, Cameron Esfahani,
Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini, Roman Bolshakov
Missing review: #1 and #5
Philippe Mathieu-Daudé (7):
Revert "accel/tcg: Unregister the RCU before exiting RR thread"
accel/tcg: Extract statistic related code to tcg-stats.c
accel/system: Introduce @x-accel-stats QMP command
accel/system: Add 'info accel' on human monitor
accel/tcg: Propagate AccelState to tcg_dump_stats()
accel/tcg: Implement get_[vcpu]_stats()
accel/hvf: Implement get_vcpu_stats()
qapi/accelerator.json | 17 +++
accel/tcg/internal-common.h | 2 +-
include/accel/accel-cpu-ops.h | 3 +
include/accel/accel-ops.h | 2 +
accel/accel-qmp.c | 35 ++++++
accel/accel-system.c | 9 ++
accel/hvf/hvf-accel-ops.c | 24 ++++
accel/tcg/monitor.c | 202 +-------------------------------
accel/tcg/tcg-accel-ops-rr.c | 2 -
accel/tcg/tcg-all.c | 6 +
accel/tcg/tcg-stats.c | 214 ++++++++++++++++++++++++++++++++++
accel/meson.build | 2 +-
accel/tcg/meson.build | 1 +
hmp-commands-info.hx | 12 ++
14 files changed, 326 insertions(+), 205 deletions(-)
create mode 100644 accel/accel-qmp.c
create mode 100644 accel/tcg/tcg-stats.c
--
2.49.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread"
2025-07-15 10:40 [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
@ 2025-07-15 10:40 ` Philippe Mathieu-Daudé
2025-07-15 11:19 ` Manos Pitsidianakis
2025-07-15 12:38 ` Richard Henderson
2025-07-15 10:40 ` [PATCH-for-10.1 v5 2/7] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
` (5 subsequent siblings)
6 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:40 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Philippe Mathieu-Daudé, Cameron Esfahani,
Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini, Roman Bolshakov,
Peter Maydell
This reverts commit bc93332fe460211c2d2f4ff50e1a0e030c7b5159,
which was merged prematurely, re-introducing Coverity CID 1547782
(unreachable code).
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/tcg-accel-ops-rr.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index a578698d071..6eec5c9eee9 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -302,8 +302,6 @@ static void *rr_cpu_thread_fn(void *arg)
rr_deal_with_unplugged_cpus();
}
- rcu_unregister_thread();
-
g_assert_not_reached();
}
--
2.49.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH-for-10.1 v5 2/7] accel/tcg: Extract statistic related code to tcg-stats.c
2025-07-15 10:40 [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
@ 2025-07-15 10:40 ` Philippe Mathieu-Daudé
2025-07-15 12:44 ` Richard Henderson
2025-07-15 13:18 ` Richard Henderson
2025-07-15 10:40 ` [PATCH-for-10.1 v5 3/7] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
` (4 subsequent siblings)
6 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:40 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Philippe Mathieu-Daudé, Cameron Esfahani,
Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini, Roman Bolshakov,
Zhao Liu
Statistic code is not specific to system emulation (except
cross-page checks) and can be used to analyze user-mode binaries.
Extract statistic related code to its own file: tcg-stats.c,
keeping the original LGPL-2.1-or-later license tag.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
---
accel/tcg/monitor.c | 201 ---------------------------------------
accel/tcg/tcg-stats.c | 215 ++++++++++++++++++++++++++++++++++++++++++
accel/tcg/meson.build | 1 +
3 files changed, 216 insertions(+), 201 deletions(-)
create mode 100644 accel/tcg/tcg-stats.c
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index 778b12613f4..adb9de5a1c6 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -7,213 +7,12 @@
*/
#include "qemu/osdep.h"
-#include "qemu/accel.h"
-#include "qemu/qht.h"
#include "qapi/error.h"
#include "qapi/type-helpers.h"
#include "qapi/qapi-commands-machine.h"
#include "monitor/monitor.h"
-#include "system/cpu-timers.h"
-#include "exec/icount.h"
#include "system/tcg.h"
-#include "tcg/tcg.h"
#include "internal-common.h"
-#include "tb-context.h"
-#include <math.h>
-
-static void dump_drift_info(GString *buf)
-{
- if (!icount_enabled()) {
- return;
- }
-
- g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
- (cpu_get_clock() - icount_get()) / SCALE_MS);
- if (icount_align_option) {
- g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
- -max_delay / SCALE_MS);
- g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
- max_advance / SCALE_MS);
- } else {
- g_string_append_printf(buf, "Max guest delay NA\n");
- g_string_append_printf(buf, "Max guest advance NA\n");
- }
-}
-
-static void dump_accel_info(GString *buf)
-{
- AccelState *accel = current_accel();
- bool one_insn_per_tb = object_property_get_bool(OBJECT(accel),
- "one-insn-per-tb",
- &error_fatal);
-
- g_string_append_printf(buf, "Accelerator settings:\n");
- g_string_append_printf(buf, "one-insn-per-tb: %s\n\n",
- one_insn_per_tb ? "on" : "off");
-}
-
-static void print_qht_statistics(struct qht_stats hst, GString *buf)
-{
- uint32_t hgram_opts;
- size_t hgram_bins;
- char *hgram;
- double avg;
-
- if (!hst.head_buckets) {
- return;
- }
- g_string_append_printf(buf, "TB hash buckets %zu/%zu "
- "(%0.2f%% head buckets used)\n",
- hst.used_head_buckets, hst.head_buckets,
- (double)hst.used_head_buckets /
- hst.head_buckets * 100);
-
- hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
- hgram_opts |= QDIST_PR_100X | QDIST_PR_PERCENT;
- if (qdist_xmax(&hst.occupancy) - qdist_xmin(&hst.occupancy) == 1) {
- hgram_opts |= QDIST_PR_NODECIMAL;
- }
- hgram = qdist_pr(&hst.occupancy, 10, hgram_opts);
- avg = qdist_avg(&hst.occupancy);
- if (!isnan(avg)) {
- g_string_append_printf(buf, "TB hash occupancy "
- "%0.2f%% avg chain occ. "
- "Histogram: %s\n",
- avg * 100, hgram);
- }
- g_free(hgram);
-
- hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
- hgram_bins = qdist_xmax(&hst.chain) - qdist_xmin(&hst.chain);
- if (hgram_bins > 10) {
- hgram_bins = 10;
- } else {
- hgram_bins = 0;
- hgram_opts |= QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE;
- }
- hgram = qdist_pr(&hst.chain, hgram_bins, hgram_opts);
- avg = qdist_avg(&hst.chain);
- if (!isnan(avg)) {
- g_string_append_printf(buf, "TB hash avg chain %0.3f buckets. "
- "Histogram: %s\n",
- avg, hgram);
- }
- g_free(hgram);
-}
-
-struct tb_tree_stats {
- size_t nb_tbs;
- size_t host_size;
- size_t target_size;
- size_t max_target_size;
- size_t direct_jmp_count;
- size_t direct_jmp2_count;
- size_t cross_page;
-};
-
-static gboolean tb_tree_stats_iter(gpointer key, gpointer value, gpointer data)
-{
- const TranslationBlock *tb = value;
- struct tb_tree_stats *tst = data;
-
- tst->nb_tbs++;
- tst->host_size += tb->tc.size;
- tst->target_size += tb->size;
- if (tb->size > tst->max_target_size) {
- tst->max_target_size = tb->size;
- }
- if (tb->page_addr[1] != -1) {
- tst->cross_page++;
- }
- if (tb->jmp_reset_offset[0] != TB_JMP_OFFSET_INVALID) {
- tst->direct_jmp_count++;
- if (tb->jmp_reset_offset[1] != TB_JMP_OFFSET_INVALID) {
- tst->direct_jmp2_count++;
- }
- }
- return false;
-}
-
-static void tlb_flush_counts(size_t *pfull, size_t *ppart, size_t *pelide)
-{
- CPUState *cpu;
- size_t full = 0, part = 0, elide = 0;
-
- CPU_FOREACH(cpu) {
- full += qatomic_read(&cpu->neg.tlb.c.full_flush_count);
- part += qatomic_read(&cpu->neg.tlb.c.part_flush_count);
- elide += qatomic_read(&cpu->neg.tlb.c.elide_flush_count);
- }
- *pfull = full;
- *ppart = part;
- *pelide = elide;
-}
-
-static void tcg_dump_flush_info(GString *buf)
-{
- size_t flush_full, flush_part, flush_elide;
-
- g_string_append_printf(buf, "TB flush count %u\n",
- qatomic_read(&tb_ctx.tb_flush_count));
- g_string_append_printf(buf, "TB invalidate count %u\n",
- qatomic_read(&tb_ctx.tb_phys_invalidate_count));
-
- tlb_flush_counts(&flush_full, &flush_part, &flush_elide);
- g_string_append_printf(buf, "TLB full flushes %zu\n", flush_full);
- g_string_append_printf(buf, "TLB partial flushes %zu\n", flush_part);
- g_string_append_printf(buf, "TLB elided flushes %zu\n", flush_elide);
-}
-
-static void dump_exec_info(GString *buf)
-{
- struct tb_tree_stats tst = {};
- struct qht_stats hst;
- size_t nb_tbs;
-
- tcg_tb_foreach(tb_tree_stats_iter, &tst);
- nb_tbs = tst.nb_tbs;
- /* XXX: avoid using doubles ? */
- g_string_append_printf(buf, "Translation buffer state:\n");
- /*
- * Report total code size including the padding and TB structs;
- * otherwise users might think "-accel tcg,tb-size" is not honoured.
- * For avg host size we use the precise numbers from tb_tree_stats though.
- */
- g_string_append_printf(buf, "gen code size %zu/%zu\n",
- tcg_code_size(), tcg_code_capacity());
- g_string_append_printf(buf, "TB count %zu\n", nb_tbs);
- g_string_append_printf(buf, "TB avg target size %zu max=%zu bytes\n",
- nb_tbs ? tst.target_size / nb_tbs : 0,
- tst.max_target_size);
- g_string_append_printf(buf, "TB avg host size %zu bytes "
- "(expansion ratio: %0.1f)\n",
- nb_tbs ? tst.host_size / nb_tbs : 0,
- tst.target_size ?
- (double)tst.host_size / tst.target_size : 0);
- g_string_append_printf(buf, "cross page TB count %zu (%zu%%)\n",
- tst.cross_page,
- nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0);
- g_string_append_printf(buf, "direct jump count %zu (%zu%%) "
- "(2 jumps=%zu %zu%%)\n",
- tst.direct_jmp_count,
- nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs : 0,
- tst.direct_jmp2_count,
- nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0);
-
- qht_statistics_init(&tb_ctx.htable, &hst);
- print_qht_statistics(hst, buf);
- qht_statistics_destroy(&hst);
-
- g_string_append_printf(buf, "\nStatistics:\n");
- tcg_dump_flush_info(buf);
-}
-
-void tcg_dump_stats(GString *buf)
-{
- dump_accel_info(buf);
- dump_exec_info(buf);
- dump_drift_info(buf);
-}
HumanReadableText *qmp_x_query_jit(Error **errp)
{
diff --git a/accel/tcg/tcg-stats.c b/accel/tcg/tcg-stats.c
new file mode 100644
index 00000000000..eb6e20ae985
--- /dev/null
+++ b/accel/tcg/tcg-stats.c
@@ -0,0 +1,215 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * QEMU TCG statistics
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/accel.h"
+#include "qemu/qht.h"
+#include "qapi/error.h"
+#include "system/cpu-timers.h"
+#include "exec/icount.h"
+#include "hw/core/cpu.h"
+#include "tcg/tcg.h"
+#include "internal-common.h"
+#include "tb-context.h"
+#include <math.h>
+
+static void dump_drift_info(GString *buf)
+{
+ if (!icount_enabled()) {
+ return;
+ }
+
+ g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
+ (cpu_get_clock() - icount_get()) / SCALE_MS);
+ if (icount_align_option) {
+ g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
+ -max_delay / SCALE_MS);
+ g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
+ max_advance / SCALE_MS);
+ } else {
+ g_string_append_printf(buf, "Max guest delay NA\n");
+ g_string_append_printf(buf, "Max guest advance NA\n");
+ }
+}
+
+static void dump_accel_info(GString *buf)
+{
+ AccelState *accel = current_accel();
+ bool one_insn_per_tb = object_property_get_bool(OBJECT(accel),
+ "one-insn-per-tb",
+ &error_fatal);
+
+ g_string_append_printf(buf, "Accelerator settings:\n");
+ g_string_append_printf(buf, "one-insn-per-tb: %s\n\n",
+ one_insn_per_tb ? "on" : "off");
+}
+
+static void print_qht_statistics(struct qht_stats hst, GString *buf)
+{
+ uint32_t hgram_opts;
+ size_t hgram_bins;
+ char *hgram;
+ double avg;
+
+ if (!hst.head_buckets) {
+ return;
+ }
+ g_string_append_printf(buf, "TB hash buckets %zu/%zu "
+ "(%0.2f%% head buckets used)\n",
+ hst.used_head_buckets, hst.head_buckets,
+ (double)hst.used_head_buckets /
+ hst.head_buckets * 100);
+
+ hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
+ hgram_opts |= QDIST_PR_100X | QDIST_PR_PERCENT;
+ if (qdist_xmax(&hst.occupancy) - qdist_xmin(&hst.occupancy) == 1) {
+ hgram_opts |= QDIST_PR_NODECIMAL;
+ }
+ hgram = qdist_pr(&hst.occupancy, 10, hgram_opts);
+ avg = qdist_avg(&hst.occupancy);
+ if (!isnan(avg)) {
+ g_string_append_printf(buf, "TB hash occupancy "
+ "%0.2f%% avg chain occ. "
+ "Histogram: %s\n",
+ avg * 100, hgram);
+ }
+ g_free(hgram);
+
+ hgram_opts = QDIST_PR_BORDER | QDIST_PR_LABELS;
+ hgram_bins = qdist_xmax(&hst.chain) - qdist_xmin(&hst.chain);
+ if (hgram_bins > 10) {
+ hgram_bins = 10;
+ } else {
+ hgram_bins = 0;
+ hgram_opts |= QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE;
+ }
+ hgram = qdist_pr(&hst.chain, hgram_bins, hgram_opts);
+ avg = qdist_avg(&hst.chain);
+ if (!isnan(avg)) {
+ g_string_append_printf(buf, "TB hash avg chain %0.3f buckets. "
+ "Histogram: %s\n",
+ avg, hgram);
+ }
+ g_free(hgram);
+}
+
+struct tb_tree_stats {
+ size_t nb_tbs;
+ size_t host_size;
+ size_t target_size;
+ size_t max_target_size;
+ size_t direct_jmp_count;
+ size_t direct_jmp2_count;
+ size_t cross_page;
+};
+
+static gboolean tb_tree_stats_iter(gpointer key, gpointer value, gpointer data)
+{
+ const TranslationBlock *tb = value;
+ struct tb_tree_stats *tst = data;
+
+ tst->nb_tbs++;
+ tst->host_size += tb->tc.size;
+ tst->target_size += tb->size;
+ if (tb->size > tst->max_target_size) {
+ tst->max_target_size = tb->size;
+ }
+#ifndef CONFIG_USER_ONLY
+ if (tb->page_addr[1] != -1) {
+ tst->cross_page++;
+ }
+#endif
+ if (tb->jmp_reset_offset[0] != TB_JMP_OFFSET_INVALID) {
+ tst->direct_jmp_count++;
+ if (tb->jmp_reset_offset[1] != TB_JMP_OFFSET_INVALID) {
+ tst->direct_jmp2_count++;
+ }
+ }
+ return false;
+}
+
+static void tlb_flush_counts(size_t *pfull, size_t *ppart, size_t *pelide)
+{
+ CPUState *cpu;
+ size_t full = 0, part = 0, elide = 0;
+
+ CPU_FOREACH(cpu) {
+ full += qatomic_read(&cpu->neg.tlb.c.full_flush_count);
+ part += qatomic_read(&cpu->neg.tlb.c.part_flush_count);
+ elide += qatomic_read(&cpu->neg.tlb.c.elide_flush_count);
+ }
+ *pfull = full;
+ *ppart = part;
+ *pelide = elide;
+}
+
+static void tcg_dump_flush_info(GString *buf)
+{
+ size_t flush_full, flush_part, flush_elide;
+
+ g_string_append_printf(buf, "TB flush count %u\n",
+ qatomic_read(&tb_ctx.tb_flush_count));
+ g_string_append_printf(buf, "TB invalidate count %u\n",
+ qatomic_read(&tb_ctx.tb_phys_invalidate_count));
+
+ tlb_flush_counts(&flush_full, &flush_part, &flush_elide);
+ g_string_append_printf(buf, "TLB full flushes %zu\n", flush_full);
+ g_string_append_printf(buf, "TLB partial flushes %zu\n", flush_part);
+ g_string_append_printf(buf, "TLB elided flushes %zu\n", flush_elide);
+}
+
+static void dump_exec_info(GString *buf)
+{
+ struct tb_tree_stats tst = {};
+ struct qht_stats hst;
+ size_t nb_tbs;
+
+ tcg_tb_foreach(tb_tree_stats_iter, &tst);
+ nb_tbs = tst.nb_tbs;
+ /* XXX: avoid using doubles ? */
+ g_string_append_printf(buf, "Translation buffer state:\n");
+ /*
+ * Report total code size including the padding and TB structs;
+ * otherwise users might think "-accel tcg,tb-size" is not honoured.
+ * For avg host size we use the precise numbers from tb_tree_stats though.
+ */
+ g_string_append_printf(buf, "gen code size %zu/%zu\n",
+ tcg_code_size(), tcg_code_capacity());
+ g_string_append_printf(buf, "TB count %zu\n", nb_tbs);
+ g_string_append_printf(buf, "TB avg target size %zu max=%zu bytes\n",
+ nb_tbs ? tst.target_size / nb_tbs : 0,
+ tst.max_target_size);
+ g_string_append_printf(buf, "TB avg host size %zu bytes "
+ "(expansion ratio: %0.1f)\n",
+ nb_tbs ? tst.host_size / nb_tbs : 0,
+ tst.target_size ?
+ (double)tst.host_size / tst.target_size : 0);
+ g_string_append_printf(buf, "cross page TB count %zu (%zu%%)\n",
+ tst.cross_page,
+ nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0);
+ g_string_append_printf(buf, "direct jump count %zu (%zu%%) "
+ "(2 jumps=%zu %zu%%)\n",
+ tst.direct_jmp_count,
+ nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs : 0,
+ tst.direct_jmp2_count,
+ nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0);
+
+ qht_statistics_init(&tb_ctx.htable, &hst);
+ print_qht_statistics(hst, buf);
+ qht_statistics_destroy(&hst);
+
+ g_string_append_printf(buf, "\nStatistics:\n");
+ tcg_dump_flush_info(buf);
+}
+
+void tcg_dump_stats(GString *buf)
+{
+ dump_accel_info(buf);
+ dump_exec_info(buf);
+ dump_drift_info(buf);
+}
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 575e92bb9e8..002aa8f4588 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -11,6 +11,7 @@ tcg_ss.add(files(
'tcg-runtime-gvec.c',
'tb-maint.c',
'tcg-all.c',
+ 'tcg-stats.c',
'translate-all.c',
'translator.c',
))
--
2.49.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH-for-10.1 v5 3/7] accel/system: Introduce @x-accel-stats QMP command
2025-07-15 10:40 [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 2/7] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
@ 2025-07-15 10:40 ` Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 4/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (3 subsequent siblings)
6 siblings, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:40 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Philippe Mathieu-Daudé, Cameron Esfahani,
Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini, Roman Bolshakov,
Zhao Liu
Unstable QMP 'x-accel-stats' dispatches to the
AccelOpsClass::get_stats() and get_vcpu_stats() handlers.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
---
qapi/accelerator.json | 17 +++++++++++++++++
include/accel/accel-cpu-ops.h | 3 +++
include/accel/accel-ops.h | 2 ++
accel/accel-qmp.c | 35 +++++++++++++++++++++++++++++++++++
accel/accel-system.c | 1 +
accel/meson.build | 2 +-
6 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 accel/accel-qmp.c
diff --git a/qapi/accelerator.json b/qapi/accelerator.json
index d55fe1aa0a3..6029e7307a7 100644
--- a/qapi/accelerator.json
+++ b/qapi/accelerator.json
@@ -37,3 +37,20 @@
# <- { "return": { "enabled": true, "present": true } }
##
{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
+
+##
+# @x-accel-stats:
+#
+# Query accelerator statistics
+#
+# Features:
+#
+# @unstable: This command is meant for debugging.
+#
+# Returns: accelerator statistics
+#
+# Since: 10.1
+##
+{ 'command': 'x-accel-stats',
+ 'returns': 'HumanReadableText',
+ 'features': [ 'unstable' ] }
diff --git a/include/accel/accel-cpu-ops.h b/include/accel/accel-cpu-ops.h
index a9191dded7e..0674764914f 100644
--- a/include/accel/accel-cpu-ops.h
+++ b/include/accel/accel-cpu-ops.h
@@ -65,6 +65,9 @@ struct AccelOpsClass {
/* handle_interrupt is mandatory. */
void (*handle_interrupt)(CPUState *cpu, int mask);
+ /* get_vcpu_stats: Append statistics of this @cpu to @buf */
+ void (*get_vcpu_stats)(CPUState *cpu, GString *buf);
+
/**
* @get_virtual_clock: fetch virtual clock
* @set_virtual_clock: set virtual clock
diff --git a/include/accel/accel-ops.h b/include/accel/accel-ops.h
index 86a27c30fa4..23a8c246e15 100644
--- a/include/accel/accel-ops.h
+++ b/include/accel/accel-ops.h
@@ -25,6 +25,8 @@ struct AccelClass {
int (*init_machine)(AccelState *as, MachineState *ms);
bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
void (*cpu_common_unrealize)(CPUState *cpu);
+ /* get_stats: Append statistics to @buf */
+ void (*get_stats)(AccelState *as, GString *buf);
/* system related hooks */
void (*setup_post)(AccelState *as);
diff --git a/accel/accel-qmp.c b/accel/accel-qmp.c
new file mode 100644
index 00000000000..5fb70c6631f
--- /dev/null
+++ b/accel/accel-qmp.c
@@ -0,0 +1,35 @@
+/*
+ * QMP commands related to accelerators
+ *
+ * Copyright (c) Linaro
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/accel.h"
+#include "qapi/type-helpers.h"
+#include "qapi/qapi-commands-accelerator.h"
+#include "accel/accel-ops.h"
+#include "accel/accel-cpu-ops.h"
+#include "hw/core/cpu.h"
+
+HumanReadableText *qmp_x_accel_stats(Error **errp)
+{
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+ g_autoptr(GString) buf = g_string_new("");
+
+ if (acc->get_stats) {
+ acc->get_stats(accel, buf);
+ }
+ if (acc->ops->get_vcpu_stats) {
+ CPUState *cpu;
+
+ CPU_FOREACH(cpu) {
+ acc->ops->get_vcpu_stats(cpu, buf);
+ }
+ }
+
+ return human_readable_text_from_str(buf);
+}
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 8df561b9539..76cf4e7ef7a 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -26,6 +26,7 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
#include "hw/boards.h"
+#include "hw/core/cpu.h"
#include "accel/accel-ops.h"
#include "accel/accel-cpu-ops.h"
#include "system/cpus.h"
diff --git a/accel/meson.build b/accel/meson.build
index 52909314bfa..25b0f100b51 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -1,6 +1,6 @@
common_ss.add(files('accel-common.c'))
specific_ss.add(files('accel-target.c'))
-system_ss.add(files('accel-system.c', 'accel-blocker.c'))
+system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c'))
user_ss.add(files('accel-user.c'))
subdir('tcg')
--
2.49.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH-for-10.1 v5 4/7] accel/system: Add 'info accel' on human monitor
2025-07-15 10:40 [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-07-15 10:40 ` [PATCH-for-10.1 v5 3/7] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
@ 2025-07-15 10:40 ` Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 5/7] accel/tcg: Propagate AccelState to tcg_dump_stats() Philippe Mathieu-Daudé
` (2 subsequent siblings)
6 siblings, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:40 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Philippe Mathieu-Daudé, Cameron Esfahani,
Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini, Roman Bolshakov
'info accel' dispatches to the AccelOpsClass::get_stats()
and get_vcpu_stats() handlers.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
accel/accel-system.c | 8 ++++++++
hmp-commands-info.hx | 12 ++++++++++++
2 files changed, 20 insertions(+)
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 76cf4e7ef7a..1e97c64fdca 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -25,6 +25,8 @@
#include "qemu/osdep.h"
#include "qemu/accel.h"
+#include "qapi/qapi-commands-accelerator.h"
+#include "monitor/monitor.h"
#include "hw/boards.h"
#include "hw/core/cpu.h"
#include "accel/accel-ops.h"
@@ -103,11 +105,17 @@ void accel_init_ops_interfaces(AccelClass *ac)
cpus_register_accel(ops);
}
+static void accel_ops_class_init(ObjectClass *oc, const void *data)
+{
+ monitor_register_hmp_info_hrt("accel", qmp_x_accel_stats);
+}
+
static const TypeInfo accel_ops_type_info = {
.name = TYPE_ACCEL_OPS,
.parent = TYPE_OBJECT,
.abstract = true,
.class_size = sizeof(AccelOpsClass),
+ .class_init = accel_ops_class_init,
};
static void accel_system_register_types(void)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index d7979222752..6142f60e7b1 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -267,6 +267,18 @@ ERST
.cmd = hmp_info_sync_profile,
},
+ {
+ .name = "accel",
+ .args_type = "",
+ .params = "",
+ .help = "show accelerator info",
+ },
+
+SRST
+ ``info accel``
+ Show accelerator info.
+ERST
+
SRST
``info sync-profile [-m|-n]`` [*max*]
Show synchronization profiling info, up to *max* entries (default: 10),
--
2.49.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH-for-10.1 v5 5/7] accel/tcg: Propagate AccelState to tcg_dump_stats()
2025-07-15 10:40 [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-07-15 10:40 ` [PATCH-for-10.1 v5 4/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
@ 2025-07-15 10:40 ` Philippe Mathieu-Daudé
2025-07-15 11:19 ` Manos Pitsidianakis
2025-07-15 13:20 ` Richard Henderson
2025-07-15 10:40 ` [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 7/7] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
6 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:40 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Philippe Mathieu-Daudé, Cameron Esfahani,
Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini, Roman Bolshakov
Next commit will register tcg_dump_stats() as AccelClass::get_stats
handler. Since we want this handler to be called with the correct
accelerator state, propagate it along.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/internal-common.h | 2 +-
accel/tcg/monitor.c | 3 ++-
accel/tcg/tcg-stats.c | 7 +++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index 77a3a0684a5..847ae3914f5 100644
--- a/accel/tcg/internal-common.h
+++ b/accel/tcg/internal-common.h
@@ -139,6 +139,6 @@ G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr);
void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
-void tcg_dump_stats(GString *buf);
+void tcg_dump_stats(AccelState *accel, GString *buf);
#endif
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index adb9de5a1c6..97626da2f1f 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -7,6 +7,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/accel.h"
#include "qapi/error.h"
#include "qapi/type-helpers.h"
#include "qapi/qapi-commands-machine.h"
@@ -23,7 +24,7 @@ HumanReadableText *qmp_x_query_jit(Error **errp)
return NULL;
}
- tcg_dump_stats(buf);
+ tcg_dump_stats(current_accel(), buf);
return human_readable_text_from_str(buf);
}
diff --git a/accel/tcg/tcg-stats.c b/accel/tcg/tcg-stats.c
index eb6e20ae985..02795570b5c 100644
--- a/accel/tcg/tcg-stats.c
+++ b/accel/tcg/tcg-stats.c
@@ -37,9 +37,8 @@ static void dump_drift_info(GString *buf)
}
}
-static void dump_accel_info(GString *buf)
+static void dump_accel_info(AccelState *accel, GString *buf)
{
- AccelState *accel = current_accel();
bool one_insn_per_tb = object_property_get_bool(OBJECT(accel),
"one-insn-per-tb",
&error_fatal);
@@ -207,9 +206,9 @@ static void dump_exec_info(GString *buf)
tcg_dump_flush_info(buf);
}
-void tcg_dump_stats(GString *buf)
+void tcg_dump_stats(AccelState *accel, GString *buf)
{
- dump_accel_info(buf);
+ dump_accel_info(accel, buf);
dump_exec_info(buf);
dump_drift_info(buf);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats()
2025-07-15 10:40 [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-07-15 10:40 ` [PATCH-for-10.1 v5 5/7] accel/tcg: Propagate AccelState to tcg_dump_stats() Philippe Mathieu-Daudé
@ 2025-07-15 10:40 ` Philippe Mathieu-Daudé
2025-07-15 10:42 ` Philippe Mathieu-Daudé
2025-07-15 12:48 ` Richard Henderson
2025-07-15 10:40 ` [PATCH-for-10.1 v5 7/7] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
6 siblings, 2 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:40 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Philippe Mathieu-Daudé, Cameron Esfahani,
Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini, Roman Bolshakov
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/tcg-all.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index eaeb465dfd5..fc3f28e3532 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -236,6 +236,11 @@ static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
}
}
+static void tcg_get_stats(AccelState *as, GString *buf)
+{
+ tcg_dump_stats(as, buf);
+}
+
static void tcg_accel_class_init(ObjectClass *oc, const void *data)
{
AccelClass *ac = ACCEL_CLASS(oc);
@@ -243,6 +248,7 @@ static void tcg_accel_class_init(ObjectClass *oc, const void *data)
ac->init_machine = tcg_init_machine;
ac->cpu_common_realize = tcg_exec_realizefn;
ac->cpu_common_unrealize = tcg_exec_unrealizefn;
+ ac->get_stats = tcg_get_stats;
ac->allowed = &tcg_allowed;
ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
--
2.49.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH-for-10.1 v5 7/7] accel/hvf: Implement get_vcpu_stats()
2025-07-15 10:40 [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-07-15 10:40 ` [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
@ 2025-07-15 10:40 ` Philippe Mathieu-Daudé
2025-07-15 10:57 ` Mads Ynddal
6 siblings, 1 reply; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:40 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Philippe Mathieu-Daudé, Cameron Esfahani,
Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini, Roman Bolshakov
Co-developed-by: Mads Ynddal <mads@ynddal.dk>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
Mads, I welcome your Signed-off-by tag on top :)
---
accel/hvf/hvf-accel-ops.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index 214454bd0b4..94a5bffb44e 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -58,6 +58,7 @@
#include "system/cpus.h"
#include "system/hvf.h"
#include "system/hvf_int.h"
+#include <mach/mach_time.h>
HVFState *hvf_state;
@@ -118,6 +119,12 @@ static void dummy_signal(int sig)
{
}
+static void do_hvf_get_vcpu_exec_time(CPUState *cpu, run_on_cpu_data arg)
+{
+ int r = hv_vcpu_get_exec_time(cpu->accel->fd, arg.host_ptr);
+ assert_hvf_ok(r);
+}
+
static void hvf_vcpu_destroy(CPUState *cpu)
{
hv_return_t ret = hv_vcpu_destroy(cpu->accel->fd);
@@ -347,6 +354,20 @@ static void hvf_remove_all_breakpoints(CPUState *cpu)
}
}
+static void hvf_get_vcpu_stats(CPUState *cpu, GString *buf)
+{
+ uint64_t time_mach; /* units of mach_absolute_time() */
+
+ run_on_cpu(cpu, do_hvf_get_vcpu_exec_time, RUN_ON_CPU_HOST_PTR(&time_mach));
+
+ mach_timebase_info_data_t timebase;
+ mach_timebase_info(&timebase);
+ uint64_t time_ns = time_mach * timebase.numer / timebase.denom;
+
+ g_string_append_printf(buf, "HVF cumulative execution time: %llu.%.3llus\n",
+ time_ns / 1000000000, (time_ns % 1000000000) / 1000000);
+}
+
static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -365,7 +386,10 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->remove_all_breakpoints = hvf_remove_all_breakpoints;
ops->update_guest_debug = hvf_update_guest_debug;
ops->supports_guest_debug = hvf_arch_supports_guest_debug;
+
+ ops->get_vcpu_stats = hvf_get_vcpu_stats;
};
+
static const TypeInfo hvf_accel_ops_type = {
.name = ACCEL_OPS_NAME("hvf"),
--
2.49.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats()
2025-07-15 10:40 ` [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
@ 2025-07-15 10:42 ` Philippe Mathieu-Daudé
2025-07-15 12:48 ` Richard Henderson
1 sibling, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 10:42 UTC (permalink / raw)
To: qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan,
Paolo Bonzini, Roman Bolshakov
Maybe "accel/tcg: Implement get_stats()" is a better subject.
On 15/7/25 12:40, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/tcg-all.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
> index eaeb465dfd5..fc3f28e3532 100644
> --- a/accel/tcg/tcg-all.c
> +++ b/accel/tcg/tcg-all.c
> @@ -236,6 +236,11 @@ static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
> }
> }
>
> +static void tcg_get_stats(AccelState *as, GString *buf)
> +{
> + tcg_dump_stats(as, buf);
> +}
> +
> static void tcg_accel_class_init(ObjectClass *oc, const void *data)
> {
> AccelClass *ac = ACCEL_CLASS(oc);
> @@ -243,6 +248,7 @@ static void tcg_accel_class_init(ObjectClass *oc, const void *data)
> ac->init_machine = tcg_init_machine;
> ac->cpu_common_realize = tcg_exec_realizefn;
> ac->cpu_common_unrealize = tcg_exec_unrealizefn;
> + ac->get_stats = tcg_get_stats;
> ac->allowed = &tcg_allowed;
> ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 7/7] accel/hvf: Implement get_vcpu_stats()
2025-07-15 10:40 ` [PATCH-for-10.1 v5 7/7] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
@ 2025-07-15 10:57 ` Mads Ynddal
0 siblings, 0 replies; 20+ messages in thread
From: Mads Ynddal @ 2025-07-15 10:57 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Manos Pitsidianakis,
Eric Blake, Cameron Esfahani, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov
> On 15 Jul 2025, at 12.40, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Co-developed-by: Mads Ynddal <mads@ynddal.dk>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> Mads, I welcome your Signed-off-by tag on top :)
> ---
> accel/hvf/hvf-accel-ops.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
Looks great :)
Signed-off-by: Mads Ynddal <mads@ynddal.dk>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 5/7] accel/tcg: Propagate AccelState to tcg_dump_stats()
2025-07-15 10:40 ` [PATCH-for-10.1 v5 5/7] accel/tcg: Propagate AccelState to tcg_dump_stats() Philippe Mathieu-Daudé
@ 2025-07-15 11:19 ` Manos Pitsidianakis
2025-07-15 13:20 ` Richard Henderson
1 sibling, 0 replies; 20+ messages in thread
From: Manos Pitsidianakis @ 2025-07-15 11:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov
On Tue, Jul 15, 2025 at 1:40 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Next commit will register tcg_dump_stats() as AccelClass::get_stats
> handler. Since we want this handler to be called with the correct
> accelerator state, propagate it along.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> accel/tcg/internal-common.h | 2 +-
> accel/tcg/monitor.c | 3 ++-
> accel/tcg/tcg-stats.c | 7 +++----
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
> index 77a3a0684a5..847ae3914f5 100644
> --- a/accel/tcg/internal-common.h
> +++ b/accel/tcg/internal-common.h
> @@ -139,6 +139,6 @@ G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
> void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr);
> void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
>
> -void tcg_dump_stats(GString *buf);
> +void tcg_dump_stats(AccelState *accel, GString *buf);
>
> #endif
> diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
> index adb9de5a1c6..97626da2f1f 100644
> --- a/accel/tcg/monitor.c
> +++ b/accel/tcg/monitor.c
> @@ -7,6 +7,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qemu/accel.h"
> #include "qapi/error.h"
> #include "qapi/type-helpers.h"
> #include "qapi/qapi-commands-machine.h"
> @@ -23,7 +24,7 @@ HumanReadableText *qmp_x_query_jit(Error **errp)
> return NULL;
> }
>
> - tcg_dump_stats(buf);
> + tcg_dump_stats(current_accel(), buf);
>
> return human_readable_text_from_str(buf);
> }
> diff --git a/accel/tcg/tcg-stats.c b/accel/tcg/tcg-stats.c
> index eb6e20ae985..02795570b5c 100644
> --- a/accel/tcg/tcg-stats.c
> +++ b/accel/tcg/tcg-stats.c
> @@ -37,9 +37,8 @@ static void dump_drift_info(GString *buf)
> }
> }
>
> -static void dump_accel_info(GString *buf)
> +static void dump_accel_info(AccelState *accel, GString *buf)
> {
> - AccelState *accel = current_accel();
> bool one_insn_per_tb = object_property_get_bool(OBJECT(accel),
> "one-insn-per-tb",
> &error_fatal);
> @@ -207,9 +206,9 @@ static void dump_exec_info(GString *buf)
> tcg_dump_flush_info(buf);
> }
>
> -void tcg_dump_stats(GString *buf)
> +void tcg_dump_stats(AccelState *accel, GString *buf)
> {
> - dump_accel_info(buf);
> + dump_accel_info(accel, buf);
> dump_exec_info(buf);
> dump_drift_info(buf);
> }
> --
> 2.49.0
>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread"
2025-07-15 10:40 ` [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
@ 2025-07-15 11:19 ` Manos Pitsidianakis
2025-07-15 12:38 ` Richard Henderson
1 sibling, 0 replies; 20+ messages in thread
From: Manos Pitsidianakis @ 2025-07-15 11:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Richard Henderson, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov, Peter Maydell
On Tue, Jul 15, 2025 at 1:40 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> This reverts commit bc93332fe460211c2d2f4ff50e1a0e030c7b5159,
> which was merged prematurely, re-introducing Coverity CID 1547782
> (unreachable code).
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> accel/tcg/tcg-accel-ops-rr.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
> index a578698d071..6eec5c9eee9 100644
> --- a/accel/tcg/tcg-accel-ops-rr.c
> +++ b/accel/tcg/tcg-accel-ops-rr.c
> @@ -302,8 +302,6 @@ static void *rr_cpu_thread_fn(void *arg)
> rr_deal_with_unplugged_cpus();
> }
>
> - rcu_unregister_thread();
> -
> g_assert_not_reached();
> }
>
> --
> 2.49.0
>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread"
2025-07-15 10:40 ` [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
2025-07-15 11:19 ` Manos Pitsidianakis
@ 2025-07-15 12:38 ` Richard Henderson
1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2025-07-15 12:38 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Manos Pitsidianakis, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov, Peter Maydell
On 7/15/25 04:40, Philippe Mathieu-Daudé wrote:
> This reverts commit bc93332fe460211c2d2f4ff50e1a0e030c7b5159,
> which was merged prematurely, re-introducing Coverity CID 1547782
> (unreachable code).
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> accel/tcg/tcg-accel-ops-rr.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
> index a578698d071..6eec5c9eee9 100644
> --- a/accel/tcg/tcg-accel-ops-rr.c
> +++ b/accel/tcg/tcg-accel-ops-rr.c
> @@ -302,8 +302,6 @@ static void *rr_cpu_thread_fn(void *arg)
> rr_deal_with_unplugged_cpus();
> }
>
> - rcu_unregister_thread();
> -
> g_assert_not_reached();
> }
>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 2/7] accel/tcg: Extract statistic related code to tcg-stats.c
2025-07-15 10:40 ` [PATCH-for-10.1 v5 2/7] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
@ 2025-07-15 12:44 ` Richard Henderson
2025-07-15 13:18 ` Richard Henderson
1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2025-07-15 12:44 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Manos Pitsidianakis, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov, Zhao Liu
On 7/15/25 04:40, Philippe Mathieu-Daudé wrote:
> Statistic code is not specific to system emulation (except
> cross-page checks) and can be used to analyze user-mode binaries.
But it's not callable from user-mode. At least so far, and within this series.
So, split out the new file if you like, but ...
> diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
> index 575e92bb9e8..002aa8f4588 100644
> --- a/accel/tcg/meson.build
> +++ b/accel/tcg/meson.build
> @@ -11,6 +11,7 @@ tcg_ss.add(files(
> 'tcg-runtime-gvec.c',
> 'tb-maint.c',
> 'tcg-all.c',
> + 'tcg-stats.c',
> 'translate-all.c',
> 'translator.c',
> ))
... leave it within system_ss.
r~
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats()
2025-07-15 10:40 ` [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
2025-07-15 10:42 ` Philippe Mathieu-Daudé
@ 2025-07-15 12:48 ` Richard Henderson
2025-07-15 13:06 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 20+ messages in thread
From: Richard Henderson @ 2025-07-15 12:48 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Manos Pitsidianakis, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov
On 7/15/25 04:40, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/tcg-all.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Oh, this is what causes tcg-stats to be used by user-only binaries, is it?
>
> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
> index eaeb465dfd5..fc3f28e3532 100644
> --- a/accel/tcg/tcg-all.c
> +++ b/accel/tcg/tcg-all.c
> @@ -236,6 +236,11 @@ static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
> }
> }
>
> +static void tcg_get_stats(AccelState *as, GString *buf)
> +{
> + tcg_dump_stats(as, buf);
> +}
Is this shim preparatory for something else?
Otherwise...
> +
> static void tcg_accel_class_init(ObjectClass *oc, const void *data)
> {
> AccelClass *ac = ACCEL_CLASS(oc);
> @@ -243,6 +248,7 @@ static void tcg_accel_class_init(ObjectClass *oc, const void *data)
> ac->init_machine = tcg_init_machine;
> ac->cpu_common_realize = tcg_exec_realizefn;
> ac->cpu_common_unrealize = tcg_exec_unrealizefn;
> + ac->get_stats = tcg_get_stats;
... assign tcg_dump_stats directly?
r~
> ac->allowed = &tcg_allowed;
> ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats()
2025-07-15 12:48 ` Richard Henderson
@ 2025-07-15 13:06 ` Philippe Mathieu-Daudé
2025-07-15 13:18 ` Richard Henderson
0 siblings, 1 reply; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 13:06 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Manos Pitsidianakis, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov
On 15/7/25 14:48, Richard Henderson wrote:
> On 7/15/25 04:40, Philippe Mathieu-Daudé wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>> accel/tcg/tcg-all.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>
> Oh, this is what causes tcg-stats to be used by user-only binaries, is it?
Indeed, otherwise we'd have to use #ifdef'ry or stubs; and there is
no good reason to not dump TCG stats on user emulation (except indeed
this code path is currently unreachable there).
>
>>
>> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
>> index eaeb465dfd5..fc3f28e3532 100644
>> --- a/accel/tcg/tcg-all.c
>> +++ b/accel/tcg/tcg-all.c
>> @@ -236,6 +236,11 @@ static int
>> tcg_gdbstub_supported_sstep_flags(AccelState *as)
>> }
>> }
>> +static void tcg_get_stats(AccelState *as, GString *buf)
>> +{
>> + tcg_dump_stats(as, buf);
>> +}
>
> Is this shim preparatory for something else?
No, I didn't realize during rebase this can be simplified.
> Otherwise...
>
>> +
>> static void tcg_accel_class_init(ObjectClass *oc, const void *data)
>> {
>> AccelClass *ac = ACCEL_CLASS(oc);
>> @@ -243,6 +248,7 @@ static void tcg_accel_class_init(ObjectClass *oc,
>> const void *data)
>> ac->init_machine = tcg_init_machine;
>> ac->cpu_common_realize = tcg_exec_realizefn;
>> ac->cpu_common_unrealize = tcg_exec_unrealizefn;
>> + ac->get_stats = tcg_get_stats;
>
> ... assign tcg_dump_stats directly?
>
>
> r~
>
>> ac->allowed = &tcg_allowed;
>> ac->gdbstub_supported_sstep_flags =
>> tcg_gdbstub_supported_sstep_flags;
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats()
2025-07-15 13:06 ` Philippe Mathieu-Daudé
@ 2025-07-15 13:18 ` Richard Henderson
2025-07-15 13:26 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 20+ messages in thread
From: Richard Henderson @ 2025-07-15 13:18 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Manos Pitsidianakis, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov
On 7/15/25 07:06, Philippe Mathieu-Daudé wrote:
> On 15/7/25 14:48, Richard Henderson wrote:
>> On 7/15/25 04:40, Philippe Mathieu-Daudé wrote:
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>>> accel/tcg/tcg-all.c | 6 ++++++
>>> 1 file changed, 6 insertions(+)
>>
>> Oh, this is what causes tcg-stats to be used by user-only binaries, is it?
>
> Indeed, otherwise we'd have to use #ifdef'ry or stubs; and there is
> no good reason to not dump TCG stats on user emulation (except indeed
> this code path is currently unreachable there).
Ok, that's fine. Let's avoid the ifdefs.
r~
>
>>
>>>
>>> diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
>>> index eaeb465dfd5..fc3f28e3532 100644
>>> --- a/accel/tcg/tcg-all.c
>>> +++ b/accel/tcg/tcg-all.c
>>> @@ -236,6 +236,11 @@ static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
>>> }
>>> }
>>> +static void tcg_get_stats(AccelState *as, GString *buf)
>>> +{
>>> + tcg_dump_stats(as, buf);
>>> +}
>>
>> Is this shim preparatory for something else?
>
> No, I didn't realize during rebase this can be simplified.
>
>> Otherwise...
>>
>>> +
>>> static void tcg_accel_class_init(ObjectClass *oc, const void *data)
>>> {
>>> AccelClass *ac = ACCEL_CLASS(oc);
>>> @@ -243,6 +248,7 @@ static void tcg_accel_class_init(ObjectClass *oc, const void *data)
>>> ac->init_machine = tcg_init_machine;
>>> ac->cpu_common_realize = tcg_exec_realizefn;
>>> ac->cpu_common_unrealize = tcg_exec_unrealizefn;
>>> + ac->get_stats = tcg_get_stats;
>>
>> ... assign tcg_dump_stats directly?
>>
>>
>> r~
>>
>>> ac->allowed = &tcg_allowed;
>>> ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
>>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 2/7] accel/tcg: Extract statistic related code to tcg-stats.c
2025-07-15 10:40 ` [PATCH-for-10.1 v5 2/7] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
2025-07-15 12:44 ` Richard Henderson
@ 2025-07-15 13:18 ` Richard Henderson
1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2025-07-15 13:18 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Manos Pitsidianakis, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov, Zhao Liu
On 7/15/25 04:40, Philippe Mathieu-Daudé wrote:
> Statistic code is not specific to system emulation (except
> cross-page checks) and can be used to analyze user-mode binaries.
> Extract statistic related code to its own file: tcg-stats.c,
> keeping the original LGPL-2.1-or-later license tag.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> Reviewed-by: Zhao Liu<zhao1.liu@intel.com>
> ---
> accel/tcg/monitor.c | 201 ---------------------------------------
> accel/tcg/tcg-stats.c | 215 ++++++++++++++++++++++++++++++++++++++++++
> accel/tcg/meson.build | 1 +
> 3 files changed, 216 insertions(+), 201 deletions(-)
> create mode 100644 accel/tcg/tcg-stats.c
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 5/7] accel/tcg: Propagate AccelState to tcg_dump_stats()
2025-07-15 10:40 ` [PATCH-for-10.1 v5 5/7] accel/tcg: Propagate AccelState to tcg_dump_stats() Philippe Mathieu-Daudé
2025-07-15 11:19 ` Manos Pitsidianakis
@ 2025-07-15 13:20 ` Richard Henderson
1 sibling, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2025-07-15 13:20 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Manos Pitsidianakis, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov
On 7/15/25 04:40, Philippe Mathieu-Daudé wrote:
> Next commit will register tcg_dump_stats() asAccelClass::get_stats
> handler. Since we want this handler to be called with the correct
> accelerator state, propagate it along.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> accel/tcg/internal-common.h | 2 +-
> accel/tcg/monitor.c | 3 ++-
> accel/tcg/tcg-stats.c | 7 +++----
> 3 files changed, 6 insertions(+), 6 deletions(-)
I suppose you could at the same time rename to tcg_get_stats to match the accel hook. But
either way,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats()
2025-07-15 13:18 ` Richard Henderson
@ 2025-07-15 13:26 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 13:26 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Cc: Markus Armbruster, Pierrick Bouvier, Alex Bennée,
Dr. David Alan Gilbert, Manos Pitsidianakis, Eric Blake,
Cameron Esfahani, Mads Ynddal, Phil Dennis-Jordan, Paolo Bonzini,
Roman Bolshakov
On 15/7/25 15:18, Richard Henderson wrote:
> On 7/15/25 07:06, Philippe Mathieu-Daudé wrote:
>> On 15/7/25 14:48, Richard Henderson wrote:
>>> On 7/15/25 04:40, Philippe Mathieu-Daudé wrote:
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>>> ---
>>>> accel/tcg/tcg-all.c | 6 ++++++
>>>> 1 file changed, 6 insertions(+)
>>>
>>> Oh, this is what causes tcg-stats to be used by user-only binaries,
>>> is it?
>>
>> Indeed, otherwise we'd have to use #ifdef'ry or stubs; and there is
>> no good reason to not dump TCG stats on user emulation (except indeed
>> this code path is currently unreachable there).
>
> Ok, that's fine. Let's avoid the ifdefs.
This works for Linux (qemu-foo -d stats.log ...):
-- >8 --
diff --git a/linux-user/exit.c b/linux-user/exit.c
index 1ff8fe4f072..3e304422502 100644
--- a/linux-user/exit.c
+++ b/linux-user/exit.c
@@ -21,7 +21,10 @@
#include "gdbstub/syscalls.h"
#include "qemu.h"
#include "user-internals.h"
+#include "qemu/accel.h"
+#include "qemu/log.h"
#include "qemu/plugin.h"
+#include "accel/tcg/internal-common.h"
#ifdef CONFIG_GCOV
extern void __gcov_dump(void);
@@ -29,10 +32,14 @@ extern void __gcov_dump(void);
void preexit_cleanup(CPUArchState *env, int code)
{
+ g_autoptr(GString) buf = g_string_new("");
+
#ifdef CONFIG_GCOV
__gcov_dump();
#endif
gdb_exit(code);
qemu_plugin_user_exit();
perf_exit();
+ tcg_dump_stats(current_accel(), buf);
+ qemu_log("TCG stats: %s", buf->str);
}
---
^ permalink raw reply related [flat|nested] 20+ messages in thread
end of thread, other threads:[~2025-07-15 14:08 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 10:40 [PATCH-for-10.1 v5 0/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 1/7] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
2025-07-15 11:19 ` Manos Pitsidianakis
2025-07-15 12:38 ` Richard Henderson
2025-07-15 10:40 ` [PATCH-for-10.1 v5 2/7] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
2025-07-15 12:44 ` Richard Henderson
2025-07-15 13:18 ` Richard Henderson
2025-07-15 10:40 ` [PATCH-for-10.1 v5 3/7] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 4/7] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 5/7] accel/tcg: Propagate AccelState to tcg_dump_stats() Philippe Mathieu-Daudé
2025-07-15 11:19 ` Manos Pitsidianakis
2025-07-15 13:20 ` Richard Henderson
2025-07-15 10:40 ` [PATCH-for-10.1 v5 6/7] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
2025-07-15 10:42 ` Philippe Mathieu-Daudé
2025-07-15 12:48 ` Richard Henderson
2025-07-15 13:06 ` Philippe Mathieu-Daudé
2025-07-15 13:18 ` Richard Henderson
2025-07-15 13:26 ` Philippe Mathieu-Daudé
2025-07-15 10:40 ` [PATCH-for-10.1 v5 7/7] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
2025-07-15 10:57 ` Mads Ynddal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).