From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
"Daniel P. Berrange" <berrange@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL v2 14/20] trace: dynamically allocate event IDs at runtime
Date: Wed, 12 Oct 2016 10:47:32 +0200 [thread overview]
Message-ID: <1476262058-13936-15-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1476262058-13936-1-git-send-email-stefanha@redhat.com>
From: "Daniel P. Berrange" <berrange@redhat.com>
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 <stefanha@redhat.com>
Reviewed-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1475588159-30598-16-git-send-email-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
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;
}
--
2.7.4
next prev parent reply other threads:[~2016-10-12 8:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-12 8:47 [Qemu-devel] [PULL v2 00/20] Tracing patches Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 01/20] trace: move colo trace events to net/ sub-directory Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 02/20] trace: add trace event iterator APIs Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 03/20] trace: convert code to use event iterators Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 04/20] trace: remove some now unused functions Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 05/20] trace: remove global 'uint16 dstate[]' array Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 06/20] trace: remove duplicate control.h includes in generated-tracers.h Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 07/20] trace: break circular dependency in event-internal.h Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 08/20] trace: give each trace event a named TraceEvent struct Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 09/20] trace: remove the TraceEventID and TraceEventVCPUID enums Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 10/20] trace: emit name <-> ID mapping in simpletrace header Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 11/20] trace: don't abort qemu if ftrace can't be initialized Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 12/20] trace: provide mechanism for registering trace events Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 13/20] trace: dynamically allocate trace_dstate in CPUState Stefan Hajnoczi
2016-10-12 8:47 ` Stefan Hajnoczi [this message]
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 15/20] trace: get rid of generated-events.h/generated-events.c Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 16/20] trace: rename _read_events to read_events Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 17/20] trace: push reading of events up a level to tracetool main Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 18/20] trace: pass trace-events to tracetool as a positional param Stefan Hajnoczi
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 19/20] trace: introduce a formal group name for trace events Stefan Hajnoczi
2016-10-13 13:58 ` Paolo Bonzini
2016-10-17 10:28 ` Greg Kurz
2016-10-12 8:47 ` [Qemu-devel] [PULL v2 20/20] trace: Add missing execution mode of guest events Stefan Hajnoczi
2016-10-12 11:13 ` [Qemu-devel] [PULL v2 00/20] Tracing patches Peter Maydell
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=1476262058-13936-15-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=berrange@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).