trace: Conditionally trace events based on their per-vCPU state

Events with the 'vcpu' property are conditionally emitted according to
their per-vCPU state. Other events are emitted normally based on their
global tracing state.

Note that the per-vCPU condition check applies to all tracing backends.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Lluís Vilanova 2016-07-11 12:53:46 +02:00 committed by Stefan Hajnoczi
parent 4815185902
commit 40b9cd25f7
6 changed files with 57 additions and 29 deletions

View file

@ -36,7 +36,7 @@ def generate_h_begin(events):
def generate_h(event):
out(' _simple_%(api)s(%(args)s);',
out(' _simple_%(api)s(%(args)s);',
api=event.api(),
args=", ".join(event.args.names()))
@ -68,16 +68,23 @@ def generate_c(event):
if len(event.args) == 0:
sizestr = '0'
event_id = 'TRACE_' + event.name.upper()
if "vcpu" in event.properties:
# already checked on the generic format code
cond = "true"
else:
cond = "trace_event_get_state(%s)" % event_id
out('',
' if (!trace_event_get_state(%(event_id)s)) {',
' if (!%(cond)s) {',
' return;',
' }',
'',
' if (trace_record_start(&rec, %(event_id)s, %(size_str)s)) {',
' return; /* Trace Buffer Full, Event Dropped ! */',
' }',
event_id='TRACE_' + event.name.upper(),
cond=cond,
event_id=event_id,
size_str=sizestr)
if len(event.args) > 0: