]> git.proxmox.com Git - mirror_qemu.git/commitdiff
trace: count number of enabled events
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 28 Oct 2015 06:06:26 +0000 (07:06 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 3 Feb 2016 09:19:08 +0000 (09:19 +0000)
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>
trace/control-internal.h
trace/control.c

index 5a8df28c58d0662318068662cbe8ba4c4742d32e..271bddb19ea6b7e051fe9750aa034b65e6bc25d5 100644 (file)
@@ -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;
 }
 
index 995beb384c13a0c716ac1dba1e164e92ab026cd6..95fbc07c3c95e8e472aebd39fa440769e97e9eae 100644 (file)
@@ -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);