Skip to contentSkip to conversation

trace: Immediately apply per-vCPU state changes if a vCPU is being created

PATCH Superseded Lluís Vilanova 2 participants 2 messages Sep 6, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace: Immediately apply per-vCPU state changes if a vCPU is being created

Right now, function trace_event_set_vcpu_state_dynamic() asynchronously enables events in the case a vCPU is executing TCG code. If the vCPU is being created this makes some events like "guest_cpu_enter" to not be traced.

---
 trace/control-target.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
trace/control-target.c +12 -7
index 4e36101997..0056da6a46 100644
@@ -88,13 +88,18 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
             clear_bit(vcpu_id, vcpu->trace_dstate_delayed);
             (*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);
+        if (vcpu->created) {
+            /*
+             * 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);
+        } else {
+            run_on_cpu_data ignored;
+            trace_event_synchronize_vcpu_state_dynamic(vcpu, ignored);
+        }
     }
 }
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Lluís Vilanova

Right now, function trace_event_set_vcpu_state_dynamic() asynchronously enables events in the case a vCPU is executing TCG code. If the vCPU is being created this makes some events like "guest_cpu_enter" to not be traced.

---
 trace/control-target.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
trace/control-target.c +1 -7
index 4e36101997..0056da6a46 100644
@@ -88,13 +88,18 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
             clear_bit(vcpu_id, vcpu->trace_dstate_delayed);
             (*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);
+        if (vcpu->created) {

trace/control-target.c void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, · line 101

Quoted 10 lines
trace/control-target.c +10 -0
+            /*
+             * 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);
+        } else {
+            run_on_cpu_data ignored;
+            trace_event_synchronize_vcpu_state_dynamic(vcpu, ignored);

I'd prefer RUN_ON_CPU_NULL here instead of the ignored param. Other than that,

		E.