Commit 17f7ac75 authored by Lluís Vilanova's avatar Lluís Vilanova Committed by Stefan Hajnoczi
Browse files

trace: Identify events with the 'vcpu' property



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: default avatarLluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 6913e79c
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
__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())

+11 −1
Original line number Diff line number Diff line
@@ -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(),
+11 −1
Original line number Diff line number Diff line
/*
 * Interface for configuring and controlling the state of tracing events.
 *
 * Copyright (C) 2011-2014 Lluís Vilanova <vilanova@ac.upc.edu>
 * Copyright (C) 2011-2016 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.
@@ -38,6 +38,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);
+17 −0
Original line number Diff line number Diff line
@@ -85,6 +85,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:
 *
+3 −1
Original line number Diff line number Diff line
/*
 * Interface for configuring and controlling the state of tracing events.
 *
 * Copyright (C) 2012 Lluís Vilanova <vilanova@ac.upc.edu>
 * Copyright (C) 2012-2016 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.
 * @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;