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_blanch...@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; }
signature.asc
Description: PGP signature