[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH RESEND 34/42] accel/split: Implement get_[vcpu]_stats()
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH RESEND 34/42] accel/split: Implement get_[vcpu]_stats() |
Date: |
Fri, 20 Jun 2025 19:27:42 +0200 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/split/split-accel.h | 5 +++++
accel/split/split-accel-ops.c | 24 +++++++++++++++++++++++-
accel/split/split-all.c | 16 +++++++++++++++-
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/accel/split/split-accel.h b/accel/split/split-accel.h
index 8a2888507f3..80a19bbb1e5 100644
--- a/accel/split/split-accel.h
+++ b/accel/split/split-accel.h
@@ -36,6 +36,11 @@ struct SplitAccelState {
char *hw_name;
char *sw_name;
+
+ struct {
+ unsigned transitions; /* number of HW <-> SW transitions */
+ uint64_t exec_count[2]; /* SW:0 HW:1 */
+ } stats;
};
struct AccelCPUState {
diff --git a/accel/split/split-accel-ops.c b/accel/split/split-accel-ops.c
index d59e70e0d9b..615faf1d96b 100644
--- a/accel/split/split-accel-ops.c
+++ b/accel/split/split-accel-ops.c
@@ -9,6 +9,7 @@
#include "qemu/osdep.h"
#include "qemu/main-loop.h"
#include "qemu/guest-random.h"
+#include "qapi/type-helpers.h"
#include "exec/cpu-common.h"
#include "exec/cpu-interrupt.h"
#include "hw/core/cpu.h"
@@ -16,6 +17,7 @@
#include "system/cpus.h"
#include "system/hw_accel.h"
#include "system/tcg.h"
+#include "monitor/monitor.h"
#include "split-accel.h"
#include "trace.h"
@@ -70,6 +72,7 @@ static void *split_cpu_thread_routine(void *arg)
r = swops->exec_vcpu_thread(cpu);
trace_accel_split_exec_vcpu_thread_sw(r);
}
+ sas->stats.exec_count[acs->use_hw]++;
switch (r) {
case 0:
if (acs->use_hw) {
@@ -103,6 +106,7 @@ static void *split_cpu_thread_routine(void *arg)
assert(!acs->use_hw);
trace_accel_split_hw_accelerate();
acs->use_hw = true;
+ sas->stats.transitions++;
break;
default:
/* Ignore everything else? */
@@ -314,7 +318,25 @@ static void split_remove_all_breakpoints(CPUState *cpu)
static void split_get_vcpu_stats(CPUState *cpu, GString *buf)
{
- g_assert_not_reached();
+ SplitAccelState *sas = SPLIT_ACCEL(cpu->accel->accel);
+ AccelClass *hwc = ACCEL_GET_CLASS(sas->hw);
+ AccelClass *swc = ACCEL_GET_CLASS(sas->sw);
+ g_autofree char *cpu_model =
+ cpu_model_from_type(object_get_typename(OBJECT(cpu)));
+
+ if (cpu->cluster_index != -1) {
+ g_string_append_printf(buf, "CPU#%d@%d: %s\n",
+ cpu->cpu_index, cpu->cluster_index, cpu_model);
+ } else {
+ g_string_append_printf(buf, "CPU#%d: %s\n",
+ cpu->cpu_index, cpu_model);
+ }
+ if (hwc->ops->get_vcpu_stats) {
+ hwc->ops->get_vcpu_stats(cpu, buf);
+ }
+ if (swc->ops->get_vcpu_stats) {
+ swc->ops->get_vcpu_stats(cpu, buf);
+ }
}
static void split_accel_ops_class_init(ObjectClass *oc, const void *data)
diff --git a/accel/split/split-all.c b/accel/split/split-all.c
index 413954af96c..9e0848db971 100644
--- a/accel/split/split-all.c
+++ b/accel/split/split-all.c
@@ -94,7 +94,21 @@ static int split_gdbstub_supported_sstep_flags(AccelState
*as)
static void split_get_stats(AccelState *as, GString *buf)
{
- g_assert_not_reached();
+ SplitAccelState *sas = SPLIT_ACCEL(as);
+ AccelClass *hwc = ACCEL_GET_CLASS(sas->hw);
+ AccelClass *swc = ACCEL_GET_CLASS(sas->sw);
+
+ g_string_append_printf(buf,
+ "%u transitions, %llu SW and %llu HW executions\n",
+ sas->stats.transitions,
+ sas->stats.exec_count[0],
+ sas->stats.exec_count[1]);
+ if (hwc->get_stats) {
+ hwc->get_stats(as, buf);
+ }
+ if (swc->get_stats) {
+ swc->get_stats(as, buf);
+ }
}
static char *split_get_hw(Object *obj, Error **errp)
--
2.49.0
- [RFC PATCH RESEND 10/42] accel/split: Define and allocate AccelCPUState, (continued)
- [RFC PATCH RESEND 10/42] accel/split: Define and allocate AccelCPUState, Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 14/42] accel/split: Implement synchronize_post_init(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 08/42] accel/split: Implement gdbstub_supported_sstep_flags(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 11/42] accel/split: Register MTTCG, Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 24/42] accel/split: Implement handle_interrupt(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 33/42] accel/split: Implement update_guest_debug(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 37/42] accel/hvf: Emulate HVC at EL2, Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 41/42] tests/functional: Add split_available() helper, Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 25/42] accel/split: Empty ops_init(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 31/42] accel/split: Implement remove_breakpoint(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 34/42] accel/split: Implement get_[vcpu]_stats(),
Philippe Mathieu-Daudé <=
- [RFC PATCH RESEND 40/42] accel/split: Call TCGCPUOps::rebuild_tb_hflags(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 01/42] accel/split: Minimal stubs for split accelerator, Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 07/42] accel/split: Implement supports_guest_debug(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 05/42] accel/split: Expose 'hw' and 'sw' properties, Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 12/42] accel/split: Have thread routine ready to dispatch over HW/SW, Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 16/42] accel/split: Implement synchronize_state(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 19/42] accel/split: Implement kick_vcpu_thread(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 23/42] target/arm: Implement SysemuCPUOps::can_accelerate() handler, Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 27/42] accel/split: Empty get_elapsed_ticks(), Philippe Mathieu-Daudé, 2025/06/20
- [RFC PATCH RESEND 28/42] accel/split: Empty cpu_thread_is_idle(), Philippe Mathieu-Daudé, 2025/06/20