qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, avi@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] trace io operations
Date: Fri, 24 Oct 2008 13:55:15 -0200	[thread overview]
Message-ID: <1224863716-23793-2-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1224863716-23793-1-git-send-email-glommer@redhat.com>

Add fields in cpu state to trace reads and writes for both
pio and mmio. Together with it, keep track of the timestamp
in which the last io happened, whatever kind it was. This last
part is particularly useful for us to replace kqemu break-loop
tests by a generic framework without the need for an accelerator
hook.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 cpu-defs.h         |    6 ++++++
 softmmu_template.h |    8 ++------
 target-i386/cpu.h  |    1 -
 vl.c               |   50 ++++++++++++++++++++++++++------------------------
 4 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/cpu-defs.h b/cpu-defs.h
index 5dcac74..4b401ef 100644
--- a/cpu-defs.h
+++ b/cpu-defs.h
@@ -153,6 +153,12 @@ typedef struct icount_decr_u16 {
                                 accessed */                             \
     target_ulong mem_io_vaddr; /* target virtual addr at which the      \
                                      memory was accessed */             \
+    uint32_t mmio_read_count;                                                \
+    uint32_t pio_read_count;                                                 \
+    uint32_t mmio_write_count;                                                \
+    uint32_t pio_write_count;                                                 \
+    uint64_t last_io_time;                                              \
+                                                                        \
     uint32_t halted; /* Nonzero if the CPU is in suspend state */       \
     uint32_t interrupt_request;                                         \
     /* The meaning of the MMU modes is defined in the target code. */   \
diff --git a/softmmu_template.h b/softmmu_template.h
index 98dd378..cdfcb38 100644
--- a/softmmu_template.h
+++ b/softmmu_template.h
@@ -75,9 +75,7 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(target_phys_addr_t physaddr,
     res |= (uint64_t)io_mem_read[index][2](io_mem_opaque[index], physaddr + 4) << 32;
 #endif
 #endif /* SHIFT > 2 */
-#ifdef USE_KQEMU
-    env->last_io_time = cpu_get_time_fast();
-#endif
+    trace_mmio(env, 0);
     return res;
 }
 
@@ -220,9 +218,7 @@ static inline void glue(io_write, SUFFIX)(target_phys_addr_t physaddr,
     io_mem_write[index][2](io_mem_opaque[index], physaddr + 4, val >> 32);
 #endif
 #endif /* SHIFT > 2 */
-#ifdef USE_KQEMU
-    env->last_io_time = cpu_get_time_fast();
-#endif
+    trace_mmio(env, 1);
 }
 
 void REGPARM glue(glue(__st, SUFFIX), MMUSUFFIX)(target_ulong addr,
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 3c11e0f..8a2d797 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -608,7 +608,6 @@ typedef struct CPUX86State {
 
 #ifdef USE_KQEMU
     int kqemu_enabled;
-    int last_io_time;
 #endif
     /* in order to simplify APIC support, we leave this pointer to the
        user */
diff --git a/vl.c b/vl.c
index 16d3e96..dfec9ff 100644
--- a/vl.c
+++ b/vl.c
@@ -263,6 +263,26 @@ PicState2 *isa_pic;
 static IOPortReadFunc default_ioport_readb, default_ioport_readw, default_ioport_readl;
 static IOPortWriteFunc default_ioport_writeb, default_ioport_writew, default_ioport_writel;
 
+void trace_pio(CPUState *env, int write)
+{
+    if (write)
+        env->pio_write_count++;
+    else
+        env->pio_read_count++;
+
+    env->last_io_time = cpu_get_real_ticks();
+}
+
+void trace_mmio(CPUState *env, int write)
+{
+    if (write)
+        env->mmio_write_count++;
+    else
+        env->mmio_read_count++;
+
+    env->last_io_time = cpu_get_real_ticks();
+}
+
 static void qemu_io_interrupt(CPUState *env)
 {
     if (env) {
@@ -422,10 +442,7 @@ void cpu_outb(CPUState *env, int addr, int val)
         fprintf(logfile, "outb: %04x %02x\n", addr, val);
 #endif
     ioport_write(0, addr, val);
-#ifdef USE_KQEMU
-    if (env)
-        env->last_io_time = cpu_get_time_fast();
-#endif
+    trace_pio(env, 1);
 }
 
 void cpu_outw(CPUState *env, int addr, int val)
@@ -435,10 +452,7 @@ void cpu_outw(CPUState *env, int addr, int val)
         fprintf(logfile, "outw: %04x %04x\n", addr, val);
 #endif
     ioport_write(1, addr, val);
-#ifdef USE_KQEMU
-    if (env)
-        env->last_io_time = cpu_get_time_fast();
-#endif
+    trace_pio(env, 1);
 }
 
 void cpu_outl(CPUState *env, int addr, int val)
@@ -448,10 +462,7 @@ void cpu_outl(CPUState *env, int addr, int val)
         fprintf(logfile, "outl: %04x %08x\n", addr, val);
 #endif
     ioport_write(2, addr, val);
-#ifdef USE_KQEMU
-    if (env)
-        env->last_io_time = cpu_get_time_fast();
-#endif
+    trace_pio(env, 1);
 }
 
 int cpu_inb(CPUState *env, int addr)
@@ -462,10 +473,7 @@ int cpu_inb(CPUState *env, int addr)
     if (loglevel & CPU_LOG_IOPORT)
         fprintf(logfile, "inb : %04x %02x\n", addr, val);
 #endif
-#ifdef USE_KQEMU
-    if (env)
-        env->last_io_time = cpu_get_time_fast();
-#endif
+    trace_pio(env, 0);
     return val;
 }
 
@@ -477,10 +485,7 @@ int cpu_inw(CPUState *env, int addr)
     if (loglevel & CPU_LOG_IOPORT)
         fprintf(logfile, "inw : %04x %04x\n", addr, val);
 #endif
-#ifdef USE_KQEMU
-    if (env)
-        env->last_io_time = cpu_get_time_fast();
-#endif
+    trace_pio(env, 0);
     return val;
 }
 
@@ -492,10 +497,7 @@ int cpu_inl(CPUState *env, int addr)
     if (loglevel & CPU_LOG_IOPORT)
         fprintf(logfile, "inl : %04x %08x\n", addr, val);
 #endif
-#ifdef USE_KQEMU
-    if (env)
-        env->last_io_time = cpu_get_time_fast();
-#endif
+    trace_pio(env, 0);
     return val;
 }
 
-- 
1.5.5.1

  reply	other threads:[~2008-10-24 13:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-24 15:55 [Qemu-devel] [PATCH 0/2] Add generic infrastructure to trace I/O Glauber Costa
2008-10-24 15:55 ` Glauber Costa [this message]
2008-10-26 13:25   ` [Qemu-devel] Re: [PATCH 1/2] trace io operations Avi Kivity
2008-10-24 15:55 ` [Qemu-devel] [PATCH 2/2] new monitor command: info iostats Glauber Costa
2008-10-26 13:24   ` [Qemu-devel] " Avi Kivity

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=1224863716-23793-2-git-send-email-glommer@redhat.com \
    --to=glommer@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --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).