From nobody Mon Feb 9 16:02:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500293597493174.39178645936477; Mon, 17 Jul 2017 05:13:17 -0700 (PDT) Received: from localhost ([::1]:50003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4tk-0003N6-14 for importer@patchew.org; Mon, 17 Jul 2017 08:13:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4sJ-0002R5-DL for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX4sI-0006zB-5l for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX4sH-0006yk-Sl for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3D817EBDB; Mon, 17 Jul 2017 12:11:40 +0000 (UTC) Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2EFE5C89F; Mon, 17 Jul 2017 12:11:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D3D817EBDB Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D3D817EBDB From: Stefan Hajnoczi To: Date: Mon, 17 Jul 2017 13:11:22 +0100 Message-Id: <20170717121127.25154-3-stefanha@redhat.com> In-Reply-To: <20170717121127.25154-1-stefanha@redhat.com> References: <20170717121127.25154-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 17 Jul 2017 12:11:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/7] trace: [tcg] Delay changes to dynamic state when translating 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 , "Emilio G . Cota" , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Llu=C3=ADs Vilanova 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=C3=ADs Vilanova Reviewed-by: Richard Henderson Reviewed-by: Emilio G. Cota Signed-off-by: Emilio G. Cota Message-id: 149915750615.6295.3713699402253529487.stgit@frigg.lan Signed-off-by: Stefan Hajnoczi --- include/qom/cpu.h | 3 +++ trace/control-target.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 5f188d4..25eefea 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -302,6 +302,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 ch= anges + * to @trace_dstate). * @trace_dstate: Dynamic tracing state of events for this vCPU (bitmask). * * State of one CPU core or thread. @@ -372,6 +374,7 @@ struct CPUState { struct kvm_run *kvm_run; =20 /* 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); =20 /* TODO Move common fields from CPUArchState here. */ diff --git a/trace/control-target.c b/trace/control-target.c index 99a8ed5..31c2ed1 100644 --- a/trace/control-target.c +++ b/trace/control-target.c @@ -61,6 +61,13 @@ void trace_event_set_state_dynamic(TraceEvent *ev, bool = state) } } =20 +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_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev, bool state) { @@ -73,13 +80,20 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, if (state_pre !=3D 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); } } =20 --=20 2.9.4