All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [PATCH v2 03/10] trace: [tcg] Identify events with the 'vcpu' property
Date: Tue, 24 Nov 2015 18:09:04 +0100	[thread overview]
Message-ID: <144838494386.3052.2385226717619371988.stgit@localhost> (raw)
In-Reply-To: <144838492534.3052.2948919558518613064.stgit@localhost>

A separate ID space ('TRACE_CPU_*') is used in attribute 'cpu_id' that
only contains events with the 'vcpu' property.

These are later used to select the appropriate physical TB cache based
on what events are active.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 qapi/trace.json                      |    5 +++--
 scripts/tracetool/format/events_c.py |   11 +++++++++--
 scripts/tracetool/format/events_h.py |   14 ++++++++++++--
 trace/control-internal.h             |    8 +++++++-
 trace/control.h                      |    7 +++++++
 trace/event-internal.h               |    4 +++-
 trace/qmp.c                          |    3 ++-
 7 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/qapi/trace.json b/qapi/trace.json
index 01b0a52..71cb96f 100644
--- a/qapi/trace.json
+++ b/qapi/trace.json
@@ -1,6 +1,6 @@
 # -*- mode: python -*-
 #
-# Copyright (C) 2011-2014 Lluís Vilanova <vilanova@ac.upc.edu>
+# Copyright (C) 2011-2015 Lluís Vilanova <vilanova@ac.upc.edu>
 #
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
@@ -29,11 +29,12 @@
 #
 # @name: Event name.
 # @state: Tracing state.
+# @vcpu: Whether this is a per-vCPU event (since 2.5).
 #
 # Since 2.2
 ##
 { 'struct': 'TraceEventInfo',
-  'data': {'name': 'str', 'state': 'TraceEventState'} }
+  'data': {'name': 'str', 'state': 'TraceEventState', 'vcpu': 'bool'} }
 
 ##
 # @trace-event-get-state:
diff --git a/scripts/tracetool/format/events_c.py b/scripts/tracetool/format/events_c.py
index 2d97fa3..e0ff73a 100644
--- a/scripts/tracetool/format/events_c.py
+++ b/scripts/tracetool/format/events_c.py
@@ -6,7 +6,7 @@ trace/generated-events.c
 """
 
 __author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2015, Lluís Vilanova <vilanova@ac.upc.edu>"
 __license__    = "GPL version 2 or (at your option) any later version"
 
 __maintainer__ = "Stefan Hajnoczi"
@@ -27,8 +27,15 @@ def generate(events, backend):
     out('TraceEvent trace_events[TRACE_EVENT_COUNT] = {')
 
     for e in events:
-        out('    { .id = %(id)s, .name = \"%(name)s\", .sstate = %(sstate)s, .dstate = 0 },',
+        if "vcpu" in e.properties and "tcg-exec" in e.properties:
+            vcpu_id = "TRACE_CPU_" + e.name.upper()
+        else:
+            vcpu_id = "TRACE_CPU_EVENT_COUNT"
+        out('    { .id = %(id)s, .cpu_id = %(vcpu_id)s,'
+            ' .name = \"%(name)s\",'
+            ' .sstate = %(sstate)s, .dstate = 0 },',
             id = "TRACE_" + e.name.upper(),
+            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 9f114a3..f260090 100644
--- a/scripts/tracetool/format/events_h.py
+++ b/scripts/tracetool/format/events_h.py
@@ -6,7 +6,7 @@ trace/generated-events.h
 """
 
 __author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2015, Lluís Vilanova <vilanova@ac.upc.edu>"
 __license__    = "GPL version 2 or (at your option) any later version"
 
 __maintainer__ = "Stefan Hajnoczi"
@@ -34,13 +34,23 @@ def generate(events, backend):
     out('    TRACE_EVENT_COUNT',
         '} TraceEventID;')
 
+    # per-vCPU event identifiers
+    out('typedef enum {')
+
+    for e in events:
+        if "vcpu" in e.properties and "tcg-exec" in e.properties:
+            out('    TRACE_CPU_%s,' % e.name.upper())
+
+    out('    TRACE_CPU_EVENT_COUNT',
+        '} TraceEventCPUID;')
+
     # static state
     for e in events:
         if 'disable' in e.properties:
             enabled = 0
         else:
             enabled = 1
-        if "tcg-trans" in e.properties:
+        if "tcg-exec" in e.properties:
             # a single define for the two "sub-events"
             out('#define TRACE_%(name)s_ENABLED %(enabled)d',
                 name=e.original.original.name.upper(),
diff --git a/trace/control-internal.h b/trace/control-internal.h
index 5a8df28..70e55df 100644
--- a/trace/control-internal.h
+++ b/trace/control-internal.h
@@ -1,7 +1,7 @@
 /*
  * Interface for configuring and controlling the state of tracing events.
  *
- * Copyright (C) 2011-2014 Lluís Vilanova <vilanova@ac.upc.edu>
+ * Copyright (C) 2011-2015 Lluís Vilanova <vilanova@ac.upc.edu>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
@@ -39,6 +39,12 @@ static inline TraceEventID trace_event_get_id(TraceEvent *ev)
     return ev->id;
 }
 
+static inline TraceEventCPUID trace_event_get_cpu_id(TraceEvent *ev)
+{
+    assert(ev != NULL);
+    return ev->cpu_id;
+}
+
 static inline const char * trace_event_get_name(TraceEvent *ev)
 {
     assert(ev != NULL);
diff --git a/trace/control.h b/trace/control.h
index 275a086..a0bfd3e 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -87,6 +87,13 @@ static TraceEventID trace_event_count(void);
 static TraceEventID trace_event_get_id(TraceEvent *ev);
 
 /**
+ * trace_event_get_cpu_id:
+ *
+ * Get the per-vCPU identifier of an event.
+ */
+static TraceEventCPUID trace_event_get_cpu_id(TraceEvent *ev);
+
+/**
  * trace_event_get_name:
  *
  * Get the name of an event.
diff --git a/trace/event-internal.h b/trace/event-internal.h
index b2310d9..ae18b48 100644
--- a/trace/event-internal.h
+++ b/trace/event-internal.h
@@ -1,7 +1,7 @@
 /*
  * Interface for configuring and controlling the state of tracing events.
  *
- * Copyright (C) 2012 Lluís Vilanova <vilanova@ac.upc.edu>
+ * Copyright (C) 2012-2015 Lluís Vilanova <vilanova@ac.upc.edu>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
@@ -16,6 +16,7 @@
 /**
  * TraceEvent:
  * @id: Unique event identifier.
+ * @cpu_id: Unique per-vCPU event identifier.
  * @name: Event name.
  * @sstate: Static tracing state.
  * @dstate: Dynamic tracing state.
@@ -24,6 +25,7 @@
  */
 typedef struct TraceEvent {
     TraceEventID id;
+    TraceEventCPUID cpu_id;
     const char * name;
     const bool sstate;
     bool dstate;
diff --git a/trace/qmp.c b/trace/qmp.c
index 0b19489..b5a5020 100644
--- a/trace/qmp.c
+++ b/trace/qmp.c
@@ -1,7 +1,7 @@
 /*
  * QMP commands for tracing events.
  *
- * Copyright (C) 2014 Lluís Vilanova <vilanova@ac.upc.edu>
+ * Copyright (C) 2014-2015 Lluís Vilanova <vilanova@ac.upc.edu>
  *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
@@ -22,6 +22,7 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name, Error **errp)
     while ((ev = trace_event_pattern(name, ev)) != NULL) {
         TraceEventInfoList *elem = g_new(TraceEventInfoList, 1);
         elem->value = g_new(TraceEventInfo, 1);
+        elem->value->vcpu = trace_event_get_cpu_id(ev) != TRACE_CPU_EVENT_COUNT;
         elem->value->name = g_strdup(trace_event_get_name(ev));
         if (!trace_event_get_state_static(ev)) {
             elem->value->state = TRACE_EVENT_STATE_UNAVAILABLE;

  parent reply	other threads:[~2015-11-24 17:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-24 17:08 [Qemu-devel] [PATCH v2 00/10] trace: Per-vCPU tracing states Lluís Vilanova
2015-11-24 17:08 ` [Qemu-devel] [PATCH v2 01/10] trace: Add support for vCPU pointers in trace events Lluís Vilanova
2015-11-24 17:08 ` [Qemu-devel] [PATCH v2 02/10] trace: Add 'vcpu' event property Lluís Vilanova
2015-11-24 17:09 ` Lluís Vilanova [this message]
2015-11-24 17:54   ` [Qemu-devel] [PATCH v2 03/10] trace: [tcg] Identify events with the 'vcpu' property Eric Blake
2015-11-24 17:09 ` [Qemu-devel] [PATCH v2 04/10] exec: [tcg] Refactor flush of per-CPU virtual TB cache Lluís Vilanova
2015-11-24 17:09 ` [Qemu-devel] [PATCH v2 05/10] exec: [ŧcg] Use multiple physical TB caches Lluís Vilanova
2016-01-07  7:49   ` Stefan Hajnoczi
2016-01-07 17:56     ` Lluís Vilanova
2015-11-24 17:09 ` [Qemu-devel] [PATCH v2 06/10] exec: [tcg] Track which vCPU is performing translation and execution Lluís Vilanova
2015-11-24 17:09 ` [Qemu-devel] [PATCH v2 07/10] [trivial] Track when QEMU has finished initialization Lluís Vilanova
2015-11-24 17:09 ` [Qemu-devel] [PATCH v2 08/10] disas: Remove unused macro '_' Lluís Vilanova
2015-11-24 17:09 ` [Qemu-devel] [PATCH v2 09/10] trace: [tcg] Add per-vCPU tracing states for events with the 'vcpu' property Lluís Vilanova
2015-11-24 17:57   ` Eric Blake
2015-11-24 18:31     ` Lluís Vilanova
2016-01-07  8:03   ` Stefan Hajnoczi
2016-01-07 18:44     ` Lluís Vilanova
2016-01-14 11:22       ` Stefan Hajnoczi
2015-11-24 17:09 ` [Qemu-devel] [PATCH v2 10/10] trace: [tcg] Generate TCG code to trace guest events on a per-vCPU basis Lluís Vilanova
2016-01-07  8:05 ` [Qemu-devel] [PATCH v2 00/10] trace: Per-vCPU tracing states Stefan Hajnoczi

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=144838494386.3052.2385226717619371988.stgit@localhost \
    --to=vilanova@ac.upc.edu \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.