From: Stefan Hajnoczi <stefanha@redhat.com>
To: Hollis Blanchard <hollis_blanchard@mentor.com>
Cc: pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] trace: include CPU index in trace_memory_region_ops_*()
Date: Wed, 24 Feb 2016 14:12:45 +0000 [thread overview]
Message-ID: <20160224141245.GC23533@stefanha-x1.localdomain> (raw)
In-Reply-To: <1455744555-22101-1-git-send-email-hollis_blanchard@mentor.com>
[-- Attachment #1: Type: text/plain, Size: 1614 bytes --]
On Wed, Feb 17, 2016 at 01:29:14PM -0800, Hollis Blanchard wrote:
> 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;
QEMU coding style always uses curly braces, even when the if statement
body only has one line.
Cases like these should be caught by scripts/checkpatch.pl. I use a git
hook to run it automatically on commit:
http://blog.vmsplice.net/2011/03/how-to-automatically-run-checkpatchpl.html
A helper function would avoid the code duplication throughout this patch:
static int get_cpu_index(void) {
if (current_cpu) {
return current_cpu->cpu_index;
}
return -1;
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
prev parent reply other threads:[~2016-02-24 14:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 21:29 [Qemu-devel] [PATCH 1/2] trace: include CPU index in trace_memory_region_ops_*() Hollis Blanchard
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 ` Stefan Hajnoczi [this message]
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=20160224141245.GC23533@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=hollis_blanchard@mentor.com \
--cc=pbonzini@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).