aboutsummaryrefslogtreecommitdiff
path: root/trace
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-10-28 07:06:27 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2016-02-03 09:19:09 +0000
commit585ec7273e6fdab902b2128bc6c2a8136aafef04 (patch)
treec51aa9a5cf2fa1600e5b3128470935afe0eb3bd5 /trace
parent43b48cfc3e8ff745a10a6b78a55519d5cf7ec5e8 (diff)
downloadqemu-585ec7273e6fdab902b2128bc6c2a8136aafef04.zip
qemu-585ec7273e6fdab902b2128bc6c2a8136aafef04.tar.gz
qemu-585ec7273e6fdab902b2128bc6c2a8136aafef04.tar.bz2
trace: track enabled events in a separate array
This is more cache friendly on the fast path, where we already have the event id available. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'trace')
-rw-r--r--trace/control-internal.h15
-rw-r--r--trace/control.c1
-rw-r--r--trace/control.h2
-rw-r--r--trace/event-internal.h2
4 files changed, 13 insertions, 7 deletions
diff --git a/trace/control-internal.h b/trace/control-internal.h
index 271bddb..07cb1c1 100644
--- a/trace/control-internal.h
+++ b/trace/control-internal.h
@@ -14,6 +14,7 @@
extern TraceEvent trace_events[];
+extern bool trace_events_dstate[];
extern int trace_events_enabled_count;
@@ -52,18 +53,24 @@ static inline bool trace_event_get_state_static(TraceEvent *ev)
return ev->sstate;
}
+static inline bool trace_event_get_state_dynamic_by_id(int id)
+{
+ return unlikely(trace_events_enabled_count) && trace_events_dstate[id];
+}
+
static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
{
- assert(ev != NULL);
- return unlikely(trace_events_enabled_count) && ev->dstate;
+ int id = trace_event_get_id(ev);
+ return trace_event_get_state_dynamic_by_id(id);
}
static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
{
+ int id = trace_event_get_id(ev);
assert(ev != NULL);
assert(trace_event_get_state_static(ev));
- trace_events_enabled_count += state - ev->dstate;
- ev->dstate = state;
+ trace_events_enabled_count += state - trace_events_dstate[id];
+ trace_events_dstate[id] = state;
}
#endif /* TRACE__CONTROL_INTERNAL_H */
diff --git a/trace/control.c b/trace/control.c
index 95fbc07..700440c 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -17,6 +17,7 @@
#include "qemu/error-report.h"
int trace_events_enabled_count;
+bool trace_events_dstate[TRACE_EVENT_COUNT];
TraceEvent *trace_event_name(const char *name)
{
diff --git a/trace/control.h b/trace/control.h
index da9bb6b..6af7ddc 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -104,7 +104,7 @@ static const char * trace_event_get_name(TraceEvent *ev);
* As a down side, you must always use an immediate #TraceEventID value.
*/
#define trace_event_get_state(id) \
- ((id ##_ENABLED) && trace_event_get_state_dynamic(trace_event_id(id)))
+ ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
/**
* trace_event_get_state_static:
diff --git a/trace/event-internal.h b/trace/event-internal.h
index b2310d9..86f6a51 100644
--- a/trace/event-internal.h
+++ b/trace/event-internal.h
@@ -18,7 +18,6 @@
* @id: Unique event identifier.
* @name: Event name.
* @sstate: Static tracing state.
- * @dstate: Dynamic tracing state.
*
* Opaque generic description of a tracing event.
*/
@@ -26,7 +25,6 @@ typedef struct TraceEvent {
TraceEventID id;
const char * name;
const bool sstate;
- bool dstate;
} TraceEvent;