From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KszDk-0007B2-Qa for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KszDh-00078p-0w for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:18 -0400 Received: from [199.232.76.173] (port=51704 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KszDg-00078c-Dv for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:16 -0400 Received: from mx2.redhat.com ([66.187.237.31]:54633) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KszDe-0006EK-Q2 for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:16 -0400 From: Glauber Costa Date: Thu, 23 Oct 2008 12:18:55 -0200 Message-Id: <1224771556-11146-12-git-send-email-glommer@redhat.com> In-Reply-To: <1224771556-11146-1-git-send-email-glommer@redhat.com> References: <1224771556-11146-1-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 11/32] separate accelerator part of info profiler Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com, jes@sgi.com, avi@qumranet.com, Glauber Costa , dmitry.baryshkov@siemens.com From: Glauber Costa Yet another accel field: profile. It allows the accelerators to do part of the profiling their own way. Signed-off-by: Glauber Costa --- 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