Skip to content

Commit

Permalink
trace: Fix dynamic event state on vCPU hot-unplug
Browse files Browse the repository at this point in the history
We need to disable per-vCPU events on a vCPU that is hot-unplugged to
keep the dynamic event state global counters consistent.

Signed-off-by: Lluís Vilanova <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
  • Loading branch information
Lluís Vilanova authored and stefanhaRH committed Jan 16, 2017
1 parent fff895d commit 82e95ec
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions qom/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
static void cpu_common_unrealizefn(DeviceState *dev, Error **errp)
{
CPUState *cpu = CPU(dev);
/* NOTE: latest generic point before the cpu is fully unrealized */
trace_fini_vcpu(cpu);
cpu_exec_unrealizefn(cpu);
}

Expand Down
16 changes: 16 additions & 0 deletions trace/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,22 @@ void trace_init_file(const char *file)
#endif
}

void trace_fini_vcpu(CPUState *vcpu)
{
TraceEventIter iter;
TraceEvent *ev;

trace_event_iter_init(&iter, NULL);
while ((ev = trace_event_iter_next(&iter)) != NULL) {
if (trace_event_is_vcpu(ev) &&
trace_event_get_state_static(ev) &&
trace_event_get_vcpu_state_dynamic(vcpu, ev)) {
/* must disable to affect the global counter */
trace_event_set_vcpu_state_dynamic(vcpu, ev, false);
}
}
}

bool trace_init_backends(void)
{
#ifdef CONFIG_TRACE_SIMPLE
Expand Down
8 changes: 8 additions & 0 deletions trace/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ void trace_init_file(const char *file);
*/
void trace_init_vcpu(CPUState *vcpu);

/**
* trace_fini_vcpu:
* @vcpu: Removed vCPU.
*
* Disable dynamic event state for a hot-unplugged vCPU.
*/
void trace_fini_vcpu(CPUState *vcpu);

/**
* trace_list_events:
*
Expand Down

0 comments on commit 82e95ec

Please sign in to comment.