[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 1/2] icount: Print instruction count on exit
From: |
Christopher Covington |
Subject: |
[Qemu-devel] [RFC 1/2] icount: Print instruction count on exit |
Date: |
Tue, 11 Aug 2015 11:08:31 -0400 |
When -icount shift=n is in use, print the instruction count when
finished. In conjunction with the `time` command, this can be used to
calculate how many instructions per second QEMU TCG can translate and
execute. The output can also be used to double-check future facilities
such as exposing the instruction count to guest/target software
through interfaces such as an emulated Performance Monitors Unit.
Signed-off-by: Christopher Covington <address@hidden>
---
cpus.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/cpus.c b/cpus.c
index a822ce3..b0bc8ec 100644
--- a/cpus.c
+++ b/cpus.c
@@ -511,6 +511,13 @@ void cpu_ticks_init(void)
vmstate_register(NULL, 0, &vmstate_timers, &timers_state);
}
+static Notifier icount_exit_notifier;
+
+static void print_instruction_count(Notifier *notifier, void *data)
+{
+ printf("Executed %"PRId64" target instructions.\n", cpu_get_icount_raw());
+}
+
void configure_icount(QemuOpts *opts, Error **errp)
{
const char *option;
@@ -541,6 +548,8 @@ void configure_icount(QemuOpts *opts, Error **errp)
if (errno != 0 || *rem_str != '\0' || !strlen(option)) {
error_setg(errp, "icount: Invalid shift value");
}
+ icount_exit_notifier.notify = &print_instruction_count;
+ qemu_add_exit_notifier(&icount_exit_notifier);
use_icount = 1;
return;
} else if (icount_align_option) {
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project