All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: "Lluís Vilanova" <vilanova@ac.upc.edu>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Our use of #include is undisciplined, and what to do about it
Date: Thu, 17 Mar 2016 16:29:01 +0000	[thread overview]
Message-ID: <20160317162900.GK5966@work-vm> (raw)
In-Reply-To: <20160317112508.GG14062@stefanha-x1.localdomain>

* Stefan Hajnoczi (stefanha@redhat.com) wrote:
> On Wed, Mar 16, 2016 at 06:27:48PM +0000, Dr. David Alan Gilbert wrote:
> > * Stefan Hajnoczi (stefanha@redhat.com) wrote:
> > > On Tue, Mar 15, 2016 at 01:56:47PM +0000, Dr. David Alan Gilbert wrote:
> > > > > This would put trace_foo() in generated-tracers-virtio-blk.h and
> > > > > trace_bar() in generated-tracers-memory.h.  Source files using tracing
> > > > > would need to include headers for relevant sections.
> > > > > 
> > > > > This way we can narrow the scope of tracing headers and prevent global
> > > > > recompilation.
> > > > > 
> > > > > The fly in the ointment is that trace/control.h defines enum
> > > > > TraceEventID, a global numbering of all trace events.  The enum is used
> > > > > in trace/contro.h APIs and also in the simpletrace file format.
> > > > > 
> > > > > If ./trace-event is modified the numbering of trace events could change.
> > > > > This would require global recompilation :(.
> > > > > 
> > > > > So in order to avoid global recompilation we need to eliminate enum
> > > > > TraceEventID.  Perhaps it's possible to use TraceEvent* instead of
> > > > > TraceEventID.  For the simpletrace backend we would continue to use a
> > > > > global ordering but that only affects generated-tracers.c and not header
> > > > > files (thankfully!).
> > > > 
> > > > I think the hardest part is going to be understanding all of the different
> > > > tracers and the things they need to know; like that thing about simpletrace
> > > > needing the single ordering;  I don't know what the other backends need
> > > > but I bet they've each got their own surprise.
> > > > 
> > > > (And yes, I'd love to split them up - I tend to use traceing quite a bit
> > > > in migration now and trying to do a bisect over a big migration patch
> > > > series takes ages mostly because of the trace.h changes)
> > > 
> > > Yes, this is the hard part.  The simpletrace.py pretty-printing script
> > > takes a trace-events file as input.  I suppose it could alphabetically
> > > sort the trace-events filenames from the command-line to produce a
> > > global ordering of trace event IDs.  Of course that doesn't work
> > > properly if the script is invoked with relative paths from a
> > > sub-directory...
> > > 
> > > Perhaps we need a new script during the QEMU build process that produces
> > > a trace-event-ids.csv file.  Then simpletrace.py could take that instead
> > > of processing ./trace-events.
> > 
> > Well that sounds easy - but is it easy to avoid using those fixed IDs
> > in any of the trace.h functions that are included everywhere (without
> > making them more expensive).
> 
> How about this:
> 
> Instead of using TraceEventID in tracing APIs, pass the TraceEvent
> pointer directly.  The tracetool.py code generator should produce
> "extern TraceEvent trace_event_foo;" definitions in headers so that the
> users have direct access to the TraceEvents.

OK, so I see TraceEvent has a TraceEventID field; so yes that works easily;
it turns out to be a little more expensive though since what was a:

   trace_events_dstate[id]

is now
   trace_events_dstate[te->id]

But hang on, what's the 'sstate' in TraceEvent; do we actually need two
state fields if we're passing a TraceEvent pointer around?

Dave

> Stefan


--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2016-03-17 16:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15  9:29 [Qemu-devel] Our use of #include is undisciplined, and what to do about it Markus Armbruster
2016-03-15  9:40 ` Paolo Bonzini
2016-03-15 12:19   ` Markus Armbruster
2016-03-15 14:51     ` Paolo Bonzini
2016-03-15 10:03 ` Peter Maydell
2016-03-15 12:28   ` Markus Armbruster
2016-03-15 12:56     ` Peter Maydell
2016-03-15 13:39 ` Stefan Hajnoczi
2016-03-15 13:51   ` Daniel P. Berrange
2016-03-15 13:56   ` Dr. David Alan Gilbert
2016-03-16 18:23     ` Stefan Hajnoczi
2016-03-16 18:27       ` Dr. David Alan Gilbert
2016-03-17 11:25         ` Stefan Hajnoczi
2016-03-17 16:29           ` Dr. David Alan Gilbert [this message]
2016-03-17 19:21             ` Paolo Bonzini
2016-03-17 19:43               ` Dr. David Alan Gilbert
2016-03-17 19:58               ` Paolo Bonzini
2016-03-17 20:14               ` Richard Henderson
2016-03-17 20:27                 ` Peter Maydell
2016-03-17 20:29                   ` Richard Henderson
2016-03-17 21:02                     ` Paolo Bonzini
2016-03-17 20:59                 ` Paolo Bonzini
2016-03-17 19:40 ` Richard Henderson
2019-05-27 13:12 ` Markus Armbruster

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=20160317162900.GK5966@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vilanova@ac.upc.edu \
    /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.