All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 5/6] trace: remove use of event ID enums from APIs
Date: Thu, 15 Sep 2016 10:26:15 +0100	[thread overview]
Message-ID: <20160915092615.GF26068@redhat.com> (raw)
In-Reply-To: <87vaxyukq9.fsf@fimbulvetr.bsc.es>

On Thu, Sep 15, 2016 at 01:26:06AM +0200, Lluís Vilanova wrote:
> Daniel P Berrange writes:
> 
> > Since there will shortly be multiple event groups allowed,
> > we can no longer use the TraceEventID and TraceEventVCPUID
> > enums in the trace control APIs. There will in fact be
> > multiple distinct enums, and the enum values will only be
> > required to be unique per group.
> 
> This patch serves no purpose without the event group patches.
> 
> Also, AFAIR TraceEventVCPUID still needs to be a flat space (they're all used as
> bitmask indexes), so keeping the enum won't lose any re-compilation benefit.
>
> And without wanting to sound like a broken record, you can make the
> "TRACE_${EVENTNAME}" IDs be global Event* variables (statically initialized in
> "trace/generated-events.c"). That still allows using their names in the macros,
> avoids having a (two-level) tree of events, and eliminates the need for the
> Event::id member (and the trace_event_get_id() function).

Regardless of whether its used in the public API, we still need to
be able to assign a unique 32bit event ID to every event, because
simpletrace currently needs to output that in its trace files.

That said, i have been wondering if people are very tied to the
current simple trace output format ?  My ideal solution would be
for us to dynamically assign id values to trace events when QEMU
starts up.

If we did this, hen in the simpletrace output file, we would have
to insert a new record type which records an (event name, ID)
value mapping, the first time any individual event type is
emitted.

Thus when simpletrace.py comes to load the trace data, instead
of using the event ID to lookup the event directly, it would use
the event ID to get the name from the trace data, and then lookup
the event based on name.



> [...]
> > diff --git a/trace/simple.c b/trace/simple.c
> > index 2f09daf..6e8013c 100644
> > --- a/trace/simple.c
> > +++ b/trace/simple.c
> > @@ -18,7 +18,7 @@
> >  #include "trace/simple.h"
>  
> >  /** Trace file header event ID */
> > -#define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with TraceEventIDs */
> > +#define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with event IDs */
>  
> >  /** Trace file magic number */
> >  #define HEADER_MAGIC 0xf2b177cb0aa429b4ULL
> > @@ -58,7 +58,7 @@ static char *trace_file_name;
>  
> >  /* * Trace buffer entry */
> >  typedef struct {
> > -    uint64_t event; /*   TraceEventID */
> > +    uint64_t event; /*  event ID */
> >      uint64_t timestamp_ns;
> >      uint32_t length;   /*    in bytes */
> >      uint32_t pid;
> > @@ -202,7 +202,7 @@ void trace_record_write_str(TraceBufferRecord *rec, const char *s, uint32_t slen
> rec-> rec_off = write_to_buffer(rec->rec_off, (void*)s, slen);
> >  }
>  
> > -int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasize)
> > +int trace_record_start(TraceBufferRecord *rec, uint32_t event, size_t datasize)
> >  {
> >      unsigned int idx, rec_off, old_idx, new_idx;
> >      uint32_t rec_len = sizeof(TraceRecord) + datasize;
> > diff --git a/trace/simple.h b/trace/simple.h
> > index 1e7de45..17ce472 100644
> > --- a/trace/simple.h
> > +++ b/trace/simple.h
> > @@ -33,7 +33,7 @@ typedef struct {
> >   *
> >   * @arglen  number of bytes required for arguments
> >   */
> > -int trace_record_start(TraceBufferRecord *rec, TraceEventID id, size_t arglen);
> > +int trace_record_start(TraceBufferRecord *rec, uint32_t id, size_t arglen);
>  
> >  /**
> >   * Append a 64-bit argument to a trace record
> 
> Not incorrect, but it's weird that the simple backend emits 64-bit identifiers
> while QEMU uses 32-bit ones.

The trace_record_start method *is* given a 32-bit id value not a 64-bit value.
That comment you're quoting here is nothing todo with the ID values, it is
about writing 64-bit parameter values.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2016-09-15  9:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14 17:08 [Qemu-devel] [PATCH v2 0/6] Prep changes for modular trace-events build Daniel P. Berrange
2016-09-14 17:08 ` [Qemu-devel] [PATCH v2 1/6] trace: add trace event iterator APIs Daniel P. Berrange
2016-09-14 21:53   ` Lluís Vilanova
2016-09-15  9:07     ` Daniel P. Berrange
2016-09-14 17:08 ` [Qemu-devel] [PATCH v2 2/6] trace: convert code to use event iterators Daniel P. Berrange
2016-09-14 22:16   ` Lluís Vilanova
2016-09-15  9:09     ` Daniel P. Berrange
2016-09-14 17:08 ` [Qemu-devel] [PATCH v2 3/6] trace: remove some now unused functions Daniel P. Berrange
2016-09-14 22:21   ` Lluís Vilanova
2016-09-14 17:08 ` [Qemu-devel] [PATCH v2 4/6] trace: remove global 'uint16 dstate[]' array Daniel P. Berrange
2016-09-14 22:56   ` Lluís Vilanova
2016-09-15  9:11     ` Daniel P. Berrange
2016-09-14 17:08 ` [Qemu-devel] [PATCH v2 5/6] trace: remove use of event ID enums from APIs Daniel P. Berrange
2016-09-14 23:26   ` Lluís Vilanova
2016-09-15  9:26     ` Daniel P. Berrange [this message]
2016-09-15 12:20       ` Lluís Vilanova
2016-09-15 12:29         ` Daniel P. Berrange
2016-09-14 17:08 ` [Qemu-devel] [PATCH v2 6/6] trace: use -1 instead of TRACE_VCPU_EVENT_COUNT as magic value Daniel P. Berrange
2016-09-14 23:12   ` Lluís Vilanova
2016-09-14 19:41 ` [Qemu-devel] [PATCH v2 0/6] Prep changes for modular trace-events build no-reply

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=20160915092615.GF26068@redhat.com \
    --to=berrange@redhat.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.