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>
This commit is contained in:
parent
43b48cfc3e
commit
585ec7273e
@ -27,7 +27,7 @@ def generate(events, backend):
|
|||||||
out('TraceEvent trace_events[TRACE_EVENT_COUNT] = {')
|
out('TraceEvent trace_events[TRACE_EVENT_COUNT] = {')
|
||||||
|
|
||||||
for e in events:
|
for e in events:
|
||||||
out(' { .id = %(id)s, .name = \"%(name)s\", .sstate = %(sstate)s, .dstate = 0 },',
|
out(' { .id = %(id)s, .name = \"%(name)s\", .sstate = %(sstate)s },',
|
||||||
id = "TRACE_" + e.name.upper(),
|
id = "TRACE_" + e.name.upper(),
|
||||||
name = e.name,
|
name = e.name,
|
||||||
sstate = "TRACE_%s_ENABLED" % e.name.upper())
|
sstate = "TRACE_%s_ENABLED" % e.name.upper())
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
extern TraceEvent trace_events[];
|
extern TraceEvent trace_events[];
|
||||||
|
extern bool trace_events_dstate[];
|
||||||
extern int trace_events_enabled_count;
|
extern int trace_events_enabled_count;
|
||||||
|
|
||||||
|
|
||||||
@ -52,18 +53,24 @@ static inline bool trace_event_get_state_static(TraceEvent *ev)
|
|||||||
return ev->sstate;
|
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)
|
static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
|
||||||
{
|
{
|
||||||
assert(ev != NULL);
|
int id = trace_event_get_id(ev);
|
||||||
return unlikely(trace_events_enabled_count) && ev->dstate;
|
return trace_event_get_state_dynamic_by_id(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
|
static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
|
||||||
{
|
{
|
||||||
|
int id = trace_event_get_id(ev);
|
||||||
assert(ev != NULL);
|
assert(ev != NULL);
|
||||||
assert(trace_event_get_state_static(ev));
|
assert(trace_event_get_state_static(ev));
|
||||||
trace_events_enabled_count += state - ev->dstate;
|
trace_events_enabled_count += state - trace_events_dstate[id];
|
||||||
ev->dstate = state;
|
trace_events_dstate[id] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* TRACE__CONTROL_INTERNAL_H */
|
#endif /* TRACE__CONTROL_INTERNAL_H */
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
|
|
||||||
int trace_events_enabled_count;
|
int trace_events_enabled_count;
|
||||||
|
bool trace_events_dstate[TRACE_EVENT_COUNT];
|
||||||
|
|
||||||
TraceEvent *trace_event_name(const char *name)
|
TraceEvent *trace_event_name(const char *name)
|
||||||
{
|
{
|
||||||
|
@ -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.
|
* As a down side, you must always use an immediate #TraceEventID value.
|
||||||
*/
|
*/
|
||||||
#define trace_event_get_state(id) \
|
#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:
|
* trace_event_get_state_static:
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
* @id: Unique event identifier.
|
* @id: Unique event identifier.
|
||||||
* @name: Event name.
|
* @name: Event name.
|
||||||
* @sstate: Static tracing state.
|
* @sstate: Static tracing state.
|
||||||
* @dstate: Dynamic tracing state.
|
|
||||||
*
|
*
|
||||||
* Opaque generic description of a tracing event.
|
* Opaque generic description of a tracing event.
|
||||||
*/
|
*/
|
||||||
@ -26,7 +25,6 @@ typedef struct TraceEvent {
|
|||||||
TraceEventID id;
|
TraceEventID id;
|
||||||
const char * name;
|
const char * name;
|
||||||
const bool sstate;
|
const bool sstate;
|
||||||
bool dstate;
|
|
||||||
} TraceEvent;
|
} TraceEvent;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user