qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/3] trace: Fix dynamic event state on vCPU hot-unpl


From: Lluís Vilanova
Subject: [Qemu-devel] [PATCH 2/3] trace: Fix dynamic event state on vCPU hot-unplug
Date: Mon, 26 Dec 2016 22:24:40 +0100
User-agent: StGit/0.17.1-dirty

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 <address@hidden>
---
 qom/cpu.c       |    2 ++
 trace/control.c |   16 ++++++++++++++++
 trace/control.h |    8 ++++++++
 3 files changed, 26 insertions(+)

diff --git a/qom/cpu.c b/qom/cpu.c
index 03d9190f8c..93e41056d9 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -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);
 }
 
diff --git a/trace/control.c b/trace/control.c
index 1a7bee6ddc..cb79bb17ec 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -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
diff --git a/trace/control.h b/trace/control.h
index ccaeac8552..4ea53e2986 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -202,6 +202,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:
  *
  * List all available events.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]