From patchwork Mon Jul 11 10:53:24 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: 9223287 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 078C7604DB for ; Mon, 11 Jul 2016 10:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBBB9277D9 for ; Mon, 11 Jul 2016 10:57:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E011627C38; Mon, 11 Jul 2016 10:57:13 +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 2EEDF277D9 for ; Mon, 11 Jul 2016 10:57:13 +0000 (UTC) Received: from localhost ([::1]:60484 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMYtj-0002vQ-SM for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Jul 2016 06:57:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMYq7-0006uD-Ne for qemu-devel@nongnu.org; Mon, 11 Jul 2016 06:53:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMYq6-0001Kt-CD for qemu-devel@nongnu.org; Mon, 11 Jul 2016 06:53:27 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:44715) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMYq5-0001Ka-St for qemu-devel@nongnu.org; Mon, 11 Jul 2016 06:53:26 -0400 Received: from gw-3.ac.upc.es (gw-3.ac.upc.es [147.83.30.9]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id u6BArPdk024142; Mon, 11 Jul 2016 12:53:25 +0200 Received: from localhost (unknown [84.88.51.85]) by gw-3.ac.upc.es (Postfix) with ESMTPSA id 0666E726; Mon, 11 Jul 2016 12:53:25 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Mon, 11 Jul 2016 12:53:24 +0200 Message-Id: <146823440469.4232.11672820569027870870.stgit@fimbulvetr.bsc.es> X-Mailer: git-send-email 2.8.1 In-Reply-To: <146823439924.4232.11681843324134763312.stgit@fimbulvetr.bsc.es> References: <146823439924.4232.11681843324134763312.stgit@fimbulvetr.bsc.es> 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 u6BArPdk024142 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH v9 1/7] trace: Identify events with the 'vcpu' property 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: Paolo Bonzini , Eduardo Habkost , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP A new event attribute 'cpu_id' is added to have a separate ID space ('TRACE_VCPU_*') for all events with the 'vcpu' property. These are later used to identify which events are enabled on each vCPU. Signed-off-by: Lluís Vilanova Reviewed-by: Stefan Hajnoczi --- scripts/tracetool/format/events_c.py | 11 +++++++++-- scripts/tracetool/format/events_h.py | 12 +++++++++++- trace/control-internal.h | 12 +++++++++++- trace/control.h | 17 +++++++++++++++++ trace/event-internal.h | 4 +++- 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/scripts/tracetool/format/events_c.py b/scripts/tracetool/format/events_c.py index 1cc6a49..4012063 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" @@ -28,8 +28,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 },', + if "vcpu" in e.properties: + vcpu_id = "TRACE_VCPU_" + e.name.upper() + else: + vcpu_id = "TRACE_VCPU_EVENT_COUNT" + out(' { .id = %(id)s, .vcpu_id = %(vcpu_id)s,' + ' .name = \"%(name)s\",' + ' .sstate = %(sstate)s },', 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 4529263..a9da60b 100644 --- a/scripts/tracetool/format/events_h.py +++ b/scripts/tracetool/format/events_h.py @@ -32,13 +32,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: + out(' TRACE_VCPU_%s,' % e.name.upper()) + + out(' TRACE_VCPU_EVENT_COUNT', + '} TraceEventVCPUID;') + # 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.name.upper(), diff --git a/trace/control-internal.h b/trace/control-internal.h index dcf67f5..5e0a5ab 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. @@ -40,6 +40,16 @@ static inline TraceEventID trace_event_get_id(TraceEvent *ev) return ev->id; } +static inline TraceEventVCPUID trace_event_get_vcpu_id(TraceEvent *ev) +{ + return ev->vcpu_id; +} + +static inline bool trace_event_is_vcpu(TraceEvent *ev) +{ + return ev->vcpu_id != TRACE_VCPU_EVENT_COUNT; +} + static inline const char * trace_event_get_name(TraceEvent *ev) { assert(ev != NULL); diff --git a/trace/control.h b/trace/control.h index e2ba6d4..d37bce7 100644 --- a/trace/control.h +++ b/trace/control.h @@ -86,6 +86,23 @@ static TraceEventID trace_event_count(void); static TraceEventID trace_event_get_id(TraceEvent *ev); /** + * trace_event_get_vcpu_id: + * + * Get the per-vCPU identifier of an event. + * + * Special value #TRACE_VCPU_EVENT_COUNT means the event is not vCPU-specific + * (does not have the "vcpu" property). + */ +static TraceEventVCPUID trace_event_get_vcpu_id(TraceEvent *ev); + +/** + * trace_event_is_vcpu: + * + * Whether this is a per-vCPU event. + */ +static bool trace_event_is_vcpu(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 86f6a51..202781a 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. + * @vcpu_id: Unique per-vCPU event identifier. * @name: Event name. * @sstate: Static tracing state. * @@ -23,6 +24,7 @@ */ typedef struct TraceEvent { TraceEventID id; + TraceEventVCPUID vcpu_id; const char * name; const bool sstate; } TraceEvent;