From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXl9d-0006st-Lw for qemu-devel@nongnu.org; Thu, 11 Aug 2016 04:15:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXl9a-0002VI-Dg for qemu-devel@nongnu.org; Thu, 11 Aug 2016 04:15:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXl9a-0002VE-5n for qemu-devel@nongnu.org; Thu, 11 Aug 2016 04:15:50 -0400 Date: Thu, 11 Aug 2016 09:15:46 +0100 From: "Daniel P. Berrange" Message-ID: <20160811081546.GB27458@redhat.com> Reply-To: "Daniel P. Berrange" References: <147084825411.21266.1977426703494992563.stgit@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <147084825411.21266.1977426703494992563.stgit@fimbulvetr.bsc.es> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] trace: Remove 'trace_events_dstate_init' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?B?TGx1w61z?= Vilanova Cc: qemu-devel@nongnu.org, Stefan Hajnoczi On Wed, Aug 10, 2016 at 06:57:34PM +0200, Llu=C3=ADs 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. >=20 > Assumes that the user won't touch the state of "vcpu" events between > early and late initialization (e.g., through QMP). >=20 > Signed-off-by: Llu=C3=ADs Vilanova > --- > stubs/trace-control.c | 5 +++++ > trace/control-target.c | 9 +++++++++ > trace/control.c | 21 ++++++++------------- > trace/control.h | 3 +++ > trace/event-internal.h | 1 + > 5 files changed, 26 insertions(+), 13 deletions(-) >=20 > 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" > =20 > =20 > +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" > =20 > =20 > +void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state) > +{ > + TraceEventID id =3D 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 +=3D state - trace_events_dstate[id]; > + trace_events_dstate[id] =3D state; > +} > + > void trace_event_set_state_dynamic(TraceEvent *ev, bool state) > { > CPUState *vcpu; > diff --git a/trace/control.c b/trace/control.c > index d173c09..027adc7 100644 > --- a/trace/control.c > +++ b/trace/control.c > @@ -31,8 +31,6 @@ int trace_events_enabled_count; > * - true : Integral counting the number of vCPUs that have this event= enabled. > */ > uint16_t trace_events_dstate[TRACE_EVENT_COUNT]; > -/* Marks events for late vCPU state init */ > -static bool trace_events_dstate_init[TRACE_EVENT_COUNT]; > =20 > QemuOptsList qemu_trace_opts =3D { > .name =3D "trace", > @@ -142,10 +140,7 @@ static void do_trace_enable_events(const char *lin= e_buf) > TraceEvent *ev =3D NULL; > while ((ev =3D trace_event_pattern(line_ptr, ev)) !=3D NULL) { > if (trace_event_get_state_static(ev)) { > - /* start tracing */ > - trace_event_set_state_dynamic(ev, enable); > - /* mark for late vCPU init */ > - trace_events_dstate_init[ev->id] =3D true; > + trace_event_set_state_dynamic_init(ev, enable); > } > } > } else { > @@ -157,10 +152,7 @@ static void do_trace_enable_events(const char *lin= e_buf) > error_report("WARNING: trace event '%s' is not traceable", > line_ptr); > } else { > - /* start tracing */ > - trace_event_set_state_dynamic(ev, enable); > - /* mark for late vCPU init */ > - trace_events_dstate_init[ev->id] =3D true; > + trace_event_set_state_dynamic_init(ev, enable); > } > } > } > @@ -275,9 +267,12 @@ void trace_init_vcpu_events(void) > { > TraceEvent *ev =3D NULL; > while ((ev =3D trace_event_pattern("*", ev)) !=3D NULL) { > - if (trace_event_is_vcpu(ev) && > - trace_event_get_state_static(ev) && > - trace_events_dstate_init[ev->id]) { > + if (trace_event_is_vcpu(ev) && trace_event_get_state_dynamic(e= v)) { > + TraceEventID id =3D trace_event_get_id(ev); > + /* disable early-init state ... */ > + trace_events_dstate[id] =3D false; This variable is uint16_t, so assigning false to it is bogus. > + trace_events_enabled_count--; > + /* ... and properly re-enable */ > trace_event_set_state_dynamic(ev, true); > } > } Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|