* [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle
@ 2016-09-19 12:55 Lluís Vilanova
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 1/3] trace: Properly initialize dynamic event states in hot-plugged vCPUs Lluís Vilanova
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Lluís Vilanova @ 2016-09-19 12:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Hajnoczi
Adds events to track vCPU hot-(un)plugging and reset.
As a bonus, first patch fixes per-vCPU dynamic event state initialization,
making the current late initialization code obsolete.
NOTE: This series is missing CPU hot-unplug, since I could not find a generic
point to hook the event.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
Changes in v3
=============
* Remove code for trace_fini_vcpu(), since there is no full support for
hot-unplugging.
Changes in v2
=============
* Properly support vCPU hot-plugging to "inherit" dynamic event states.
* Rename event "guest_cpu_init" to "guest_cpu_enter".
Lluís Vilanova (3):
trace: Properly initialize dynamic event states in hot-plugged vCPUs
trace: Add event "guest_cpu_enter"
trace: Add event "guest_cpu_reset"
bsd-user/main.c | 1 -
linux-user/main.c | 1 -
qom/cpu.c | 6 ++++++
stubs/trace-control.c | 6 ++++++
trace-events | 13 +++++++++++++
trace/control-target.c | 40 ++++++++++++++++++++++++++++++++++++++++
trace/control.c | 19 -------------------
trace/control.h | 19 ++++++++-----------
vl.c | 1 -
9 files changed, 73 insertions(+), 33 deletions(-)
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3 1/3] trace: Properly initialize dynamic event states in hot-plugged vCPUs
2016-09-19 12:55 [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle Lluís Vilanova
@ 2016-09-19 12:55 ` Lluís Vilanova
2016-09-23 12:40 ` Stefan Hajnoczi
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 2/3] trace: Add event "guest_cpu_enter" Lluís Vilanova
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Lluís Vilanova @ 2016-09-19 12:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Hajnoczi, Riku Voipio, Paolo Bonzini
Every time a vCPU is hot-plugged, it will "inherit" its tracing state
from the global state array. That is, if *any* existing vCPU has an
event enabled, new vCPUs will have too.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
bsd-user/main.c | 1 -
linux-user/main.c | 1 -
qom/cpu.c | 3 +++
stubs/trace-control.c | 6 ++++++
trace/control-target.c | 37 +++++++++++++++++++++++++++++++++++++
trace/control.c | 19 -------------------
trace/control.h | 19 ++++++++-----------
vl.c | 1 -
8 files changed, 54 insertions(+), 33 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 0fb08e4..f58bb43 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -1133,7 +1133,6 @@ int main(int argc, char **argv)
gdbserver_start (gdbstub_port);
gdb_handlesig(cpu, 0);
}
- trace_init_vcpu_events();
cpu_loop(env);
/* never exits */
return 0;
diff --git a/linux-user/main.c b/linux-user/main.c
index f2f4d2f..b792c91 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4810,7 +4810,6 @@ int main(int argc, char **argv, char **envp)
}
gdb_handlesig(cpu, 0);
}
- trace_init_vcpu_events();
cpu_loop(env);
/* never exits */
return 0;
diff --git a/qom/cpu.c b/qom/cpu.c
index 2553247..7e2e523 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -333,6 +333,9 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
cpu_synchronize_post_init(cpu);
cpu_resume(cpu);
}
+
+ /* NOTE: latest generic point where the cpu is fully relized */
+ trace_init_vcpu(cpu);
}
static void cpu_common_initfn(Object *obj)
diff --git a/stubs/trace-control.c b/stubs/trace-control.c
index 2dfcd9f..f765a02 100644
--- a/stubs/trace-control.c
+++ b/stubs/trace-control.c
@@ -44,3 +44,9 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
/* should never be called on non-target binaries */
abort();
}
+
+void trace_init_vcpu(CPUState *vcpu)
+{
+ /* should never be called on non-target binaries */
+ abort();
+}
diff --git a/trace/control-target.c b/trace/control-target.c
index 72081e2..3b7d99b 100644
--- a/trace/control-target.c
+++ b/trace/control-target.c
@@ -81,3 +81,40 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
}
}
}
+
+static bool adding_first_cpu(void)
+{
+ CPUState *cpu;
+ size_t count = 0;
+ CPU_FOREACH(cpu) {
+ count++;
+ if (count > 1) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void trace_init_vcpu(CPUState *vcpu)
+{
+ TraceEvent *ev = NULL;
+
+ while ((ev = trace_event_pattern("*", ev)) != NULL) {
+ if (trace_event_is_vcpu(ev) &&
+ trace_event_get_state_static(ev) &&
+ trace_event_get_state_dynamic(ev)) {
+ TraceEventID id = trace_event_get_id(ev);
+ if (adding_first_cpu()) {
+ /* check preconditions */
+ assert(trace_events_dstate[id] == 1);
+ /* disable early-init state ... */
+ trace_events_dstate[id] = 0;
+ trace_events_enabled_count--;
+ /* ... and properly re-enable */
+ trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
+ } else {
+ trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
+ }
+ }
+ }
+}
diff --git a/trace/control.c b/trace/control.c
index 05d85ac..10b3e9b 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -269,22 +269,3 @@ char *trace_opt_parse(const char *optarg)
return trace_file;
}
-
-void trace_init_vcpu_events(void)
-{
- TraceEvent *ev = NULL;
- while ((ev = trace_event_pattern("*", ev)) != NULL) {
- if (trace_event_is_vcpu(ev) &&
- trace_event_get_state_static(ev) &&
- trace_event_get_state_dynamic(ev)) {
- TraceEventID id = trace_event_get_id(ev);
- /* check preconditions */
- assert(trace_events_dstate[id] == 1);
- /* disable early-init state ... */
- trace_events_dstate[id] = 0;
- trace_events_enabled_count--;
- /* ... and properly re-enable */
- trace_event_set_state_dynamic(ev, true);
- }
- }
-}
diff --git a/trace/control.h b/trace/control.h
index 27a16fc..a22d112 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -239,6 +239,14 @@ bool trace_init_backends(void);
void trace_init_file(const char *file);
/**
+ * trace_init_vcpu:
+ * @vcpu: Added vCPU.
+ *
+ * Set initial dynamic event state for a hot-plugged vCPU.
+ */
+void trace_init_vcpu(CPUState *vcpu);
+
+/**
* trace_list_events:
*
* List all available events.
@@ -269,17 +277,6 @@ extern QemuOptsList qemu_trace_opts;
*/
char *trace_opt_parse(const char *optarg);
-/**
- * trace_init_vcpu_events:
- *
- * Re-synchronize initial event state with vCPUs (which can be created after
- * trace_init_events()).
- *
- * Precondition: event states won't be changed between trace_enable_events() and
- * trace_init_vcpu_events() (e.g., through QMP).
- */
-void trace_init_vcpu_events(void);
-
#include "trace/control-internal.h"
diff --git a/vl.c b/vl.c
index ee557a1..5d4d837 100644
--- a/vl.c
+++ b/vl.c
@@ -4613,7 +4613,6 @@ int main(int argc, char **argv, char **envp)
os_setup_post();
- trace_init_vcpu_events();
main_loop();
replay_disable_events();
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3 2/3] trace: Add event "guest_cpu_enter"
2016-09-19 12:55 [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle Lluís Vilanova
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 1/3] trace: Properly initialize dynamic event states in hot-plugged vCPUs Lluís Vilanova
@ 2016-09-19 12:55 ` Lluís Vilanova
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 3/3] trace: Add event "guest_cpu_reset" Lluís Vilanova
2016-09-23 12:40 ` [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle Stefan Hajnoczi
3 siblings, 0 replies; 6+ messages in thread
From: Lluís Vilanova @ 2016-09-19 12:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Hajnoczi
Signals the hot-plugging of a new virtual (guest) CPU.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
trace-events | 8 ++++++++
trace/control-target.c | 3 +++
2 files changed, 11 insertions(+)
diff --git a/trace-events b/trace-events
index 616cc52..16a1cb4 100644
--- a/trace-events
+++ b/trace-events
@@ -142,6 +142,14 @@ memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsigned si
### Guest events, keep at bottom
+
+## vCPU
+
+# Hot-plug a new virtual (guest) CPU
+#
+# Targets: all
+vcpu guest_cpu_enter(void)
+
# @vaddr: Access' virtual address.
# @info : Access' information (see below).
#
diff --git a/trace/control-target.c b/trace/control-target.c
index 3b7d99b..52fcce5 100644
--- a/trace/control-target.c
+++ b/trace/control-target.c
@@ -9,6 +9,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
+#include "trace.h"
#include "trace/control.h"
#include "translate-all.h"
@@ -117,4 +118,6 @@ void trace_init_vcpu(CPUState *vcpu)
}
}
}
+
+ trace_guest_cpu_enter(vcpu);
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3 3/3] trace: Add event "guest_cpu_reset"
2016-09-19 12:55 [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle Lluís Vilanova
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 1/3] trace: Properly initialize dynamic event states in hot-plugged vCPUs Lluís Vilanova
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 2/3] trace: Add event "guest_cpu_enter" Lluís Vilanova
@ 2016-09-19 12:55 ` Lluís Vilanova
2016-09-23 12:40 ` [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle Stefan Hajnoczi
3 siblings, 0 replies; 6+ messages in thread
From: Lluís Vilanova @ 2016-09-19 12:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Hajnoczi
Signals the reset of the state a virtual (guest) CPU.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
qom/cpu.c | 3 +++
trace-events | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/qom/cpu.c b/qom/cpu.c
index 7e2e523..5f0ec6e 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -29,6 +29,7 @@
#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
#include "hw/qdev-properties.h"
+#include "trace.h"
bool cpu_exists(int64_t id)
{
@@ -245,6 +246,8 @@ void cpu_reset(CPUState *cpu)
if (klass->reset != NULL) {
(*klass->reset)(cpu);
}
+
+ trace_guest_cpu_reset(cpu);
}
static void cpu_common_reset(CPUState *cpu)
diff --git a/trace-events b/trace-events
index 16a1cb4..fd452c9 100644
--- a/trace-events
+++ b/trace-events
@@ -150,6 +150,11 @@ memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsigned si
# Targets: all
vcpu guest_cpu_enter(void)
+# Reset the state of a virtual (guest) CPU
+#
+# Targets: all
+vcpu guest_cpu_reset(void)
+
# @vaddr: Access' virtual address.
# @info : Access' information (see below).
#
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v3 1/3] trace: Properly initialize dynamic event states in hot-plugged vCPUs
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 1/3] trace: Properly initialize dynamic event states in hot-plugged vCPUs Lluís Vilanova
@ 2016-09-23 12:40 ` Stefan Hajnoczi
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2016-09-23 12:40 UTC (permalink / raw)
To: Lluís Vilanova; +Cc: qemu-devel, Riku Voipio, Paolo Bonzini
[-- Attachment #1: Type: text/plain, Size: 482 bytes --]
On Mon, Sep 19, 2016 at 02:55:07PM +0200, Lluís Vilanova wrote:
> diff --git a/qom/cpu.c b/qom/cpu.c
> index 2553247..7e2e523 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -333,6 +333,9 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
> cpu_synchronize_post_init(cpu);
> cpu_resume(cpu);
> }
> +
> + /* NOTE: latest generic point where the cpu is fully relized */
s/relized/realized/
I'll fix this typo while merging.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle
2016-09-19 12:55 [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle Lluís Vilanova
` (2 preceding siblings ...)
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 3/3] trace: Add event "guest_cpu_reset" Lluís Vilanova
@ 2016-09-23 12:40 ` Stefan Hajnoczi
3 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2016-09-23 12:40 UTC (permalink / raw)
To: Lluís Vilanova; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]
On Mon, Sep 19, 2016 at 02:55:02PM +0200, Lluís Vilanova wrote:
> Adds events to track vCPU hot-(un)plugging and reset.
>
> As a bonus, first patch fixes per-vCPU dynamic event state initialization,
> making the current late initialization code obsolete.
>
> NOTE: This series is missing CPU hot-unplug, since I could not find a generic
> point to hook the event.
>
> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
>
> Changes in v3
> =============
>
> * Remove code for trace_fini_vcpu(), since there is no full support for
> hot-unplugging.
>
>
> Changes in v2
> =============
>
> * Properly support vCPU hot-plugging to "inherit" dynamic event states.
> * Rename event "guest_cpu_init" to "guest_cpu_enter".
>
>
> Lluís Vilanova (3):
> trace: Properly initialize dynamic event states in hot-plugged vCPUs
> trace: Add event "guest_cpu_enter"
> trace: Add event "guest_cpu_reset"
>
>
> bsd-user/main.c | 1 -
> linux-user/main.c | 1 -
> qom/cpu.c | 6 ++++++
> stubs/trace-control.c | 6 ++++++
> trace-events | 13 +++++++++++++
> trace/control-target.c | 40 ++++++++++++++++++++++++++++++++++++++++
> trace/control.c | 19 -------------------
> trace/control.h | 19 ++++++++-----------
> vl.c | 1 -
> 9 files changed, 73 insertions(+), 33 deletions(-)
>
>
> To: qemu-devel@nongnu.org
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-09-23 12:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-19 12:55 [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle Lluís Vilanova
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 1/3] trace: Properly initialize dynamic event states in hot-plugged vCPUs Lluís Vilanova
2016-09-23 12:40 ` Stefan Hajnoczi
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 2/3] trace: Add event "guest_cpu_enter" Lluís Vilanova
2016-09-19 12:55 ` [Qemu-devel] [PATCH v3 3/3] trace: Add event "guest_cpu_reset" Lluís Vilanova
2016-09-23 12:40 ` [Qemu-devel] [PATCH v3 0/3] trace: Add events to track vCPU lifecycle Stefan Hajnoczi
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).