From patchwork Mon Sep 5 19:42:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9315125 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 CF61E60760 for ; Mon, 5 Sep 2016 19:48:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C10E3287D3 for ; Mon, 5 Sep 2016 19:48:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B61372889C; Mon, 5 Sep 2016 19:48:57 +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 8332F287D3 for ; Mon, 5 Sep 2016 19:48:55 +0000 (UTC) Received: from localhost ([::1]:56740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgzsz-0006Jh-Sr for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Sep 2016 15:48:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgzos-0003Wo-CY for qemu-devel@nongnu.org; Mon, 05 Sep 2016 15:44:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgzon-0002E5-VO for qemu-devel@nongnu.org; Mon, 05 Sep 2016 15:44:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgzon-0002E1-Mn for qemu-devel@nongnu.org; Mon, 05 Sep 2016 15:44:33 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 472FD83F41; Mon, 5 Sep 2016 19:44:33 +0000 (UTC) Received: from localhost (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u85JiVV1032741; Mon, 5 Sep 2016 15:44:32 -0400 From: Stefan Hajnoczi To: Date: Mon, 5 Sep 2016 15:42:48 -0400 Message-Id: <1473104569-6973-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1473104569-6973-1-git-send-email-stefanha@redhat.com> References: <1473104569-6973-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 05 Sep 2016 19:44:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/3] trace: Remove 'trace_events_dstate_init' 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: Peter Maydell , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Lluís Vilanova Removes the event state array used for early initialization. Since only events with the "vcpu" property need a late initialization fixup, threats their initialization specially. Assumes that the user won't touch the state of "vcpu" events between early and late initialization (e.g., through QMP). Signed-off-by: Lluís Vilanova Message-id: 147194273191.26836.14423079546263831356.stgit@fimbulvetr.bsc.es Signed-off-by: Stefan Hajnoczi --- stubs/trace-control.c | 5 +++++ trace/control-target.c | 9 +++++++++ trace/control.c | 21 ++++++++++----------- trace/control.h | 3 +++ trace/event-internal.h | 1 + 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/stubs/trace-control.c b/stubs/trace-control.c index fe59836..3740c38 100644 --- a/stubs/trace-control.c +++ b/stubs/trace-control.c @@ -11,6 +11,11 @@ #include "trace/control.h" +void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state) +{ + trace_event_set_state_dynamic(ev, state); +} + void trace_event_set_state_dynamic(TraceEvent *ev, bool state) { TraceEventID id; diff --git a/trace/control-target.c b/trace/control-target.c index 74c029a..4ee3733 100644 --- a/trace/control-target.c +++ b/trace/control-target.c @@ -13,6 +13,15 @@ #include "translate-all.h" +void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state) +{ + TraceEventID id = trace_event_get_id(ev); + assert(trace_event_get_state_static(ev)); + /* Ignore "vcpu" property, since no vCPUs have been created yet */ + trace_events_enabled_count += state - trace_events_dstate[id]; + trace_events_dstate[id] = state; +} + void trace_event_set_state_dynamic(TraceEvent *ev, bool state) { CPUState *vcpu; diff --git a/trace/control.c b/trace/control.c index b179cde..05d85ac 100644 --- a/trace/control.c +++ b/trace/control.c @@ -34,8 +34,6 @@ int trace_events_enabled_count; * - 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]; QemuOptsList qemu_trace_opts = { .name = "trace", @@ -145,10 +143,7 @@ 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; + trace_event_set_state_dynamic_init(ev, enable); } } } else { @@ -160,10 +155,7 @@ 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; + trace_event_set_state_dynamic_init(ev, enable); } } } @@ -284,7 +276,14 @@ void trace_init_vcpu_events(void) 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_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 0413b28..27a16fc 100644 --- a/trace/control.h +++ b/trace/control.h @@ -274,6 +274,9 @@ char *trace_opt_parse(const char *optarg); * * 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); diff --git a/trace/event-internal.h b/trace/event-internal.h index 5d8fa97..074faf6 100644 --- a/trace/event-internal.h +++ b/trace/event-internal.h @@ -29,5 +29,6 @@ typedef struct TraceEvent { const bool sstate; } TraceEvent; +void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state); #endif /* TRACE__EVENT_INTERNAL_H */