qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Glauber Costa <gcosta@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm-devel@lists.sourceforge.net
Subject: [Qemu-devel] [PATCH 07/13] [PATCH] separate accelerator part of info profiler
Date: Thu, 15 May 2008 11:09:27 -0300	[thread overview]
Message-ID: <12108606012733-git-send-email-gcosta@redhat.com> (raw)
In-Reply-To: <12108605981240-git-send-email-gcosta@redhat.com>

---
 exec-all.h |    8 ++++++++
 kqemu.c    |   35 +++++++++++++++++++++++++++++++++++
 monitor.c  |   27 ++++++---------------------
 3 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/exec-all.h b/exec-all.h
index f1bd7ae..689973d 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -584,6 +584,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;
@@ -624,6 +625,13 @@ static inline int accel_info(CPUState *env, char *buf)
     return 0;
 }
 
+static inline int accel_profile(CPUState *env, char *buf)
+{
+    if (current_accel && current_accel->profile)
+       return current_accel->profile(env, buf);
+    return 0;
+}
+
 #ifdef USE_KQEMU
 #define KQEMU_MODIFY_PAGE_MASK (0xff & ~(VGA_DIRTY_FLAG | CODE_DIRTY_FLAG))
 
diff --git a/kqemu.c b/kqemu.c
index 451d1d4..6d46dfb 100644
--- a/kqemu.c
+++ b/kqemu.c
@@ -51,6 +51,10 @@
 #include <fcntl.h>
 #include "kqemu.h"
 
+#ifdef CONFIG_PROFILER
+#include "qemu-timer.h" /* for ticks_per_sec */
+#endif
+
 /* compatibility stuff */
 #ifndef KQEMU_RET_SYSCALL
 #define KQEMU_RET_SYSCALL   0x0300 /* syscall insn */
@@ -307,12 +311,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 cb9faef..2ee5b0c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1187,17 +1187,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;
@@ -1205,24 +1202,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

  reply	other threads:[~2008-05-15 14:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 14:09 [Qemu-devel] [PATCH 0/13] New shot at QEMUAccel Glauber Costa
2008-05-15 14:09 ` [Qemu-devel] [PATCH 01/13] [PATCH] make cpu_exec_init symmetric Glauber Costa
2008-05-15 14:09   ` [Qemu-devel] [PATCH 02/13] [PATCH] split kqemu_init into two Glauber Costa
2008-05-15 14:09     ` [Qemu-devel] [PATCH 03/13] [PATCH] introduce QEMUAccel and fill it with interrupt specific driver Glauber Costa
2008-05-15 14:09       ` [Qemu-devel] [PATCH 04/13] [PATCH] init env made accel driver Glauber Costa
2008-05-15 14:09         ` [Qemu-devel] [PATCH 05/13] [PATCH] wrap cache flushing functions into accel drivers Glauber Costa
2008-05-15 14:09           ` [Qemu-devel] [PATCH 06/13] [PATCH] turn info kqemu into generic info accelerator Glauber Costa
2008-05-15 14:09             ` Glauber Costa [this message]
2008-05-15 14:09               ` [Qemu-devel] [PATCH 08/13] [PATCH] move kqemu externs to kqemu.h Glauber Costa
2008-05-15 14:09                 ` [Qemu-devel] [PATCH 09/13] [PATCH] move disabling code to kqemu.c instead of vl.c Glauber Costa
2008-05-15 14:09                   ` [Qemu-devel] [PATCH 10/13] [PATCH] set_notdirty goes through accel wrapper Glauber Costa
2008-05-15 14:09                     ` [Qemu-devel] [PATCH 11/13] [PATCH] wrap modify_page through accel calls Glauber Costa
2008-05-15 14:09                       ` [Qemu-devel] [PATCH 12/13] [PATCH] remove kqemu reference from hw/pc.c Glauber Costa
2008-05-15 14:09                         ` [Qemu-devel] [PATCH 13/13] [PATCH] build list of available accelerators Glauber Costa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12108606012733-git-send-email-gcosta@redhat.com \
    --to=gcosta@redhat.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).