From patchwork Fri Jan 15 16:38:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 8043191 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 78745BEEE5 for ; Fri, 15 Jan 2016 16:38:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 960EA20453 for ; Fri, 15 Jan 2016 16:38:29 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 5877B203F4 for ; Fri, 15 Jan 2016 16:38:28 +0000 (UTC) Received: from localhost ([::1]:47960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK7ON-0007vj-Na for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 Jan 2016 11:38:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK7O8-0007qW-Ur for qemu-devel@nongnu.org; Fri, 15 Jan 2016 11:38:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK7O6-0004Qj-7X for qemu-devel@nongnu.org; Fri, 15 Jan 2016 11:38:12 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:58097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK7O5-0004Qe-Qa for qemu-devel@nongnu.org; Fri, 15 Jan 2016 11:38:10 -0500 Received: from gw-2.ac.upc.es (gw-2.ac.upc.es [147.83.30.8]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id u0FEwYmp029628; Fri, 15 Jan 2016 15:58:34 +0100 Received: from localhost (unknown [84.88.51.85]) by gw-2.ac.upc.es (Postfix) with ESMTPSA id D5EE5766; Fri, 15 Jan 2016 17:38:08 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Fri, 15 Jan 2016 17:38:08 +0100 Message-Id: <145287588827.11400.1103495123595311902.stgit@localhost> X-Mailer: git-send-email 2.6.4 In-Reply-To: <145287587081.11400.4178335509020334684.stgit@localhost> References: <145287587081.11400.4178335509020334684.stgit@localhost> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id u0FEwYmp029628 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Cc: Stefan Hajnoczi , Eduardo Habkost , Stefan Hajnoczi , Markus Armbruster Subject: [Qemu-devel] [PATCH v4 3/9] trace: [tcg] Identify events with the 'vcpu' property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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..84c34dd 100644 --- a/qapi/trace.json +++ b/qapi/trace.json @@ -1,6 +1,6 @@ # -*- mode: python -*- # -# Copyright (C) 2011-2014 Lluís Vilanova +# Copyright (C) 2011-2016 Lluís Vilanova # # 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.6). # # 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..fbfb9b1 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 " -__copyright__ = "Copyright 2012-2014, Lluís Vilanova " +__copyright__ = "Copyright 2012-2016, Lluís Vilanova " __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..9c5aee4 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 " -__copyright__ = "Copyright 2012-2014, Lluís Vilanova " +__copyright__ = "Copyright 2012-2016, Lluís Vilanova " __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..ab42396 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 + * Copyright (C) 2011-2016 Lluís Vilanova * * 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 766fdad..860beed 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..258bcde 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 + * Copyright (C) 2012-2016 Lluís Vilanova * * 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..be99496 100644 --- a/trace/qmp.c +++ b/trace/qmp.c @@ -1,7 +1,7 @@ /* * QMP commands for tracing events. * - * Copyright (C) 2014 Lluís Vilanova + * Copyright (C) 2014-2016 Lluís Vilanova * * 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;