Message ID | 147395465853.2399.8315639698512911211.stgit@fimbulvetr.bsc.es |
---|---|
State | New |
Headers | show |
On Thu, Sep 15, 2016 at 05:50:58PM +0200, Lluís Vilanova wrote: In the subject line: s/dinamically-disabled/dynamically/ > for e in events: > + # tracer without checks > + out('', > + 'static inline void __nocheck__%(api)s(%(args)s)', In QEMU we avoid using double underscore since that part of the namespace is reserved according to the C standard: "7.1.3 Reserved identifiers [...] All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use."
Stefan Hajnoczi writes: > On Thu, Sep 15, 2016 at 05:50:58PM +0200, Lluís Vilanova wrote: > In the subject line: > s/dinamically-disabled/dynamically/ >> for e in events: >> + # tracer without checks >> + out('', >> + 'static inline void __nocheck__%(api)s(%(args)s)', > In QEMU we avoid using double underscore since that part of the > namespace is reserved according to the C standard: > "7.1.3 Reserved identifiers > [...] > All identifiers that begin with an underscore and either an uppercase > letter or another underscore are always reserved for any use." Oops! It's one of those rules I always forget about (being used to reading it on other codebases). I'll use a single underscore then. I was also recommending Daniel to prefix some symbols with a double underscore in his modular trace refactoring to make it more explicit they should not be used directly. In his case, they are uppercase names, so I'm not sure what's the appropriate way to go there. Daniel: change it to something like this? QEMU_EVENT = "_event_{NAME}" Then "ev.api(ev.QEMU_EVENT)" would generate: TraceEvent _event_QEMU_MEMALIGN = {...}; Thanks, Lluis
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index 3763e9a..99fcbc0 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -29,6 +29,19 @@ def generate(events, backend): backend.generate_begin(events) for e in events: + # tracer without checks + out('', + 'static inline void __nocheck__%(api)s(%(args)s)', + '{', + api=e.api(), + args=e.args) + + if "disable" not in e.properties: + backend.generate(e) + + out('}') + + # tracer wrapper with checks (per-vCPU tracing) if "vcpu" in e.properties: trace_cpu = next(iter(e.args))[1] cond = "trace_event_get_vcpu_state(%(cpu)s,"\ @@ -44,16 +57,14 @@ def generate(events, backend): 'static inline void %(api)s(%(args)s)', '{', ' if (%(cond)s) {', + ' __nocheck__%(api)s(%(names)s);', + ' }', + '}', api=e.api(), args=e.args, + names=", ".join(e.args.names()), cond=cond) - if "disable" not in e.properties: - backend.generate(e) - - out(' }', - '}') - backend.generate_end(events) out('#endif /* TRACE__GENERATED_TRACERS_H */') diff --git a/scripts/tracetool/format/tcg_h.py b/scripts/tracetool/format/tcg_h.py index e2331f2..fb2503a 100644 --- a/scripts/tracetool/format/tcg_h.py +++ b/scripts/tracetool/format/tcg_h.py @@ -41,7 +41,7 @@ def generate(events, backend): for e in events: # just keep one of them - if "tcg-trans" not in e.properties: + if "tcg-exec" not in e.properties: continue out('static inline void %(name_tcg)s(%(args)s)', @@ -53,12 +53,26 @@ def generate(events, backend): args_trans = e.original.event_trans.args args_exec = tracetool.vcpu.transform_args( "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,"\ + " TRACE_VCPU_%(id)s)"\ + % dict( + cpu=trace_cpu, + id=e.original.event_exec.name.upper()) + else: + cond = "true" + 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_exec=e.original.event_exec.api(e.QEMU_TRACE), argnames_trans=", ".join(args_trans.names()), - argnames_exec=", ".join(args_exec.names())) + argnames_exec=", ".join(args_exec.names()), + cond=cond) out('}') diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool/format/tcg_helper_c.py index e3485b7..f9adb3c 100644 --- a/scripts/tracetool/format/tcg_helper_c.py +++ b/scripts/tracetool/format/tcg_helper_c.py @@ -66,7 +66,8 @@ def generate(events, backend): out('void %(name_tcg)s(%(args_api)s)', '{', - ' %(name)s(%(args_call)s);', + # NOTE: the check was already performed at TCG-generation time + ' __nocheck__%(name)s(%(args_call)s);', '}', name_tcg="helper_%s_proxy" % e.api(), name=e.api(),
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> --- scripts/tracetool/format/h.py | 23 +++++++++++++++++------ scripts/tracetool/format/tcg_h.py | 20 +++++++++++++++++--- scripts/tracetool/format/tcg_helper_c.py | 3 ++- 3 files changed, 36 insertions(+), 10 deletions(-)