[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/32] separate accelerator part of info profiler
From: |
Glauber Costa |
Subject: |
[Qemu-devel] [PATCH 11/32] separate accelerator part of info profiler |
Date: |
Thu, 23 Oct 2008 12:18:55 -0200 |
From: Glauber Costa <address@hidden>
Yet another accel field: profile.
It allows the accelerators to do part of the profiling their own way.
Signed-off-by: Glauber Costa <address@hidden>
---
accel.c | 1 +
accel.h | 6 ++++++
kqemu.c | 35 +++++++++++++++++++++++++++++++++++
monitor.c | 27 ++++++---------------------
4 files changed, 48 insertions(+), 21 deletions(-)
diff --git a/accel.c b/accel.c
index cb615d7..40dfac6 100644
--- a/accel.c
+++ b/accel.c
@@ -22,5 +22,6 @@ QEMUAccel noaccel = {
.flush_cache = accel_nop,
.flush_page = accel_nop,
.info = noaccel_info,
+ .profile = accel_nop,
};
diff --git a/accel.h b/accel.h
index 549ce01..bb56526 100644
--- a/accel.h
+++ b/accel.h
@@ -9,6 +9,7 @@ typedef struct QEMUAccel {
void (*flush_cache)(CPUState *env, int global);
void (*flush_page)(CPUState *env, target_ulong addr);
int (*info)(CPUState *env, char *buf);
+ int (*profile)(CPUState *env, char *buf);
} QEMUAccel;
extern QEMUAccel *current_accel;
@@ -43,4 +44,9 @@ static inline int accel_info(CPUState *env, char *buf)
{
return current_accel->info(env, buf);
}
+
+static inline int accel_profile(CPUState *env, char *buf)
+{
+ return current_accel->profile(env, buf);
+}
#endif
diff --git a/kqemu.c b/kqemu.c
index 424d8f4..0a1d63b 100644
--- a/kqemu.c
+++ b/kqemu.c
@@ -53,6 +53,10 @@
#include "kqemu.h"
#include "accel.h"
+#ifdef CONFIG_PROFILER
+#include "qemu-timer.h" /* for ticks_per_sec */
+#endif
+
#ifdef _WIN32
#define KQEMU_DEVICE "\\\\.\\kqemu"
#else
@@ -1072,12 +1076,43 @@ static int kqemu_info(CPUState *env, char *buf)
return len;
}
+int64_t kqemu_time;
+int64_t kqemu_exec_count;
+int64_t kqemu_ret_int_count;
+int64_t kqemu_ret_excp_count;
+int64_t kqemu_ret_intr_count;
+extern int64_t qemu_time;
+
+static int kqemu_profile(CPUState *env, char *buf)
+{
+ int len = 0;
+#ifdef CONFIG_PROFILER
+ len = sprintf(buf, "kqemu time %" PRId64 " (%0.3f %0.1f%%) count=%" PRId64
+ " int=%" PRId64 " excp=%" PRId64 " intr=%" PRId64 "\n",
+ kqemu_time, kqemu_time / (double)ticks_per_sec,
+ kqemu_time / qemu_time * 100.0,
+ kqemu_exec_count,
+ kqemu_ret_int_count,
+ kqemu_ret_excp_count,
+ kqemu_ret_intr_count);
+
+ kqemu_time = 0;
+ kqemu_exec_count = 0;
+ kqemu_ret_int_count = 0;
+ kqemu_ret_excp_count = 0;
+ kqemu_ret_intr_count = 0;
+ kqemu_record_dump();
+#endif
+ return len;
+}
+
QEMUAccel kqemu_accel = {
.cpu_interrupt = kqemu_cpu_interrupt,
.init_env = kqemu_init_env,
.flush_cache = kqemu_flush,
.flush_page = kqemu_flush_page,
.info = kqemu_info,
+ .profile = kqemu_profile,
};
#endif
diff --git a/monitor.c b/monitor.c
index d3ab137..42a1b02 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1254,17 +1254,14 @@ static void do_info_accelerator(void)
#ifdef CONFIG_PROFILER
-int64_t kqemu_time;
int64_t qemu_time;
-int64_t kqemu_exec_count;
int64_t dev_time;
-int64_t kqemu_ret_int_count;
-int64_t kqemu_ret_excp_count;
-int64_t kqemu_ret_intr_count;
-
static void do_info_profile(void)
{
int64_t total;
+ char buf[MAX_BUF];
+ CPUState *env = mon_get_cpu();
+
total = qemu_time;
if (total == 0)
total = 1;
@@ -1272,24 +1269,12 @@ static void do_info_profile(void)
dev_time, dev_time / (double)ticks_per_sec);
term_printf("qemu time %" PRId64 " (%0.3f)\n",
qemu_time, qemu_time / (double)ticks_per_sec);
- term_printf("kqemu time %" PRId64 " (%0.3f %0.1f%%) count=%" PRId64 "
int=%" PRId64 " excp=%" PRId64 " intr=%" PRId64 "\n",
- kqemu_time, kqemu_time / (double)ticks_per_sec,
- kqemu_time / (double)total * 100.0,
- kqemu_exec_count,
- kqemu_ret_int_count,
- kqemu_ret_excp_count,
- kqemu_ret_intr_count);
+ if (accel_profile(env, buf))
+ term_printf(buf);
qemu_time = 0;
- kqemu_time = 0;
- kqemu_exec_count = 0;
dev_time = 0;
- kqemu_ret_int_count = 0;
- kqemu_ret_excp_count = 0;
- kqemu_ret_intr_count = 0;
-#ifdef USE_KQEMU
- kqemu_record_dump();
-#endif
}
+
#else
static void do_info_profile(void)
{
--
1.5.5.1
- [Qemu-devel] [PATCH 08/32] init env made accel driver, (continued)
- [Qemu-devel] [PATCH 08/32] init env made accel driver, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 09/32] wrap cache flushing functions into accel drivers, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 13/32] move disabling code to kqemu.c instead of vl.c, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 15/32] wrap modify_page through accel calls, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 18/32] provide --accel option, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 10/32] turn info kqemu into generic info accelerator, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 16/32] remove kqemu reference from hw/pc.c, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 12/32] move kqemu externs to kqemu.h, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 11/32] separate accelerator part of info profiler,
Glauber Costa <=
- [Qemu-devel] [PATCH 21/32] get_env accel wrapper, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 17/32] build list of available accelerators, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 14/32] set_notdirty goes through accel wrapper, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 22/32] add next_cpu_index, Glauber Costa, 2008/10/23