trace: Remove 'trace_events_dstate_init'
Removes the event state array used for early initialization. Since only events with the "vcpu" property need a late initialization fixup, threats their initialization specially. Assumes that the user won't touch the state of "vcpu" events between early and late initialization (e.g., through QMP). Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Message-id: 147194273191.26836.14423079546263831356.stgit@fimbulvetr.bsc.es Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
0a85241756
commit
a4d50b1d2a
@ -11,6 +11,11 @@
|
|||||||
#include "trace/control.h"
|
#include "trace/control.h"
|
||||||
|
|
||||||
|
|
||||||
|
void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
|
||||||
|
{
|
||||||
|
trace_event_set_state_dynamic(ev, state);
|
||||||
|
}
|
||||||
|
|
||||||
void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
|
void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
|
||||||
{
|
{
|
||||||
TraceEventID id;
|
TraceEventID id;
|
||||||
|
@ -13,6 +13,15 @@
|
|||||||
#include "translate-all.h"
|
#include "translate-all.h"
|
||||||
|
|
||||||
|
|
||||||
|
void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
|
||||||
|
{
|
||||||
|
TraceEventID id = trace_event_get_id(ev);
|
||||||
|
assert(trace_event_get_state_static(ev));
|
||||||
|
/* Ignore "vcpu" property, since no vCPUs have been created yet */
|
||||||
|
trace_events_enabled_count += state - trace_events_dstate[id];
|
||||||
|
trace_events_dstate[id] = state;
|
||||||
|
}
|
||||||
|
|
||||||
void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
|
void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
|
||||||
{
|
{
|
||||||
CPUState *vcpu;
|
CPUState *vcpu;
|
||||||
|
@ -34,8 +34,6 @@ int trace_events_enabled_count;
|
|||||||
* - true : Integral counting the number of vCPUs that have this event enabled.
|
* - true : Integral counting the number of vCPUs that have this event enabled.
|
||||||
*/
|
*/
|
||||||
uint16_t trace_events_dstate[TRACE_EVENT_COUNT];
|
uint16_t trace_events_dstate[TRACE_EVENT_COUNT];
|
||||||
/* Marks events for late vCPU state init */
|
|
||||||
static bool trace_events_dstate_init[TRACE_EVENT_COUNT];
|
|
||||||
|
|
||||||
QemuOptsList qemu_trace_opts = {
|
QemuOptsList qemu_trace_opts = {
|
||||||
.name = "trace",
|
.name = "trace",
|
||||||
@ -145,10 +143,7 @@ static void do_trace_enable_events(const char *line_buf)
|
|||||||
TraceEvent *ev = NULL;
|
TraceEvent *ev = NULL;
|
||||||
while ((ev = trace_event_pattern(line_ptr, ev)) != NULL) {
|
while ((ev = trace_event_pattern(line_ptr, ev)) != NULL) {
|
||||||
if (trace_event_get_state_static(ev)) {
|
if (trace_event_get_state_static(ev)) {
|
||||||
/* start tracing */
|
trace_event_set_state_dynamic_init(ev, enable);
|
||||||
trace_event_set_state_dynamic(ev, enable);
|
|
||||||
/* mark for late vCPU init */
|
|
||||||
trace_events_dstate_init[ev->id] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -160,10 +155,7 @@ static void do_trace_enable_events(const char *line_buf)
|
|||||||
error_report("WARNING: trace event '%s' is not traceable",
|
error_report("WARNING: trace event '%s' is not traceable",
|
||||||
line_ptr);
|
line_ptr);
|
||||||
} else {
|
} else {
|
||||||
/* start tracing */
|
trace_event_set_state_dynamic_init(ev, enable);
|
||||||
trace_event_set_state_dynamic(ev, enable);
|
|
||||||
/* mark for late vCPU init */
|
|
||||||
trace_events_dstate_init[ev->id] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,7 +276,14 @@ void trace_init_vcpu_events(void)
|
|||||||
while ((ev = trace_event_pattern("*", ev)) != NULL) {
|
while ((ev = trace_event_pattern("*", ev)) != NULL) {
|
||||||
if (trace_event_is_vcpu(ev) &&
|
if (trace_event_is_vcpu(ev) &&
|
||||||
trace_event_get_state_static(ev) &&
|
trace_event_get_state_static(ev) &&
|
||||||
trace_events_dstate_init[ev->id]) {
|
trace_event_get_state_dynamic(ev)) {
|
||||||
|
TraceEventID id = trace_event_get_id(ev);
|
||||||
|
/* check preconditions */
|
||||||
|
assert(trace_events_dstate[id] == 1);
|
||||||
|
/* disable early-init state ... */
|
||||||
|
trace_events_dstate[id] = 0;
|
||||||
|
trace_events_enabled_count--;
|
||||||
|
/* ... and properly re-enable */
|
||||||
trace_event_set_state_dynamic(ev, true);
|
trace_event_set_state_dynamic(ev, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,6 +274,9 @@ char *trace_opt_parse(const char *optarg);
|
|||||||
*
|
*
|
||||||
* Re-synchronize initial event state with vCPUs (which can be created after
|
* Re-synchronize initial event state with vCPUs (which can be created after
|
||||||
* trace_init_events()).
|
* trace_init_events()).
|
||||||
|
*
|
||||||
|
* Precondition: event states won't be changed between trace_enable_events() and
|
||||||
|
* trace_init_vcpu_events() (e.g., through QMP).
|
||||||
*/
|
*/
|
||||||
void trace_init_vcpu_events(void);
|
void trace_init_vcpu_events(void);
|
||||||
|
|
||||||
|
@ -29,5 +29,6 @@ typedef struct TraceEvent {
|
|||||||
const bool sstate;
|
const bool sstate;
|
||||||
} TraceEvent;
|
} TraceEvent;
|
||||||
|
|
||||||
|
void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state);
|
||||||
|
|
||||||
#endif /* TRACE__EVENT_INTERNAL_H */
|
#endif /* TRACE__EVENT_INTERNAL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user