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 1/6] trace: add trace event iterator APIs
Date: Thu, 15 Sep 2016 10:07:03 +0100	[thread overview]
Message-ID: <20160915090703.GC26068@redhat.com> (raw)
In-Reply-To: <878tuuywqh.fsf@fimbulvetr.bsc.es>

On Wed, Sep 14, 2016 at 11:53:10PM +0200, Lluís Vilanova wrote:
> Daniel P Berrange writes:
> 
> > Currently methods which want to iterate over trace events,
> > do so using the trace_event_count() and trace_event_id()
> > methods. This leaks the concept of a single ID enum to
> > the callers. There is an alternative trace_event_pattern()
> > method which can be used in an iteration context, but its
> > design is stateless, so is not easy to expand it in the
> > future.
> 
> > This defines a formal iterator API will provide an future
> > proof way of iterating over events.
> 
> > The iterator is also able to apply a pattern match filter
> > to events, further removing the need for the pattern
> 
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > ---
> >  trace/control.c | 20 ++++++++++++++++++++
> >  trace/control.h | 27 +++++++++++++++++++++++++++
> >  2 files changed, 47 insertions(+)
> 
> > diff --git a/trace/control.c b/trace/control.c
> > index 05d85ac..b871727 100644
> > --- a/trace/control.c
> > +++ b/trace/control.c
> > @@ -125,6 +125,26 @@ TraceEvent *trace_event_pattern(const char *pat, TraceEvent *ev)
> >      return NULL;
> >  }
>  
> > +void trace_event_iter_init(TraceEventIter *iter, const char *pattern)
> > +{
> > +    iter->event = 0;
> > +    iter->pattern = pattern;
> > +}
> > +
> > +TraceEvent *trace_event_iter_next(TraceEventIter *iter)
> > +{
> > +    while (iter->event < TRACE_EVENT_COUNT) {
> > +        if (!iter->pattern ||
> > +            pattern_glob(iter->pattern,
> > +                         trace_event_get_name(&(trace_events[iter->event])))) {
> > +            return &(trace_events[iter->event]);
> 
> That's a picky one (feel free to ignore), but can you refactor
> "&(trace_events[iter->event])" out into a variable? The long pattern_glob() call
> is a bit hard to parse.
> 
> 
> > +        }
> > +        iter->event++;
> > +    }
> > +
> > +    return NULL;
> > +}
> > +
> >  void trace_list_events(void)
> >  {
> >      int i;
> > diff --git a/trace/control.h b/trace/control.h
> > index 27a16fc..c71b405 100644
> > --- a/trace/control.h
> > +++ b/trace/control.h
> > @@ -13,6 +13,10 @@
> >  #include "qemu-common.h"
> >  #include "trace/generated-events.h"
>  
> > +typedef struct TraceEventIter {
> > +    size_t event;
> 
> Shouldn't this be TraceEventID for consistence with "trace/control.h"? But if
> you're going to drop TraceEventID in a later series feel free to ignore me.

For array indexes size_t is always the optimal type, since that matches
the maximum logical size that an array can be. It just happens that
array indexes match TraceEventID but since that'll be killed in the API
later, I figured it best to stick to the normal size_t .


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:07 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 [this message]
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
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=20160915090703.GC26068@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.