diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2015-10-28 07:06:26 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-02-03 09:19:08 +0000 |
commit | 43b48cfc3e8ff745a10a6b78a55519d5cf7ec5e8 (patch) | |
tree | 659f921a14e9b8a6bfb03aac53b578cfc7fa7554 | |
parent | c65db7705b7926f4a084b93778e4bd5dd3990aad (diff) | |
download | qemu-43b48cfc3e8ff745a10a6b78a55519d5cf7ec5e8.zip qemu-43b48cfc3e8ff745a10a6b78a55519d5cf7ec5e8.tar.gz qemu-43b48cfc3e8ff745a10a6b78a55519d5cf7ec5e8.tar.bz2 |
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 <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r-- | trace/control-internal.h | 4 | ||||
-rw-r--r-- | trace/control.c | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/trace/control-internal.h b/trace/control-internal.h index 5a8df28..271bddb 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; } diff --git a/trace/control.c b/trace/control.c index 995beb3..95fbc07 100644 --- a/trace/control.c +++ b/trace/control.c @@ -16,6 +16,8 @@ #endif #include "qemu/error-report.h" +int trace_events_enabled_count; + TraceEvent *trace_event_name(const char *name) { assert(name != NULL); |