From patchwork Tue Jun 14 13:11:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 9175781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 789F46075D for ; Tue, 14 Jun 2016 13:12:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66FAC2793B for ; Tue, 14 Jun 2016 13:12:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B23B280E0; Tue, 14 Jun 2016 13:12:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F29842793B for ; Tue, 14 Jun 2016 13:12:18 +0000 (UTC) Received: from localhost ([::1]:35172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCo8f-0001yr-6A for patchwork-qemu-devel@patchwork.kernel.org; Tue, 14 Jun 2016 09:12:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCo7p-0001fY-7n for qemu-devel@nongnu.org; Tue, 14 Jun 2016 09:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCo7l-0007ws-Gq for qemu-devel@nongnu.org; Tue, 14 Jun 2016 09:11:25 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:42418 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCo7k-0007wU-S4 for qemu-devel@nongnu.org; Tue, 14 Jun 2016 09:11:21 -0400 Received: from gw-3.ac.upc.es (gw-3.ac.upc.es [147.83.30.9]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id u5EDBCBp008053; Tue, 14 Jun 2016 15:11:12 +0200 Received: from localhost (unknown [84.88.51.85]) by gw-3.ac.upc.es (Postfix) with ESMTPSA id 4A2C4213; Tue, 14 Jun 2016 15:11:12 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Tue, 14 Jun 2016 15:11:12 +0200 Message-Id: <146590987194.16561.5003247869378936017.stgit@fimbulvetr.bsc.es> X-Mailer: git-send-email 2.8.1 In-Reply-To: <146590985033.16561.16324808287190305042.stgit@fimbulvetr.bsc.es> References: <146590985033.16561.16324808287190305042.stgit@fimbulvetr.bsc.es> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id u5EDBCBp008053 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH v4 4/6] trace: Add per-vCPU tracing states for events with the 'vcpu' property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Peter Crosthwaite , Riku Voipio , Blue Swirl , Stefan Hajnoczi , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Each vCPU gets a 'trace_dstate' bitmap to control the per-vCPU dynamic tracing state of events with the 'vcpu' property. Signed-off-by: Lluís Vilanova --- Makefile.objs | 1 + bsd-user/main.c | 2 ++ include/qom/cpu.h | 6 +++++ linux-user/main.c | 2 ++ qom/cpu.c | 1 + trace/Makefile.objs | 26 ++++++++++++++++++++ trace/control-internal.h | 28 ++++++++++++++++----- trace/control-stub.c | 28 +++++++++++++++++++++ trace/control-target.c | 53 ++++++++++++++++++++++++++++++++++++++++ trace/control.c | 29 ++++++++++++++++++++-- trace/control.h | 61 +++++++++++++++++++++++++++++++++++++++++++++- translate-all.h | 3 ++ vl.c | 1 + 13 files changed, 231 insertions(+), 10 deletions(-) create mode 100644 trace/control-stub.c create mode 100644 trace/control-target.c diff --git a/Makefile.objs b/Makefile.objs index da49b71..30ae957 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -102,6 +102,7 @@ version-lobj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.lo # tracing util-obj-y += trace/ target-obj-y += trace/ +stub-obj-y += trace/ ###################################################################### # guest agent diff --git a/bsd-user/main.c b/bsd-user/main.c index 9f592be..e43a583 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -27,6 +27,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "tcg.h" +#include "trace/control.h" #include "qemu/timer.h" #include "qemu/envlist.h" #include "exec/log.h" @@ -1116,6 +1117,7 @@ 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/include/qom/cpu.h b/include/qom/cpu.h index 32f3af3..c27489f 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -24,8 +24,10 @@ #include "disas/bfd.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" +#include "qemu/bitmap.h" #include "qemu/queue.h" #include "qemu/thread.h" +#include "trace/generated-events.h" typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size, void *opaque); @@ -273,6 +275,7 @@ 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: Dynamic tracing state of events for this vCPU (bitmask). * * State of one CPU core or thread. */ @@ -340,6 +343,9 @@ struct CPUState { struct KVMState *kvm_state; struct kvm_run *kvm_run; + /* Used for events with 'vcpu' and *without* the 'disabled' properties */ + DECLARE_BITMAP(trace_dstate, TRACE_VCPU_EVENT_COUNT); + /* TODO Move common fields from CPUArchState here. */ int cpu_index; /* used by alpha TCG */ uint32_t halted; /* used by alpha, cris, ppc TCG */ diff --git a/linux-user/main.c b/linux-user/main.c index f8a8764..b49d764 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -29,6 +29,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "tcg.h" +#include "trace/control.h" #include "qemu/timer.h" #include "qemu/envlist.h" #include "elf.h" @@ -4776,6 +4777,7 @@ 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 751e992..929ecbe 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -330,6 +330,7 @@ static void cpu_common_initfn(Object *obj) qemu_mutex_init(&cpu->work_mutex); QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); + bitmap_zero(cpu->trace_dstate, TRACE_VCPU_EVENT_COUNT); } static void cpu_common_finalize(Object *obj) diff --git a/trace/Makefile.objs b/trace/Makefile.objs index 5145b34..902d47b 100644 --- a/trace/Makefile.objs +++ b/trace/Makefile.objs @@ -12,6 +12,8 @@ tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py") # Auto-generated event descriptions for LTTng ust code ifeq ($(findstring ust,$(TRACE_BACKENDS)),ust) + +ifndef MAKEFILE_GUARD_TRACE $(obj)/generated-ust-provider.h: $(obj)/generated-ust-provider.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ $(obj)/generated-ust-provider.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) @@ -30,11 +32,14 @@ $(obj)/generated-ust.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(obj)/generated-events.h: $(obj)/generated-ust-provider.h $(obj)/generated-events.c: $(obj)/generated-ust.c +endif # MAKEFILE_GUARD_TRACE + endif ###################################################################### # Auto-generated event descriptions +ifndef MAKEFILE_GUARD_TRACE $(obj)/generated-events.h: $(obj)/generated-events.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ $(obj)/generated-events.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) @@ -50,6 +55,7 @@ $(obj)/generated-events.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) --format=events-c \ --backends=$(TRACE_BACKENDS) \ < $< > $@," GEN $(patsubst %-timestamp,%,$@)") +endif # MAKEFILE_GUARD_TRACE util-obj-y += generated-events.o @@ -60,6 +66,7 @@ util-obj-y += generated-events.o ################################################## # Execution level +ifndef MAKEFILE_GUARD_TRACE $(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp @cmp -s $< $@ || cp $< $@ $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) @@ -67,10 +74,12 @@ $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf --format=h \ --backends=$(TRACE_BACKENDS) \ < $< > $@," GEN $(patsubst %-timestamp,%,$@)") +endif # MAKEFILE_GUARD_TRACE ############################## # non-DTrace +ifndef MAKEFILE_GUARD_TRACE $(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp @cmp -s $< $@ || cp $< $@ $(obj)/generated-tracers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) @@ -80,6 +89,7 @@ $(obj)/generated-tracers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf < $< > $@," GEN $(patsubst %-timestamp,%,$@)") $(obj)/generated-tracers.o: $(obj)/generated-tracers.c $(obj)/generated-tracers.h +endif # MAKEFILE_GUARD_TRACE ############################## # DTrace @@ -88,6 +98,8 @@ $(obj)/generated-tracers.o: $(obj)/generated-tracers.c $(obj)/generated-tracers. # but that gets picked up by QEMU's Makefile as an external dependency # rule file. So we use '.dtrace' instead ifeq ($(findstring dtrace,$(TRACE_BACKENDS)),dtrace) + +ifndef MAKEFILE_GUARD_TRACE $(obj)/generated-tracers-dtrace.dtrace: $(obj)/generated-tracers-dtrace.dtrace-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ $(obj)/generated-tracers-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) @@ -100,6 +112,7 @@ $(obj)/generated-tracers-dtrace.h: $(obj)/generated-tracers-dtrace.dtrace $(call quiet-command,dtrace -o $@ -h -s $<, " GEN $@") $(obj)/generated-tracers-dtrace.o: $(obj)/generated-tracers-dtrace.dtrace +endif # MAKEFILE_GUARD_TRACE util-obj-y += generated-tracers-dtrace.o endif @@ -107,6 +120,7 @@ endif ################################################## # Translation level +ifndef MAKEFILE_GUARD_TRACE $(obj)/generated-helpers-wrappers.h: $(obj)/generated-helpers-wrappers.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ $(obj)/generated-helpers-wrappers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) @@ -132,10 +146,12 @@ $(obj)/generated-helpers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf < $< > $@," GEN $(patsubst %-timestamp,%,$@)") $(obj)/generated-helpers.o: $(obj)/generated-helpers.c +endif # MAKEFILE_GUARD_TRACE target-obj-y += generated-helpers.o +ifndef MAKEFILE_GUARD_TRACE $(obj)/generated-tcg-tracers.h: $(obj)/generated-tcg-tracers.h-timestamp @cmp $< $@ >/dev/null 2>&1 || cp $< $@ $(obj)/generated-tcg-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y) @@ -143,6 +159,7 @@ $(obj)/generated-tcg-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/ --format=tcg-h \ --backend=$(TRACE_BACKENDS) \ < $< > $@," GEN $(patsubst %-timestamp,%,$@)") +endif # MAKEFILE_GUARD_TRACE ###################################################################### @@ -152,4 +169,13 @@ util-obj-$(CONFIG_TRACE_SIMPLE) += simple.o generated-tracers.o util-obj-$(CONFIG_TRACE_FTRACE) += ftrace.o util-obj-$(CONFIG_TRACE_UST) += generated-ust.o util-obj-y += control.o +target-obj-y += control-target.o +stub-obj-y += control-stub.o util-obj-y += qmp.o + + +###################################################################### +# Avoid rule overrides when included from multiple top-level variables +ifndef MAKEFILE_GUARD_TRACE +MAKEFILE_GUARD_TRACE = 1 +endif diff --git a/trace/control-internal.h b/trace/control-internal.h index 3f368fd..fde1bba 100644 --- a/trace/control-internal.h +++ b/trace/control-internal.h @@ -10,10 +10,13 @@ #ifndef TRACE__CONTROL_INTERNAL_H #define TRACE__CONTROL_INTERNAL_H +#include /* size_t */ + +#include "qom/cpu.h" extern TraceEvent trace_events[]; -extern bool trace_events_dstate[]; +extern uint16_t trace_events_dstate[]; extern int trace_events_enabled_count; @@ -76,13 +79,24 @@ static inline bool trace_event_get_state_dynamic(TraceEvent *ev) return trace_event_get_state_dynamic_by_id(id); } -static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state) +static inline bool trace_event_get_vcpu_state_dynamic_by_vcpu_id(CPUState *vcpu, + TraceEventVCPUID id) { - int id = trace_event_get_id(ev); - assert(ev != NULL); - assert(trace_event_get_state_static(ev)); - trace_events_enabled_count += state - trace_events_dstate[id]; - trace_events_dstate[id] = state; + /* it's on fast path, avoid consistency checks (asserts) */ + if (unlikely(trace_events_enabled_count)) { + return test_bit(id, vcpu->trace_dstate); + } else { + return false; + } +} + +static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, + TraceEvent *ev) +{ + TraceEventVCPUID id; + assert(trace_event_is_vcpu(ev)); + id = trace_event_get_vcpu_id(ev); + return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, id); } #endif /* TRACE__CONTROL_INTERNAL_H */ diff --git a/trace/control-stub.c b/trace/control-stub.c new file mode 100644 index 0000000..fe59836 --- /dev/null +++ b/trace/control-stub.c @@ -0,0 +1,28 @@ +/* + * Interface for configuring and controlling the state of tracing events. + * + * Copyright (C) 2014-2016 Lluís Vilanova + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "trace/control.h" + + +void trace_event_set_state_dynamic(TraceEvent *ev, bool state) +{ + TraceEventID id; + assert(trace_event_get_state_static(ev)); + id = trace_event_get_id(ev); + trace_events_enabled_count += state - trace_events_dstate[id]; + trace_events_dstate[id] = state; +} + +void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, + TraceEvent *ev, bool state) +{ + /* should never be called on non-target binaries */ + abort(); +} diff --git a/trace/control-target.c b/trace/control-target.c new file mode 100644 index 0000000..74c029a --- /dev/null +++ b/trace/control-target.c @@ -0,0 +1,53 @@ +/* + * Interface for configuring and controlling the state of tracing events. + * + * Copyright (C) 2014-2016 Lluís Vilanova + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "trace/control.h" +#include "translate-all.h" + + +void trace_event_set_state_dynamic(TraceEvent *ev, bool state) +{ + CPUState *vcpu; + assert(trace_event_get_state_static(ev)); + if (trace_event_is_vcpu(ev)) { + CPU_FOREACH(vcpu) { + trace_event_set_vcpu_state_dynamic(vcpu, ev, state); + } + } else { + TraceEventID id = trace_event_get_id(ev); + trace_events_enabled_count += state - trace_events_dstate[id]; + trace_events_dstate[id] = state; + } +} + +void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, + TraceEvent *ev, bool state) +{ + TraceEventID id; + TraceEventVCPUID vcpu_id; + bool state_pre; + assert(trace_event_get_state_static(ev)); + assert(trace_event_is_vcpu(ev)); + id = trace_event_get_id(ev); + vcpu_id = trace_event_get_vcpu_id(ev); + state_pre = test_bit(vcpu_id, vcpu->trace_dstate); + if (state_pre != state) { + if (state) { + trace_events_enabled_count++; + set_bit(vcpu_id, vcpu->trace_dstate); + trace_events_dstate[id]++; + } else { + trace_events_enabled_count--; + clear_bit(vcpu_id, vcpu->trace_dstate); + trace_events_dstate[id]--; + } + } +} diff --git a/trace/control.c b/trace/control.c index d099f73..b0a5dcf 100644 --- a/trace/control.c +++ b/trace/control.c @@ -1,7 +1,7 @@ /* * Interface for configuring and controlling the state of tracing events. * - * Copyright (C) 2011-2014 Lluís Vilanova + * Copyright (C) 2011-2016 Lluís Vilanova * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. @@ -23,7 +23,14 @@ #include "monitor/monitor.h" int trace_events_enabled_count; -bool trace_events_dstate[TRACE_EVENT_COUNT]; +/* + * Interpretation depends on wether the event has the 'vcpu' property: + * - false: Boolean value indicating whether the event is active. + * - true : Integral counting the number of vCPUs that have this event enabled. + */ +uint16_t trace_events_dstate[TRACE_EVENT_COUNT]; +/* Marks events for late vCPU state init */ +static bool trace_events_dstate_init[TRACE_EVENT_COUNT]; TraceEvent *trace_event_name(const char *name) { @@ -112,7 +119,10 @@ static void do_trace_enable_events(const char *line_buf) TraceEvent *ev = NULL; while ((ev = trace_event_pattern(line_ptr, ev)) != NULL) { if (trace_event_get_state_static(ev)) { + /* start tracing */ trace_event_set_state_dynamic(ev, enable); + /* mark for late vCPU init */ + trace_events_dstate_init[ev->id] = true; } } } else { @@ -124,7 +134,10 @@ static void do_trace_enable_events(const char *line_buf) error_report("WARNING: trace event '%s' is not traceable", line_ptr); } else { + /* start tracing */ trace_event_set_state_dynamic(ev, enable); + /* mark for late vCPU init */ + trace_events_dstate_init[ev->id] = true; } } } @@ -216,3 +229,15 @@ bool trace_init_backends(void) return true; } + +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_events_dstate_init[ev->id]) { + trace_event_set_state_dynamic(ev, true); + } + } +} diff --git a/trace/control.h b/trace/control.h index d37bce7..5234a8e 100644 --- a/trace/control.h +++ b/trace/control.h @@ -124,6 +124,23 @@ static const char * trace_event_get_name(TraceEvent *ev); ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id)) /** + * trace_event_get_vcpu_state: + * @vcpu: Target vCPU. + * @id: Event identifier (TraceEventID). + * @vcpu_id: Per-vCPU event identifier (TraceEventVCPUID). + * + * Get the tracing state of an event (both static and dynamic) for the given + * vCPU. + * + * If the event has the disabled property, the check will have no performance + * impact. + * + * As a down side, you must always use an immediate #TraceEventID value. + */ +#define trace_event_get_vcpu_state(vcpu, id, vcpu_id) \ + ((id ##_ENABLED) && trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id)) + +/** * trace_event_get_state_static: * @id: Event identifier. * @@ -138,10 +155,19 @@ static bool trace_event_get_state_static(TraceEvent *ev); * trace_event_get_state_dynamic: * * Get the dynamic tracing state of an event. + * + * If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs. */ static bool trace_event_get_state_dynamic(TraceEvent *ev); /** + * trace_event_get_vcpu_state_dynamic: + * + * Get the dynamic tracing state of an event for the given vCPU. + */ +static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev); + +/** * trace_event_set_state: * * Set the tracing state of an event (only if possible). @@ -155,13 +181,38 @@ static bool trace_event_get_state_dynamic(TraceEvent *ev); } while (0) /** + * trace_event_set_vcpu_state: + * + * Set the tracing state of an event for the given vCPU (only if not disabled). + */ +#define trace_event_set_vcpu_state(vcpu, id, state) \ + do { \ + if ((id ##_ENABLED)) { \ + TraceEvent *_e = trace_event_id(id); \ + trace_event_set_vcpu_state_dynamic(vcpu, _e, state); \ + } \ + } while (0) + +/** * trace_event_set_state_dynamic: * * Set the dynamic tracing state of an event. * + * If the event has the 'vcpu' property, sets the state on all vCPUs. + * * Pre-condition: trace_event_get_state_static(ev) == true */ -static void trace_event_set_state_dynamic(TraceEvent *ev, bool state); +void trace_event_set_state_dynamic(TraceEvent *ev, bool state); + +/** + * trace_event_set_vcpu_state_dynamic: + * + * Set the dynamic tracing state of an event for the given vCPU. + * + * Pre-condition: trace_event_get_vcpu_state_static(ev) == true + */ +void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, + TraceEvent *ev, bool state); @@ -214,6 +265,14 @@ void trace_list_events(void); */ void trace_enable_events(const char *line_buf); +/** + * trace_init_vcpu_events: + * + * Re-synchronize initial event state with vCPUs (which can be created after + * trace_init_events()). + */ +void trace_init_vcpu_events(void); + #include "trace/control-internal.h" diff --git a/translate-all.h b/translate-all.h index 0384640..bb8f542 100644 --- a/translate-all.h +++ b/translate-all.h @@ -19,6 +19,9 @@ #ifndef TRANSLATE_ALL_H #define TRANSLATE_ALL_H +#include "exec/exec-all.h" + + /* translate-all.c */ void tb_invalidate_phys_page_fast(tb_page_addr_t start, int len); void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, diff --git a/vl.c b/vl.c index b0bcc25..e3d8f65 100644 --- a/vl.c +++ b/vl.c @@ -4624,6 +4624,7 @@ int main(int argc, char **argv, char **envp) os_setup_post(); + trace_init_vcpu_events(); main_loop(); replay_disable_events();