From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkShU-00060m-4W for qemu-devel@nongnu.org; Thu, 15 Sep 2016 05:11:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkShQ-000519-Co for qemu-devel@nongnu.org; Thu, 15 Sep 2016 05:11:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkShQ-000515-3V for qemu-devel@nongnu.org; Thu, 15 Sep 2016 05:11:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB6358B120 for ; Thu, 15 Sep 2016 09:11:15 +0000 (UTC) Date: Thu, 15 Sep 2016 10:11:12 +0100 From: "Daniel P. Berrange" Message-ID: <20160915091112.GE26068@redhat.com> Reply-To: "Daniel P. Berrange" References: <1473872922-23449-1-git-send-email-berrange@redhat.com> <1473872922-23449-5-git-send-email-berrange@redhat.com> <87fup2w0na.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87fup2w0na.fsf@fimbulvetr.bsc.es> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 4/6] trace: remove global 'uint16 dstate[]' array List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Stefan Hajnoczi , Paolo Bonzini On Thu, Sep 15, 2016 at 12:56:57AM +0200, Llu=C3=ADs Vilanova wrote: > Daniel P Berrange writes: >=20 > > Instead of having a global dstate array, declare a single > > 'uint16 TRACE_${EVENT_NAME}_DSTATE' variable for each > > trace event. Record a pointer to this variable in the > > TraceEvent struct too. >=20 > > By turning trace_event_get_state_dynamic_by_id into a > > macro, this still hits the fast path, and cache affinity > > is ensured by declaring all the uint16 vars adjacent to > > each other. >=20 > > Signed-off-by: Daniel P. Berrange > > --- > > scripts/tracetool/format/events_c.py | 6 +++++- > > scripts/tracetool/format/events_h.py | 3 +++ > > stubs/trace-control.c | 9 ++++----- > > trace/control-internal.h | 14 ++++---------- > > trace/control-target.c | 20 ++++++++------------ > > trace/control.c | 11 ++--------- > > trace/event-internal.h | 6 ++++++ > > 7 files changed, 32 insertions(+), 37 deletions(-) >=20 > > diff --git a/scripts/tracetool/format/events_c.py b/scripts/tracetool= /format/events_c.py > > index 4012063..a2f457f 100644 > > --- a/scripts/tracetool/format/events_c.py > > +++ b/scripts/tracetool/format/events_c.py > > @@ -25,6 +25,9 @@ def generate(events, backend): > > '#include "trace/control.h"', > > '') > =20 > > + for e in events: > > + out('uint16_t TRACE_%s_DSTATE;' % e.name.upper()) > > + > > out('TraceEvent trace_events[TRACE_EVENT_COUNT] =3D {') > =20 > > for e in events: >=20 > I would emit an "obviously non-public" variable name, like > ___TRACE_%s_dstate. The "TRACE_%s" is only necesary for consistency wit= h the > "public name" and macro trickery on the fast path. >=20 > To make naming consistency easier to track, you can use Event.api(), wh= ich needs > only a small extension ("scripts/tracetool/__init__.py"): >=20 > QEMU_TRACE =3D "trace_%(name)s" > QEMU_TRACE_TCG =3D QEMU_TRACE + "_tcg" >=20 > QEMU_DSTATE =3D "___TRACE_%(NAME)s_dstate" >=20 > def api(self, fmt=3DNone): > if fmt is None: > fmt =3D Event.QEMU_TRACE > return fmt % {"name": self.name, "NAME": self.name.upper()} >=20 > Then change all the places where you generate the dstate symbol name to > something like: >=20 > out('uint16_t ' + e.api(e.QEMU_DSTATE)) + ';') Ah interesting, I hadn't noticed the Event.api() method. > > @@ -54,18 +53,13 @@ static inline bool trace_event_get_state_static(T= raceEvent *ev) > > return ev->sstate; > > } > =20 > > -static inline bool trace_event_get_state_dynamic_by_id(TraceEventID = id) > > -{ > > - /* it's on fast path, avoid consistency checks (asserts) */ > > - return unlikely(trace_events_enabled_count) && trace_events_dsta= te[id]; > > -} > > +/* it's on fast path, avoid consistency checks (asserts) */ > > +#define trace_event_get_state_dynamic_by_id(id) \ > > + (unlikely(trace_events_enabled_count) && id ## _DSTATE) > =20 > > static inline bool trace_event_get_state_dynamic(TraceEvent *ev) > > { > > - TraceEventID id; > > - assert(trace_event_get_state_static(ev)); > > - id =3D trace_event_get_id(ev); > > - return trace_event_get_state_dynamic_by_id(id); > > + return unlikely(trace_events_enabled_count) && *ev->dstate; >=20 > This one is not on the fast path, so there's no need for the first part= of the > AND (shouldn't hurt performance to keep it either). Yep, I just figured it'd be nice to keep the two methods having the same logic even if this second one isn't so performance critical. 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 :|