From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KqCWG-0001Q6-Uk for qemu-devel@nongnu.org; Wed, 15 Oct 2008 15:58:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KqCWE-0001OK-38 for qemu-devel@nongnu.org; Wed, 15 Oct 2008 15:58:55 -0400 Received: from [199.232.76.173] (port=36786 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KqCWC-0001Nv-I6 for qemu-devel@nongnu.org; Wed, 15 Oct 2008 15:58:52 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49437) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KqCWB-0001JU-99 for qemu-devel@nongnu.org; Wed, 15 Oct 2008 15:58:52 -0400 From: Glauber Costa Date: Wed, 15 Oct 2008 19:55:03 -0200 Message-Id: <1224107718-19128-7-git-send-email-glommer@redhat.com> In-Reply-To: <1224107718-19128-1-git-send-email-glommer@redhat.com> References: <1224107718-19128-1-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 06/21] 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 466fe67..af9091c 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 45a3fca..754d49f 100644 --- a/accel.h +++ b/accel.h @@ -7,6 +7,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; @@ -41,4 +42,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 ac12e17..bcbe3cc 100644 --- a/kqemu.c +++ b/kqemu.c @@ -52,6 +52,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 @@ -293,12 +297,43 @@ 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; + +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, }; diff --git a/monitor.c b/monitor.c index c638a38..2f92bcc 100644 --- a/monitor.c +++ b/monitor.c @@ -1255,17 +1255,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; @@ -1273,24 +1270,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