From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3Md-0003Yj-6Z for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:44:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn3Ma-0001Wl-0j for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:44:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3MZ-0001Vm-Mo for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:44:27 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 196092AD5 for ; Thu, 22 Sep 2016 12:44:27 +0000 (UTC) Date: Thu, 22 Sep 2016 13:44:24 +0100 From: "Daniel P. Berrange" Message-ID: <20160922124423.GL352@redhat.com> Reply-To: "Daniel P. Berrange" References: <1474533652-31170-1-git-send-email-berrange@redhat.com> <1474533652-31170-9-git-send-email-berrange@redhat.com> <87ponwnmcl.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87ponwnmcl.fsf@fimbulvetr.bsc.es> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 08/17] trace: remove the TraceEventID and TraceEventVCPUID enums List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Stefan Hajnoczi On Thu, Sep 22, 2016 at 02:35:38PM +0200, Llu=C3=ADs Vilanova wrote: > Daniel P Berrange writes: >=20 > > The TraceEventID and TraceEventVCPUID enums constants are > > no longer actually used for anything critical. >=20 > > The TRACE_EVENT_COUNT limit is used to determine the size > > of the TraceEvents array, and can be removed if we just > > NULL terminate the array instead. >=20 > > The TRACE_VCPU_EVENT_COUNT limit is used as a magic value > > for marking non-vCPU events, and also for declaring the > > size of the trace dstate mask in the CPUState struct. > > The former usage can be replaced by a dedicated constant > > TRACE_EVENT_VCPU_NONE, defined as (uint32_t)-1. For the > > latter usage, we can simply define a constant for the > > number of VCPUs, avoiding the need for the full enum. >=20 > > The only other usages of the enum values can be replaced > > by accesing the id/vcpu_id fields via the named TraceEvent > > structs. >=20 > > Signed-off-by: Daniel P. Berrange >=20 > Disregarding comment below: >=20 > Reviewed-by: Llu=C3=ADs Vilanova >=20 > > --- > > scripts/tracetool/backend/simple.py | 4 ++-- > > scripts/tracetool/format/events_c.py | 16 +++++++++++----- > > scripts/tracetool/format/events_h.py | 18 +++--------------- > > scripts/tracetool/format/h.py | 3 +-- > > trace/control-internal.h | 19 ++++++++++--------- > > trace/control-target.c | 2 +- > > trace/control.c | 2 +- > > trace/control.h | 31 ++++++++------------------= ----- > > trace/event-internal.h | 6 ++++++ > > trace/simple.c | 8 ++++---- > > trace/simple.h | 2 +- > > 11 files changed, 48 insertions(+), 63 deletions(-) > > diff --git a/scripts/tracetool/format/events_h.py b/scripts/tracetool= /format/events_h.py > > index 80a66c5..5da1d4c 100644 > > --- a/scripts/tracetool/format/events_h.py > > +++ b/scripts/tracetool/format/events_h.py > > @@ -29,27 +29,15 @@ def generate(events, backend): > > out('extern TraceEvent %(event)s;', > > event =3D e.api(e.QEMU_EVENT)) > =20 > > - # event identifiers > > - out('typedef enum {') > > - > > - for e in events: > > - out(' TRACE_%s,' % e.name.upper()) > > - > > - out(' TRACE_EVENT_COUNT', > > - '} TraceEventID;') > > - > > for e in events: > > out('extern uint16_t %s;' % e.api(e.QEMU_DSTATE)) > =20 > > - # per-vCPU event identifiers > > - out('typedef enum {') > > - > > + numvcpu =3D 0 > > for e in events: > > if "vcpu" in e.properties: > > - out(' TRACE_VCPU_%s,' % e.name.upper()) > > + numvcpu +=3D 1 > =20 > > - out(' TRACE_VCPU_EVENT_COUNT', > > - '} TraceEventVCPUID;') >=20 > Here's a more pythonic way to write it: >=20 > numvcpu =3D len([e for e in events if "vcpu" in e.properties]) FWIW I was tending to avoid this kind of idiom, since most of QEMU maintainers are C developers, for whom this looks rather alien. 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 :|