From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] trace: Remove 'trace_events_dstate_init'
Date: Thu, 11 Aug 2016 12:21:13 +0100 [thread overview]
Message-ID: <20160811112113.GT27458@redhat.com> (raw)
In-Reply-To: <878tw3lg9d.fsf@fimbulvetr.bsc.es>
On Thu, Aug 11, 2016 at 01:03:10PM +0200, Lluís Vilanova wrote:
> Daniel P Berrange writes:
>
> > On Thu, Aug 11, 2016 at 12:23:05PM +0200, Lluís Vilanova wrote:
> >> Removes the event state array used for early initialization. Since only
> >> events with the "vcpu" property need a late initialization fixup,
> >> threats their initialization specially.
> >>
> >> Assumes that the user won't touch the state of "vcpu" events between
> >> early and late initialization (e.g., through QMP).
> >>
> >> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> >> ---
> >> stubs/trace-control.c | 5 +++++
> >> trace/control-target.c | 9 +++++++++
> >> trace/control.c | 23 ++++++++++-------------
> >> trace/control.h | 3 +++
> >> trace/event-internal.h | 1 +
> >> 5 files changed, 28 insertions(+), 13 deletions(-)
> >>
> >> diff --git a/stubs/trace-control.c b/stubs/trace-control.c
> >> index fe59836..3740c38 100644
> >> --- a/stubs/trace-control.c
> >> +++ b/stubs/trace-control.c
> >> @@ -11,6 +11,11 @@
> >> #include "trace/control.h"
> >>
> >>
> >> +void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
> >> +{
> >> + trace_event_set_state_dynamic(ev, state);
> >> +}
> >> +
> >> void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
> >> {
> >> TraceEventID id;
> >> diff --git a/trace/control-target.c b/trace/control-target.c
> >> index 74c029a..4ee3733 100644
> >> --- a/trace/control-target.c
> >> +++ b/trace/control-target.c
> >> @@ -13,6 +13,15 @@
> >> #include "translate-all.h"
> >>
> >>
> >> +void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
> >> +{
> >> + TraceEventID id = trace_event_get_id(ev);
> >> + assert(trace_event_get_state_static(ev));
> >> + /* Ignore "vcpu" property, since no vCPUs have been created yet */
> >> + trace_events_enabled_count += state - trace_events_dstate[id];
>
> > This is doing arithmetic on a boolean value
>
> >> + trace_events_dstate[id] = state;
>
> > This is assigning a boolean value to an int16_t
>
> >> void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
> >> {
> >> CPUState *vcpu;
>
>
> Mmmm, all these were c&p from existing code, just moved to a new function. I do
> remember explicitly checking for the boolean values with if/else to do the
> appropriate operations, but someone reviewing the code suggested using what
> you're seeing to make it shorter and more readable.
I think this logic is considerably less understandable with this magic
trick, because it is not at all obvious that trace_events_dstate[id]
will always be 0 if state is True.
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 :|
next prev parent reply other threads:[~2016-08-11 11:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 10:23 [Qemu-devel] [PATCH v2] trace: Remove 'trace_events_dstate_init' Lluís Vilanova
2016-08-11 10:28 ` Daniel P. Berrange
2016-08-11 11:03 ` Lluís Vilanova
2016-08-11 11:21 ` Daniel P. Berrange [this message]
2016-08-11 12:24 ` Lluís Vilanova
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=20160811112113.GT27458@redhat.com \
--to=berrange@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 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).