From 4815185902971c41fcdd700fa1fc3e1d9299900f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Vilanova?= Date: Mon, 11 Jul 2016 12:53:41 +0200 Subject: trace: Add per-vCPU tracing states for events with the 'vcpu' property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each vCPU gets a 'trace_dstate' bitmap to control the per-vCPU dynamic tracing state of events with the 'vcpu' property. Signed-off-by: LluĂ­s Vilanova Signed-off-by: Stefan Hajnoczi --- trace/control.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'trace/control.h') diff --git a/trace/control.h b/trace/control.h index d7d6500438..0413b28769 100644 --- a/trace/control.h +++ b/trace/control.h @@ -123,6 +123,23 @@ static const char * trace_event_get_name(TraceEvent *ev); #define trace_event_get_state(id) \ ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id)) +/** + * trace_event_get_vcpu_state: + * @vcpu: Target vCPU. + * @id: Event identifier (TraceEventID). + * @vcpu_id: Per-vCPU event identifier (TraceEventVCPUID). + * + * Get the tracing state of an event (both static and dynamic) for the given + * vCPU. + * + * If the event has the disabled property, the check will have no performance + * impact. + * + * As a down side, you must always use an immediate #TraceEventID value. + */ +#define trace_event_get_vcpu_state(vcpu, id, vcpu_id) \ + ((id ##_ENABLED) && trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id)) + /** * trace_event_get_state_static: * @id: Event identifier. @@ -138,9 +155,18 @@ static bool trace_event_get_state_static(TraceEvent *ev); * trace_event_get_state_dynamic: * * Get the dynamic tracing state of an event. + * + * If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs. */ static bool trace_event_get_state_dynamic(TraceEvent *ev); +/** + * trace_event_get_vcpu_state_dynamic: + * + * Get the dynamic tracing state of an event for the given vCPU. + */ +static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev); + /** * trace_event_set_state: * @@ -154,14 +180,39 @@ static bool trace_event_get_state_dynamic(TraceEvent *ev); } \ } while (0) +/** + * trace_event_set_vcpu_state: + * + * Set the tracing state of an event for the given vCPU (only if not disabled). + */ +#define trace_event_set_vcpu_state(vcpu, id, state) \ + do { \ + if ((id ##_ENABLED)) { \ + TraceEvent *_e = trace_event_id(id); \ + trace_event_set_vcpu_state_dynamic(vcpu, _e, state); \ + } \ + } while (0) + /** * trace_event_set_state_dynamic: * * Set the dynamic tracing state of an event. * + * If the event has the 'vcpu' property, sets the state on all vCPUs. + * * Pre-condition: trace_event_get_state_static(ev) == true */ -static void trace_event_set_state_dynamic(TraceEvent *ev, bool state); +void trace_event_set_state_dynamic(TraceEvent *ev, bool state); + +/** + * trace_event_set_vcpu_state_dynamic: + * + * Set the dynamic tracing state of an event for the given vCPU. + * + * Pre-condition: trace_event_get_vcpu_state_static(ev) == true + */ +void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, + TraceEvent *ev, bool state); @@ -218,6 +269,15 @@ extern QemuOptsList qemu_trace_opts; */ char *trace_opt_parse(const char *optarg); +/** + * trace_init_vcpu_events: + * + * Re-synchronize initial event state with vCPUs (which can be created after + * trace_init_events()). + */ +void trace_init_vcpu_events(void); + + #include "trace/control-internal.h" #endif /* TRACE__CONTROL_H */ -- cgit v1.2.1