diff options
author | Lluís Vilanova <vilanova@ac.upc.edu> | 2016-07-11 12:53:41 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-07-18 18:23:12 +0100 |
commit | 4815185902971c41fcdd700fa1fc3e1d9299900f (patch) | |
tree | fcdcdbb543e1ea9828e4e8820368675692f761f3 /trace/control-internal.h | |
parent | e1d6e0a4c0e23b30501b887211f1fa6e0eb799a3 (diff) |
trace: Add per-vCPU tracing states for events with the 'vcpu' property
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 <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'trace/control-internal.h')
-rw-r--r-- | trace/control-internal.h | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/trace/control-internal.h b/trace/control-internal.h index b326d88d72..a4e5f4aa06 100644 --- a/trace/control-internal.h +++ b/trace/control-internal.h @@ -10,8 +10,13 @@ #ifndef TRACE__CONTROL_INTERNAL_H #define TRACE__CONTROL_INTERNAL_H +#include <stddef.h> /* size_t */ + +#include "qom/cpu.h" + + extern TraceEvent trace_events[]; -extern bool trace_events_dstate[]; +extern uint16_t trace_events_dstate[]; extern int trace_events_enabled_count; @@ -74,13 +79,24 @@ static inline bool trace_event_get_state_dynamic(TraceEvent *ev) return trace_event_get_state_dynamic_by_id(id); } -static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state) +static inline bool trace_event_get_vcpu_state_dynamic_by_vcpu_id(CPUState *vcpu, + TraceEventVCPUID id) { - int id = trace_event_get_id(ev); - assert(ev != NULL); - assert(trace_event_get_state_static(ev)); - trace_events_enabled_count += state - trace_events_dstate[id]; - trace_events_dstate[id] = state; + /* it's on fast path, avoid consistency checks (asserts) */ + if (unlikely(trace_events_enabled_count)) { + return test_bit(id, vcpu->trace_dstate); + } else { + return false; + } +} + +static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, + TraceEvent *ev) +{ + TraceEventVCPUID id; + assert(trace_event_is_vcpu(ev)); + id = trace_event_get_vcpu_id(ev); + return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, id); } #endif /* TRACE__CONTROL_INTERNAL_H */ |