trace: [tcg] Delay changes to dynamic state when translating
This keeps consistency across all decisions taken during translation when the dynamic state of a vCPU is changed in the middle of translating some guest code. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Reviewed-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Emilio G. Cota <cota@braap.org> Message-id: 149915750615.6295.3713699402253529487.stgit@frigg.lan Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
d01c05c955
commit
d43811165d
|
@ -302,6 +302,8 @@ struct qemu_work_item;
|
||||||
* @kvm_fd: vCPU file descriptor for KVM.
|
* @kvm_fd: vCPU file descriptor for KVM.
|
||||||
* @work_mutex: Lock to prevent multiple access to queued_work_*.
|
* @work_mutex: Lock to prevent multiple access to queued_work_*.
|
||||||
* @queued_work_first: First asynchronous work pending.
|
* @queued_work_first: First asynchronous work pending.
|
||||||
|
* @trace_dstate_delayed: Delayed changes to trace_dstate (includes all changes
|
||||||
|
* to @trace_dstate).
|
||||||
* @trace_dstate: Dynamic tracing state of events for this vCPU (bitmask).
|
* @trace_dstate: Dynamic tracing state of events for this vCPU (bitmask).
|
||||||
*
|
*
|
||||||
* State of one CPU core or thread.
|
* State of one CPU core or thread.
|
||||||
|
@ -372,6 +374,7 @@ struct CPUState {
|
||||||
struct kvm_run *kvm_run;
|
struct kvm_run *kvm_run;
|
||||||
|
|
||||||
/* Used for events with 'vcpu' and *without* the 'disabled' properties */
|
/* Used for events with 'vcpu' and *without* the 'disabled' properties */
|
||||||
|
DECLARE_BITMAP(trace_dstate_delayed, CPU_TRACE_DSTATE_MAX_EVENTS);
|
||||||
DECLARE_BITMAP(trace_dstate, CPU_TRACE_DSTATE_MAX_EVENTS);
|
DECLARE_BITMAP(trace_dstate, CPU_TRACE_DSTATE_MAX_EVENTS);
|
||||||
|
|
||||||
/* TODO Move common fields from CPUArchState here. */
|
/* TODO Move common fields from CPUArchState here. */
|
||||||
|
|
|
@ -61,6 +61,13 @@ void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void trace_event_synchronize_vcpu_state_dynamic(
|
||||||
|
CPUState *vcpu, run_on_cpu_data ignored)
|
||||||
|
{
|
||||||
|
bitmap_copy(vcpu->trace_dstate, vcpu->trace_dstate_delayed,
|
||||||
|
CPU_TRACE_DSTATE_MAX_EVENTS);
|
||||||
|
}
|
||||||
|
|
||||||
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
|
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
|
||||||
TraceEvent *ev, bool state)
|
TraceEvent *ev, bool state)
|
||||||
{
|
{
|
||||||
|
@ -73,13 +80,20 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
|
||||||
if (state_pre != state) {
|
if (state_pre != state) {
|
||||||
if (state) {
|
if (state) {
|
||||||
trace_events_enabled_count++;
|
trace_events_enabled_count++;
|
||||||
set_bit(vcpu_id, vcpu->trace_dstate);
|
set_bit(vcpu_id, vcpu->trace_dstate_delayed);
|
||||||
(*ev->dstate)++;
|
(*ev->dstate)++;
|
||||||
} else {
|
} else {
|
||||||
trace_events_enabled_count--;
|
trace_events_enabled_count--;
|
||||||
clear_bit(vcpu_id, vcpu->trace_dstate);
|
clear_bit(vcpu_id, vcpu->trace_dstate_delayed);
|
||||||
(*ev->dstate)--;
|
(*ev->dstate)--;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Delay changes until next TB; we want all TBs to be built from a
|
||||||
|
* single set of dstate values to ensure consistency of generated
|
||||||
|
* tracing code.
|
||||||
|
*/
|
||||||
|
async_run_on_cpu(vcpu, trace_event_synchronize_vcpu_state_dynamic,
|
||||||
|
RUN_ON_CPU_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue