Skip to content

Commit

Permalink
trace: fix simple trace "disable" keyword
Browse files Browse the repository at this point in the history
The trace-events "disable" keyword turns an event into a nop at
compile-time.  This is important for high-frequency events that can
impact performance.

The "disable" keyword is currently broken in the simple trace backend.
This patch fixes the problem as follows:

Trace events are identified by their TraceEventID number.  When events
are disabled there are two options for assigning TraceEventID numbers:
1. Skip disabled events and don't assign them a number.
2. Assign numbers for all events regardless of the disabled keyword.

The simple trace backend and its binary file format uses approach qemu#1.

The tracetool infrastructure has been using approach qemu#2 for a while.

The result is that the numbers used in simple trace files do not
correspond with TraceEventIDs.  In trace/simple.c we assumed that they
are identical and therefore emitted bogus numbers.

This patch fixes the bug by using TraceEventID for trace_event_id()
while sticking to approach qemu#1 for simple trace file numbers.  This
preserves simple trace file format compatibility.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Jan 27, 2014
1 parent 05735a2 commit 736ec16
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/tracetool/backend/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def c(events):


out('',
' TraceEvent *eventp = trace_event_id(%(event_id)s);',
' TraceEvent *eventp = trace_event_id(%(event_enum)s);',
' bool _state = trace_event_get_state_dynamic(eventp);',
' if (!_state) {',
' return;',
Expand All @@ -65,6 +65,7 @@ def c(events):
' if (trace_record_start(&rec, %(event_id)s, %(size_str)s)) {',
' return; /* Trace Buffer Full, Event Dropped ! */',
' }',
event_enum = 'TRACE_' + event.name.upper(),
event_id = num,
size_str = sizestr,
)
Expand Down

0 comments on commit 736ec16

Please sign in to comment.