All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hollis Blanchard <hollis_blanchard@mentor.com>
To: stefanha@redhat.com
Cc: pbonzini@redhat.com,
	Hollis Blanchard <hollis_blanchard@mentor.com>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] trace: include CPU index in trace_memory_region_ops_*()
Date: Wed, 17 Feb 2016 13:29:14 -0800	[thread overview]
Message-ID: <1455744555-22101-1-git-send-email-hollis_blanchard@mentor.com> (raw)

Knowing which CPU performed an action is essential for understanding SMP guest
behavior.

However, cpu_physical_memory_rw() may be executed by a machine init function,
before any VCPUs are running, when there is no CPU running ('current_cpu' is
NULL). In this case, store -1 in the trace record as the CPU index. Trace
analysis tools may need to be aware of this special case.

Signed-off-by: Hollis Blanchard <hollis_blanchard@mentor.com>
---
 memory.c     | 48 ++++++++++++++++++++++++++++++++++++------------
 trace-events |  8 ++++----
 2 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/memory.c b/memory.c
index 2d87c21..6ae7bae 100644
--- a/memory.c
+++ b/memory.c
@@ -395,13 +395,17 @@ static MemTxResult memory_region_oldmmio_read_accessor(MemoryRegion *mr,
                                                        MemTxAttrs attrs)
 {
     uint64_t tmp;
+    int cpu_index = -1;
+
+    if (current_cpu)
+        cpu_index = current_cpu->cpu_index;
 
     tmp = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr);
     if (mr->subpage) {
-        trace_memory_region_subpage_read(mr, addr, tmp, size);
+        trace_memory_region_subpage_read(cpu_index, mr, addr, tmp, size);
     } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
         hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
-        trace_memory_region_ops_read(mr, abs_addr, tmp, size);
+        trace_memory_region_ops_read(cpu_index, mr, abs_addr, tmp, size);
     }
     *value |= (tmp & mask) << shift;
     return MEMTX_OK;
@@ -416,13 +420,17 @@ static MemTxResult  memory_region_read_accessor(MemoryRegion *mr,
                                                 MemTxAttrs attrs)
 {
     uint64_t tmp;
+    int cpu_index = -1;
+
+    if (current_cpu)
+        cpu_index = current_cpu->cpu_index;
 
     tmp = mr->ops->read(mr->opaque, addr, size);
     if (mr->subpage) {
-        trace_memory_region_subpage_read(mr, addr, tmp, size);
+        trace_memory_region_subpage_read(cpu_index, mr, addr, tmp, size);
     } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
         hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
-        trace_memory_region_ops_read(mr, abs_addr, tmp, size);
+        trace_memory_region_ops_read(cpu_index, mr, abs_addr, tmp, size);
     }
     *value |= (tmp & mask) << shift;
     return MEMTX_OK;
@@ -438,13 +446,17 @@ static MemTxResult memory_region_read_with_attrs_accessor(MemoryRegion *mr,
 {
     uint64_t tmp = 0;
     MemTxResult r;
+    int cpu_index = -1;
+
+    if (current_cpu)
+        cpu_index = current_cpu->cpu_index;
 
     r = mr->ops->read_with_attrs(mr->opaque, addr, &tmp, size, attrs);
     if (mr->subpage) {
-        trace_memory_region_subpage_read(mr, addr, tmp, size);
+        trace_memory_region_subpage_read(cpu_index, mr, addr, tmp, size);
     } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) {
         hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
-        trace_memory_region_ops_read(mr, abs_addr, tmp, size);
+        trace_memory_region_ops_read(cpu_index, mr, abs_addr, tmp, size);
     }
     *value |= (tmp & mask) << shift;
     return r;
@@ -459,13 +471,17 @@ static MemTxResult memory_region_oldmmio_write_accessor(MemoryRegion *mr,
                                                         MemTxAttrs attrs)
 {
     uint64_t tmp;
+    int cpu_index = -1;
+
+    if (current_cpu)
+        cpu_index = current_cpu->cpu_index;
 
     tmp = (*value >> shift) & mask;
     if (mr->subpage) {
-        trace_memory_region_subpage_write(mr, addr, tmp, size);
+        trace_memory_region_subpage_write(cpu_index, mr, addr, tmp, size);
     } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
         hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
-        trace_memory_region_ops_write(mr, abs_addr, tmp, size);
+        trace_memory_region_ops_write(cpu_index, mr, abs_addr, tmp, size);
     }
     mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp);
     return MEMTX_OK;
@@ -480,13 +496,17 @@ static MemTxResult memory_region_write_accessor(MemoryRegion *mr,
                                                 MemTxAttrs attrs)
 {
     uint64_t tmp;
+    int cpu_index = -1;
+
+    if (current_cpu)
+        cpu_index = current_cpu->cpu_index;
 
     tmp = (*value >> shift) & mask;
     if (mr->subpage) {
-        trace_memory_region_subpage_write(mr, addr, tmp, size);
+        trace_memory_region_subpage_write(cpu_index, mr, addr, tmp, size);
     } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
         hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
-        trace_memory_region_ops_write(mr, abs_addr, tmp, size);
+        trace_memory_region_ops_write(cpu_index, mr, abs_addr, tmp, size);
     }
     mr->ops->write(mr->opaque, addr, tmp, size);
     return MEMTX_OK;
@@ -501,13 +521,17 @@ static MemTxResult memory_region_write_with_attrs_accessor(MemoryRegion *mr,
                                                            MemTxAttrs attrs)
 {
     uint64_t tmp;
+    int cpu_index = -1;
+
+    if (current_cpu)
+        cpu_index = current_cpu->cpu_index;
 
     tmp = (*value >> shift) & mask;
     if (mr->subpage) {
-        trace_memory_region_subpage_write(mr, addr, tmp, size);
+        trace_memory_region_subpage_write(cpu_index, mr, addr, tmp, size);
     } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) {
         hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr);
-        trace_memory_region_ops_write(mr, abs_addr, tmp, size);
+        trace_memory_region_ops_write(cpu_index, mr, abs_addr, tmp, size);
     }
     return mr->ops->write_with_attrs(mr->opaque, addr, tmp, size, attrs);
 }
diff --git a/trace-events b/trace-events
index a80dc1c..756ce86 100644
--- a/trace-events
+++ b/trace-events
@@ -1626,10 +1626,10 @@ disable exec_tb_exit(void *next_tb, unsigned int flags) "tb:%p flags=%x"
 translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p"
 
 # memory.c
-memory_region_ops_read(void *mr, uint64_t addr, uint64_t value, unsigned size) "mr %p addr %#"PRIx64" value %#"PRIx64" size %u"
-memory_region_ops_write(void *mr, uint64_t addr, uint64_t value, unsigned size) "mr %p addr %#"PRIx64" value %#"PRIx64" size %u"
-memory_region_subpage_read(void *mr, uint64_t offset, uint64_t value, unsigned size) "mr %p offset %#"PRIx64" value %#"PRIx64" size %u"
-memory_region_subpage_write(void *mr, uint64_t offset, uint64_t value, unsigned size) "mr %p offset %#"PRIx64" value %#"PRIx64" size %u"
+memory_region_ops_read(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size) "cpu %d mr %p addr %#"PRIx64" value %#"PRIx64" size %u"
+memory_region_ops_write(int cpu_index, void *mr, uint64_t addr, uint64_t value, unsigned size) "cpu %d mr %p addr %#"PRIx64" value %#"PRIx64" size %u"
+memory_region_subpage_read(int cpu_index, void *mr, uint64_t offset, uint64_t value, unsigned size) "cpu %d mr %p offset %#"PRIx64" value %#"PRIx64" size %u"
+memory_region_subpage_write(int cpu_index, void *mr, uint64_t offset, uint64_t value, unsigned size) "cpu %d mr %p offset %#"PRIx64" value %#"PRIx64" size %u"
 
 # qom/object.c
 object_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
-- 
1.9.1

             reply	other threads:[~2016-02-17 21:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 21:29 Hollis Blanchard [this message]
2016-02-17 21:29 ` [Qemu-devel] [PATCH 2/2] trace: separate MMIO tracepoints from TB-access tracepoints Hollis Blanchard
2016-02-18 18:37   ` Hollis Blanchard
2016-02-24 14:13   ` Stefan Hajnoczi
2016-03-23 16:47   ` Hollis Blanchard
2016-03-23 16:53     ` Paolo Bonzini
2016-03-23 17:16       ` Hollis Blanchard
2016-03-24 19:30       ` [Qemu-devel] io_mem_notdirty and live migration Hollis Blanchard
2016-03-24 22:01         ` Paolo Bonzini
2016-02-24 14:12 ` [Qemu-devel] [PATCH 1/2] trace: include CPU index in trace_memory_region_ops_*() Stefan Hajnoczi

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=1455744555-22101-1-git-send-email-hollis_blanchard@mentor.com \
    --to=hollis_blanchard@mentor.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.