* [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor
@ 2025-07-15 14:00 Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 1/8] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal
Since v5:
- Addressed rth review comments
- Added R-b tags
Philippe Mathieu-Daudé (8):
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 dump_accel_info()
accel/tcg: Implement AccelClass::get_stats() handler
accel/hvf: Implement AccelClass::get_vcpu_stats()
[NOTFORMERGE] linux-user: Dump TCG stats to logfile
qapi/accelerator.json | 17 +++
accel/tcg/internal-common.h | 2 +-
include/accel/accel-cpu-ops.h | 3 +
include/accel/accel-ops.h | 2 +
include/tcg/tcg.h | 2 +
accel/accel-qmp.c | 35 ++++++
accel/accel-system.c | 9 ++
accel/hvf/hvf-accel-ops.c | 24 ++++
accel/tcg/monitor.c | 200 -------------------------------
accel/tcg/tcg-accel-ops-rr.c | 2 -
accel/tcg/tcg-all.c | 1 +
accel/tcg/tcg-stats.c | 219 ++++++++++++++++++++++++++++++++++
linux-user/exit.c | 6 +
accel/meson.build | 2 +-
accel/tcg/meson.build | 1 +
hmp-commands-info.hx | 12 ++
16 files changed, 333 insertions(+), 204 deletions(-)
create mode 100644 accel/accel-qmp.c
create mode 100644 accel/tcg/tcg-stats.c
--
2.49.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH-for-10.1 v6 1/8] Revert "accel/tcg: Unregister the RCU before exiting RR thread"
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
@ 2025-07-15 14:00 ` Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 2/8] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal, 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>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@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] 10+ messages in thread
* [PATCH-for-10.1 v6 2/8] accel/tcg: Extract statistic related code to tcg-stats.c
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 1/8] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
@ 2025-07-15 14:00 ` Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 3/8] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal, 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.
Note, this code is not yet reachable by user-mode.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
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] 10+ messages in thread
* [PATCH-for-10.1 v6 3/8] accel/system: Introduce @x-accel-stats QMP command
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 1/8] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 2/8] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
@ 2025-07-15 14:00 ` Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 4/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal, 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] 10+ messages in thread
* [PATCH-for-10.1 v6 4/8] accel/system: Add 'info accel' on human monitor
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-07-15 14:00 ` [PATCH-for-10.1 v6 3/8] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
@ 2025-07-15 14:00 ` Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 5/8] accel/tcg: Propagate AccelState to dump_accel_info() Philippe Mathieu-Daudé
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal
'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] 10+ messages in thread
* [PATCH-for-10.1 v6 5/8] accel/tcg: Propagate AccelState to dump_accel_info()
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-07-15 14:00 ` [PATCH-for-10.1 v6 4/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
@ 2025-07-15 14:00 ` Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 6/8] accel/tcg: Implement AccelClass::get_stats() handler Philippe Mathieu-Daudé
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal
Declare tcg_dump_stats() in "tcg/tcg.h" so it can be used out of
accel/tcg/, like by {bsd,linux}-user.
Next commit will register the TCG AccelClass::get_stats handler,
which expects a AccelState, so propagate it to dump_accel_info().
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/internal-common.h | 2 --
include/tcg/tcg.h | 2 ++
accel/tcg/monitor.c | 1 +
accel/tcg/tcg-stats.c | 5 ++---
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index 77a3a0684a5..1dbc45dd955 100644
--- a/accel/tcg/internal-common.h
+++ b/accel/tcg/internal-common.h
@@ -139,6 +139,4 @@ 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);
-
#endif
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 0c2a319c11d..a6d9aa50d47 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -1005,5 +1005,7 @@ static inline const TCGOpcode *tcg_swap_vecop_list(const TCGOpcode *n)
bool tcg_can_emit_vecop_list(const TCGOpcode *, TCGType, unsigned);
void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs);
+/* tcg_dump_stats: Append TCG statistics to @buf */
+void tcg_dump_stats(GString *buf);
#endif /* TCG_H */
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
index adb9de5a1c6..be5c1950177 100644
--- a/accel/tcg/monitor.c
+++ b/accel/tcg/monitor.c
@@ -12,6 +12,7 @@
#include "qapi/qapi-commands-machine.h"
#include "monitor/monitor.h"
#include "system/tcg.h"
+#include "tcg/tcg.h"
#include "internal-common.h"
HumanReadableText *qmp_x_query_jit(Error **errp)
diff --git a/accel/tcg/tcg-stats.c b/accel/tcg/tcg-stats.c
index eb6e20ae985..e1a1c4cf4ac 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);
@@ -209,7 +208,7 @@ static void dump_exec_info(GString *buf)
void tcg_dump_stats(GString *buf)
{
- dump_accel_info(buf);
+ dump_accel_info(current_accel(), buf);
dump_exec_info(buf);
dump_drift_info(buf);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH-for-10.1 v6 6/8] accel/tcg: Implement AccelClass::get_stats() handler
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-07-15 14:00 ` [PATCH-for-10.1 v6 5/8] accel/tcg: Propagate AccelState to dump_accel_info() Philippe Mathieu-Daudé
@ 2025-07-15 14:00 ` Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 7/8] accel/hvf: Implement AccelClass::get_vcpu_stats() Philippe Mathieu-Daudé
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal
Factor tcg_get_stats() out of tcg_dump_stats(),
passing the current accelerator argument to match
the AccelClass::get_stats() prototype.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/internal-common.h | 2 ++
accel/tcg/tcg-all.c | 1 +
accel/tcg/tcg-stats.c | 9 +++++++--
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index 1dbc45dd955..6adfeefe131 100644
--- a/accel/tcg/internal-common.h
+++ b/accel/tcg/internal-common.h
@@ -139,4 +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_get_stats(AccelState *accel, GString *buf);
+
#endif
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index eaeb465dfd5..5125e1a4e27 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -243,6 +243,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;
diff --git a/accel/tcg/tcg-stats.c b/accel/tcg/tcg-stats.c
index e1a1c4cf4ac..ced5dec0c4f 100644
--- a/accel/tcg/tcg-stats.c
+++ b/accel/tcg/tcg-stats.c
@@ -206,9 +206,14 @@ static void dump_exec_info(GString *buf)
tcg_dump_flush_info(buf);
}
-void tcg_dump_stats(GString *buf)
+void tcg_get_stats(AccelState *accel, GString *buf)
{
- dump_accel_info(current_accel(), buf);
+ dump_accel_info(accel, buf);
dump_exec_info(buf);
dump_drift_info(buf);
}
+
+void tcg_dump_stats(GString *buf)
+{
+ tcg_get_stats(current_accel(), buf);
+}
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH-for-10.1 v6 7/8] accel/hvf: Implement AccelClass::get_vcpu_stats()
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-07-15 14:00 ` [PATCH-for-10.1 v6 6/8] accel/tcg: Implement AccelClass::get_stats() handler Philippe Mathieu-Daudé
@ 2025-07-15 14:00 ` Philippe Mathieu-Daudé
2025-07-15 14:00 ` [NOTFORMERGE PATCH-for-10.1 v6 8/8] linux-user: Dump TCG stats to logfile Philippe Mathieu-Daudé
2025-07-15 19:28 ` [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal
Co-developed-by: Mads Ynddal <mads@ynddal.dk>
Signed-off-by: Mads Ynddal <mads@ynddal.dk>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
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] 10+ messages in thread
* [NOTFORMERGE PATCH-for-10.1 v6 8/8] linux-user: Dump TCG stats to logfile
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-07-15 14:00 ` [PATCH-for-10.1 v6 7/8] accel/hvf: Implement AccelClass::get_vcpu_stats() Philippe Mathieu-Daudé
@ 2025-07-15 14:00 ` Philippe Mathieu-Daudé
2025-07-15 19:28 ` [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 14:00 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster,
Philippe Mathieu-Daudé, Cameron Esfahani, Laurent Vivier,
Manos Pitsidianakis, Dr. David Alan Gilbert, Alex Bennée,
Roman Bolshakov, Eric Blake, Paolo Bonzini, Pierrick Bouvier,
Richard Henderson, Mads Ynddal
Running 'qemu-user -D stats.log' will dump TCG statistics
to 'stats.log' before exiting.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
linux-user/exit.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/exit.c b/linux-user/exit.c
index 1ff8fe4f072..17d2ad0517b 100644
--- a/linux-user/exit.c
+++ b/linux-user/exit.c
@@ -21,7 +21,9 @@
#include "gdbstub/syscalls.h"
#include "qemu.h"
#include "user-internals.h"
+#include "qemu/log.h"
#include "qemu/plugin.h"
+#include "tcg/tcg.h"
#ifdef CONFIG_GCOV
extern void __gcov_dump(void);
@@ -29,10 +31,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(buf);
+ qemu_log("TCG stats: %s", buf->str);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2025-07-15 14:00 ` [NOTFORMERGE PATCH-for-10.1 v6 8/8] linux-user: Dump TCG stats to logfile Philippe Mathieu-Daudé
@ 2025-07-15 19:28 ` Philippe Mathieu-Daudé
8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-07-15 19:28 UTC (permalink / raw)
To: qemu-devel
Cc: Phil Dennis-Jordan, Markus Armbruster, Cameron Esfahani,
Laurent Vivier, Manos Pitsidianakis, Dr. David Alan Gilbert,
Alex Bennée, Roman Bolshakov, Eric Blake, Paolo Bonzini,
Pierrick Bouvier, Richard Henderson, Mads Ynddal
On 15/7/25 16:00, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (8):
> 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 dump_accel_info()
> accel/tcg: Implement AccelClass::get_stats() handler
> accel/hvf: Implement AccelClass::get_vcpu_stats()
1-7 queued, thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-07-15 19:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 14:00 [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 1/8] Revert "accel/tcg: Unregister the RCU before exiting RR thread" Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 2/8] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 3/8] accel/system: Introduce @x-accel-stats QMP command Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 4/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 5/8] accel/tcg: Propagate AccelState to dump_accel_info() Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 6/8] accel/tcg: Implement AccelClass::get_stats() handler Philippe Mathieu-Daudé
2025-07-15 14:00 ` [PATCH-for-10.1 v6 7/8] accel/hvf: Implement AccelClass::get_vcpu_stats() Philippe Mathieu-Daudé
2025-07-15 14:00 ` [NOTFORMERGE PATCH-for-10.1 v6 8/8] linux-user: Dump TCG stats to logfile Philippe Mathieu-Daudé
2025-07-15 19:28 ` [PATCH-for-10.1 v6 0/8] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
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).