mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 14:53:54 -06:00
trace: [tcg] Do not generate TCG code to trace dynamically-disabled events
If an event is dynamically disabled, the TCG code that calls the execution-time tracer is not generated. Removes the overheads of execution-time tracers for dynamically disabled events. As a bonus, also avoids checking the event state when the execution-time tracer is called from TCG-generated code (since otherwise TCG would simply not call it). Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Signed-off-by: Emilio G. Cota <cota@braap.org> Message-id: 149915799921.6295.13067154430923434035.stgit@frigg.lan Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
61a67f71dd
commit
864a2178d4
4 changed files with 41 additions and 14 deletions
|
@ -6,7 +6,7 @@ Machinery for generating tracing-related intermediate files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||||
__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
|
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||||
__license__ = "GPL version 2 or (at your option) any later version"
|
__license__ = "GPL version 2 or (at your option) any later version"
|
||||||
|
|
||||||
__maintainer__ = "Stefan Hajnoczi"
|
__maintainer__ = "Stefan Hajnoczi"
|
||||||
|
@ -268,6 +268,7 @@ class Event(object):
|
||||||
return self._FMT.findall(self.fmt)
|
return self._FMT.findall(self.fmt)
|
||||||
|
|
||||||
QEMU_TRACE = "trace_%(name)s"
|
QEMU_TRACE = "trace_%(name)s"
|
||||||
|
QEMU_TRACE_NOCHECK = "_nocheck__" + QEMU_TRACE
|
||||||
QEMU_TRACE_TCG = QEMU_TRACE + "_tcg"
|
QEMU_TRACE_TCG = QEMU_TRACE + "_tcg"
|
||||||
QEMU_DSTATE = "_TRACE_%(NAME)s_DSTATE"
|
QEMU_DSTATE = "_TRACE_%(NAME)s_DSTATE"
|
||||||
QEMU_EVENT = "_TRACE_%(NAME)s_EVENT"
|
QEMU_EVENT = "_TRACE_%(NAME)s_EVENT"
|
||||||
|
|
|
@ -6,7 +6,7 @@ trace/generated-tracers.h
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||||
__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
|
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||||
__license__ = "GPL version 2 or (at your option) any later version"
|
__license__ = "GPL version 2 or (at your option) any later version"
|
||||||
|
|
||||||
__maintainer__ = "Stefan Hajnoczi"
|
__maintainer__ = "Stefan Hajnoczi"
|
||||||
|
@ -49,6 +49,19 @@ def generate(events, backend, group):
|
||||||
backend.generate_begin(events, group)
|
backend.generate_begin(events, group)
|
||||||
|
|
||||||
for e in events:
|
for e in events:
|
||||||
|
# tracer without checks
|
||||||
|
out('',
|
||||||
|
'static inline void %(api)s(%(args)s)',
|
||||||
|
'{',
|
||||||
|
api=e.api(e.QEMU_TRACE_NOCHECK),
|
||||||
|
args=e.args)
|
||||||
|
|
||||||
|
if "disable" not in e.properties:
|
||||||
|
backend.generate(e, group)
|
||||||
|
|
||||||
|
out('}')
|
||||||
|
|
||||||
|
# tracer wrapper with checks (per-vCPU tracing)
|
||||||
if "vcpu" in e.properties:
|
if "vcpu" in e.properties:
|
||||||
trace_cpu = next(iter(e.args))[1]
|
trace_cpu = next(iter(e.args))[1]
|
||||||
cond = "trace_event_get_vcpu_state(%(cpu)s,"\
|
cond = "trace_event_get_vcpu_state(%(cpu)s,"\
|
||||||
|
@ -63,16 +76,15 @@ def generate(events, backend, group):
|
||||||
'static inline void %(api)s(%(args)s)',
|
'static inline void %(api)s(%(args)s)',
|
||||||
'{',
|
'{',
|
||||||
' if (%(cond)s) {',
|
' if (%(cond)s) {',
|
||||||
|
' %(api_nocheck)s(%(names)s);',
|
||||||
|
' }',
|
||||||
|
'}',
|
||||||
api=e.api(),
|
api=e.api(),
|
||||||
|
api_nocheck=e.api(e.QEMU_TRACE_NOCHECK),
|
||||||
args=e.args,
|
args=e.args,
|
||||||
|
names=", ".join(e.args.names()),
|
||||||
cond=cond)
|
cond=cond)
|
||||||
|
|
||||||
if "disable" not in e.properties:
|
|
||||||
backend.generate(e, group)
|
|
||||||
|
|
||||||
out(' }',
|
|
||||||
'}')
|
|
||||||
|
|
||||||
backend.generate_end(events, group)
|
backend.generate_end(events, group)
|
||||||
|
|
||||||
out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group.upper())
|
out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group.upper())
|
||||||
|
|
|
@ -6,7 +6,7 @@ Generate .h file for TCG code generation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||||
__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
|
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||||
__license__ = "GPL version 2 or (at your option) any later version"
|
__license__ = "GPL version 2 or (at your option) any later version"
|
||||||
|
|
||||||
__maintainer__ = "Stefan Hajnoczi"
|
__maintainer__ = "Stefan Hajnoczi"
|
||||||
|
@ -46,7 +46,7 @@ def generate(events, backend, group):
|
||||||
|
|
||||||
for e in events:
|
for e in events:
|
||||||
# just keep one of them
|
# just keep one of them
|
||||||
if "tcg-trans" not in e.properties:
|
if "tcg-exec" not in e.properties:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
out('static inline void %(name_tcg)s(%(args)s)',
|
out('static inline void %(name_tcg)s(%(args)s)',
|
||||||
|
@ -58,12 +58,25 @@ def generate(events, backend, group):
|
||||||
args_trans = e.original.event_trans.args
|
args_trans = e.original.event_trans.args
|
||||||
args_exec = tracetool.vcpu.transform_args(
|
args_exec = tracetool.vcpu.transform_args(
|
||||||
"tcg_helper_c", e.original.event_exec, "wrapper")
|
"tcg_helper_c", e.original.event_exec, "wrapper")
|
||||||
|
if "vcpu" in e.properties:
|
||||||
|
trace_cpu = e.args.names()[0]
|
||||||
|
cond = "trace_event_get_vcpu_state(%(cpu)s,"\
|
||||||
|
" TRACE_%(id)s)"\
|
||||||
|
% dict(
|
||||||
|
cpu=trace_cpu,
|
||||||
|
id=e.original.event_exec.name.upper())
|
||||||
|
else:
|
||||||
|
cond = "true"
|
||||||
|
|
||||||
out(' %(name_trans)s(%(argnames_trans)s);',
|
out(' %(name_trans)s(%(argnames_trans)s);',
|
||||||
' gen_helper_%(name_exec)s(%(argnames_exec)s);',
|
' if (%(cond)s) {',
|
||||||
|
' gen_helper_%(name_exec)s(%(argnames_exec)s);',
|
||||||
|
' }',
|
||||||
name_trans=e.original.event_trans.api(e.QEMU_TRACE),
|
name_trans=e.original.event_trans.api(e.QEMU_TRACE),
|
||||||
name_exec=e.original.event_exec.api(e.QEMU_TRACE),
|
name_exec=e.original.event_exec.api(e.QEMU_TRACE),
|
||||||
argnames_trans=", ".join(args_trans.names()),
|
argnames_trans=", ".join(args_trans.names()),
|
||||||
argnames_exec=", ".join(args_exec.names()))
|
argnames_exec=", ".join(args_exec.names()),
|
||||||
|
cond=cond)
|
||||||
|
|
||||||
out('}')
|
out('}')
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ Generate trace/generated-helpers.c.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||||
__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
|
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
|
||||||
__license__ = "GPL version 2 or (at your option) any later version"
|
__license__ = "GPL version 2 or (at your option) any later version"
|
||||||
|
|
||||||
__maintainer__ = "Stefan Hajnoczi"
|
__maintainer__ = "Stefan Hajnoczi"
|
||||||
|
@ -71,10 +71,11 @@ def generate(events, backend, group):
|
||||||
|
|
||||||
out('void %(name_tcg)s(%(args_api)s)',
|
out('void %(name_tcg)s(%(args_api)s)',
|
||||||
'{',
|
'{',
|
||||||
|
# NOTE: the check was already performed at TCG-generation time
|
||||||
' %(name)s(%(args_call)s);',
|
' %(name)s(%(args_call)s);',
|
||||||
'}',
|
'}',
|
||||||
name_tcg="helper_%s_proxy" % e.api(),
|
name_tcg="helper_%s_proxy" % e.api(),
|
||||||
name=e.api(),
|
name=e.api(e.QEMU_TRACE_NOCHECK),
|
||||||
args_api=e_args_api,
|
args_api=e_args_api,
|
||||||
args_call=", ".join(e_args_call.casted()),
|
args_call=", ".join(e_args_call.casted()),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue