From: "Emilio G. Cota" <cota@braap.org>
To: qemu-devel@nongnu.org
Cc: "Daniel P . Berrange" <berrange@redhat.com>,
"Lluís Vilanova" <vilanova@ac.upc.edu>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Richard Henderson" <rth@twiddle.net>,
"Laurent Desnogues" <laurent.desnogues@gmail.com>
Subject: [Qemu-devel] [PATCH 3/7] trace: [tcg] Delay changes to dynamic state when translating
Date: Mon, 26 Jun 2017 18:04:37 -0400 [thread overview]
Message-ID: <1498514681-3059-4-git-send-email-cota@braap.org> (raw)
In-Reply-To: <1498514681-3059-1-git-send-email-cota@braap.org>
From: Lluís Vilanova <vilanova@ac.upc.edu>
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>
[cota: use CPU_TRACE_DSTATE_MAX_EVENTS instead of trace_get_vcpu_event_count()]
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
include/qom/cpu.h | 3 +++
trace/control-target.c | 19 +++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index bc6e20f..29f4a32 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -303,6 +303,8 @@ struct qemu_work_item;
* @kvm_fd: vCPU file descriptor for KVM.
* @work_mutex: Lock to prevent multiple access to queued_work_*.
* @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).
*
* State of one CPU core or thread.
@@ -375,6 +377,7 @@ struct CPUState {
struct kvm_run *kvm_run;
/* 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);
/* TODO Move common fields from CPUArchState here. */
diff --git a/trace/control-target.c b/trace/control-target.c
index 99a8ed5..c3a83d2 100644
--- a/trace/control-target.c
+++ b/trace/control-target.c
@@ -8,6 +8,7 @@
*/
#include "qemu/osdep.h"
+#include "qom/cpu.h"
#include "cpu.h"
#include "trace-root.h"
#include "trace/control.h"
@@ -34,6 +35,13 @@ void trace_event_set_state_dynamic_init(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_state_dynamic(TraceEvent *ev, bool state)
{
CPUState *vcpu;
@@ -73,13 +81,20 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
if (state_pre != state) {
if (state) {
trace_events_enabled_count++;
- set_bit(vcpu_id, vcpu->trace_dstate);
+ set_bit(vcpu_id, vcpu->trace_dstate_delayed);
(*ev->dstate)++;
} else {
trace_events_enabled_count--;
- clear_bit(vcpu_id, vcpu->trace_dstate);
+ 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);
}
}
--
2.7.4
next prev parent reply other threads:[~2017-06-26 22:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-26 22:04 [Qemu-devel] [PATCH v9 0/7] trace: Optimize per-vCPU TCG tracing states Emilio G. Cota
2017-06-26 22:04 ` [Qemu-devel] [PATCH 1/7] exec: [tcg] Refactor flush of per-CPU virtual TB cache Emilio G. Cota
2017-06-26 22:04 ` [Qemu-devel] [PATCH 2/7] cpu: allocate cpu->trace_dstate in place Emilio G. Cota
2017-06-26 22:04 ` Emilio G. Cota [this message]
2017-06-26 22:04 ` [Qemu-devel] [PATCH 4/7] exec: [tcg] Use different TBs according to the vCPU's dynamic tracing state Emilio G. Cota
2017-06-26 22:04 ` [Qemu-devel] [PATCH 5/7] trace: [tcg] Do not generate TCG code to trace dinamically-disabled events Emilio G. Cota
2017-06-26 22:04 ` [Qemu-devel] [PATCH 6/7] trace: [tcg, trivial] Re-align generated code Emilio G. Cota
2017-06-26 22:04 ` [Qemu-devel] [PATCH 7/7] trace: Statically enable all TCG guest events Emilio G. Cota
2017-07-10 12:07 ` [Qemu-devel] [PATCH v9 0/7] trace: Optimize per-vCPU TCG tracing states Stefan Hajnoczi
2017-07-11 10:55 ` Stefan Hajnoczi
2017-07-11 12:35 ` Lluís Vilanova
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=1498514681-3059-4-git-send-email-cota@braap.org \
--to=cota@braap.org \
--cc=berrange@redhat.com \
--cc=laurent.desnogues@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=stefanha@redhat.com \
--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).