From patchwork Fri Oct 7 10:09:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9365969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 918BF600C8 for ; Fri, 7 Oct 2016 10:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 808CF294B6 for ; Fri, 7 Oct 2016 10:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75320294BF; Fri, 7 Oct 2016 10:20:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CBBF2294B6 for ; Fri, 7 Oct 2016 10:20:00 +0000 (UTC) Received: from localhost ([::1]:33682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsSFz-0003MK-OH for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Oct 2016 06:19:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsS6j-0004J9-Ut for qemu-devel@nongnu.org; Fri, 07 Oct 2016 06:10:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsS6h-0004j1-GA for qemu-devel@nongnu.org; Fri, 07 Oct 2016 06:10:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsS6h-0004id-5M for qemu-devel@nongnu.org; Fri, 07 Oct 2016 06:10:23 -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 AB47CC05A28B; Fri, 7 Oct 2016 10:10:22 +0000 (UTC) Received: from localhost (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u97AALMF002038; Fri, 7 Oct 2016 06:10:22 -0400 From: Stefan Hajnoczi To: Date: Fri, 7 Oct 2016 11:09:33 +0100 Message-Id: <1475834979-4980-15-git-send-email-stefanha@redhat.com> In-Reply-To: <1475834979-4980-1-git-send-email-stefanha@redhat.com> References: <1475834979-4980-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 07 Oct 2016 10:10:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/20] trace: dynamically allocate event IDs at runtime X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Daniel P. Berrange" Instead of having the code generator assign event IDs and event VCPU IDs, assign them when the events are registered at runtime. This will allow code to be generated from individual trace-events without having to figure out globally unique numbering at build time. Reviewed-by: Stefan Hajnoczi Reviewed-by: LluĂ­s Vilanova Signed-off-by: Daniel P. Berrange Message-id: 1475588159-30598-16-git-send-email-berrange@redhat.com Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/format/events_c.py | 10 ++-------- scripts/tracetool/format/events_h.py | 4 ---- trace/control.c | 11 ++++++++++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/tracetool/format/events_c.py b/scripts/tracetool/format/events_c.py index 8817555..a976c22 100644 --- a/scripts/tracetool/format/events_c.py +++ b/scripts/tracetool/format/events_c.py @@ -28,25 +28,19 @@ def generate(events, backend): for e in events: out('uint16_t %s;' % e.api(e.QEMU_DSTATE)) - next_id = 0 - next_vcpu_id = 0 for e in events: - id = next_id - next_id += 1 if "vcpu" in e.properties: - vcpu_id = next_vcpu_id - next_vcpu_id += 1 + vcpu_id = 0 else: vcpu_id = "TRACE_VCPU_EVENT_NONE" out('TraceEvent %(event)s = {', - ' .id = %(id)s,', + ' .id = 0,', ' .vcpu_id = %(vcpu_id)s,', ' .name = \"%(name)s\",', ' .sstate = %(sstate)s,', ' .dstate = &%(dstate)s ', '};', event = e.api(e.QEMU_EVENT), - id = id, vcpu_id = vcpu_id, name = e.name, sstate = "TRACE_%s_ENABLED" % e.name.upper(), diff --git a/scripts/tracetool/format/events_h.py b/scripts/tracetool/format/events_h.py index ca6d730..1cb332b 100644 --- a/scripts/tracetool/format/events_h.py +++ b/scripts/tracetool/format/events_h.py @@ -32,10 +32,6 @@ def generate(events, backend): for e in events: out('extern uint16_t %s;' % e.api(e.QEMU_DSTATE)) - numvcpu = len([e for e in events if "vcpu" in e.properties]) - - out("#define TRACE_VCPU_EVENT_COUNT %d" % numvcpu) - # static state for e in events: if 'disable' in e.properties: diff --git a/trace/control.c b/trace/control.c index 5f10e2d..1a7bee6 100644 --- a/trace/control.c +++ b/trace/control.c @@ -35,6 +35,8 @@ typedef struct TraceEventGroup { static TraceEventGroup *event_groups; static size_t nevent_groups; +static uint32_t next_id; +static uint32_t next_vcpu_id; QemuOptsList qemu_trace_opts = { .name = "trace", @@ -59,6 +61,13 @@ QemuOptsList qemu_trace_opts = { void trace_event_register_group(TraceEvent **events) { + size_t i; + for (i = 0; events[i] != NULL; i++) { + events[i]->id = next_id++; + if (events[i]->vcpu_id != TRACE_VCPU_EVENT_NONE) { + events[i]->vcpu_id = next_vcpu_id++; + } + } event_groups = g_renew(TraceEventGroup, event_groups, nevent_groups + 1); event_groups[nevent_groups].events = events; nevent_groups++; @@ -293,5 +302,5 @@ char *trace_opt_parse(const char *optarg) uint32_t trace_get_vcpu_event_count(void) { - return TRACE_VCPU_EVENT_COUNT; + return next_vcpu_id; }