qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Lluís Vilanova" <vilanova@ac.upc.edu>,
	"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 3/4] trace: Fix dynamic event state on vCPU hot-unplug
Date: Mon, 16 Jan 2017 13:44:54 +0000	[thread overview]
Message-ID: <20170116134455.28636-4-stefanha@redhat.com> (raw)
In-Reply-To: <20170116134455.28636-1-stefanha@redhat.com>

From: Lluís Vilanova <vilanova@ac.upc.edu>

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 <vilanova@ac.upc.edu>
Message-id: 148278748055.1404.1570530281528619895.stgit@fimbulvetr.bsc.es
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 trace/control.h |  8 ++++++++
 qom/cpu.c       |  2 ++
 trace/control.c | 16 ++++++++++++++++
 3 files changed, 26 insertions(+)

diff --git a/trace/control.h b/trace/control.h
index ccaeac8..4ea53e2 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.
diff --git a/qom/cpu.c b/qom/cpu.c
index 03d9190..93e4105 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 1a7bee6..cb79bb1 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
-- 
2.9.3

  parent reply	other threads:[~2017-01-16 13:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 13:44 [Qemu-devel] [PULL 0/4] Tracing patches Stefan Hajnoczi
2017-01-16 13:44 ` [Qemu-devel] [PULL 1/4] trace-events: spelling fix Stefan Hajnoczi
2017-01-16 13:44 ` [Qemu-devel] [PULL 2/4] trace: Lock vCPU list when initializing dynamic tracing state Stefan Hajnoczi
2017-01-16 13:44 ` Stefan Hajnoczi [this message]
2017-01-16 13:44 ` [Qemu-devel] [PULL 4/4] trace: Add event "guest_cpu_exit" Stefan Hajnoczi
2017-01-19 10:46 ` [Qemu-devel] [PULL 0/4] Tracing patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170116134455.28636-4-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vilanova@ac.upc.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).