From 43b48cfc3e8ff745a10a6b78a55519d5cf7ec5e8 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 28 Oct 2015 07:06:26 +0100 Subject: trace: count number of enabled events This lets trace_event_get_state_dynamic quickly return false. Right now there is hardly any benefit because there are also many assertions and indirections, but the next patch will streamline all of this. Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- trace/control-internal.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'trace/control-internal.h') diff --git a/trace/control-internal.h b/trace/control-internal.h index 5a8df28c58..271bddb19e 100644 --- a/trace/control-internal.h +++ b/trace/control-internal.h @@ -14,6 +14,7 @@ extern TraceEvent trace_events[]; +extern int trace_events_enabled_count; static inline TraceEventID trace_event_count(void) @@ -54,13 +55,14 @@ static inline bool trace_event_get_state_static(TraceEvent *ev) static inline bool trace_event_get_state_dynamic(TraceEvent *ev) { assert(ev != NULL); - return ev->dstate; + return unlikely(trace_events_enabled_count) && ev->dstate; } static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state) { assert(ev != NULL); assert(trace_event_get_state_static(ev)); + trace_events_enabled_count += state - ev->dstate; ev->dstate = state; } -- cgit v1.2.1