From nobody Mon May 6 17:25:39 2024 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 1500293584499564.4159355202262; Mon, 17 Jul 2017 05:13:04 -0700 (PDT) Received: from localhost ([::1]:50002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4tZ-0003DQ-4L for importer@patchew.org; Mon, 17 Jul 2017 08:13:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4sF-0002O7-1q for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX4sD-0006w7-MV for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44252) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX4sD-0006vY-Dj for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72395356C2; Mon, 17 Jul 2017 12:11:36 +0000 (UTC) Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3594F173BD; Mon, 17 Jul 2017 12:11:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 72395356C2 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 72395356C2 From: Stefan Hajnoczi To: Date: Mon, 17 Jul 2017 13:11:21 +0100 Message-Id: <20170717121127.25154-2-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 17 Jul 2017 12:11:36 +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 1/7] trace: Allocate cpu->trace_dstate in place 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 There's little point in dynamically allocating the bitmap if we know at compile-time the max number of events we want to support. Thus, make room in the struct for the bitmap, which will make things easier later: this paves the way for upcoming changes, in which we'll use a u32 to fully capture cpu->trace_dstate. This change also increases performance by saving a dereference and improving locality--note that this is important since upcoming work makes reading this bitmap fairly common. Signed-off-by: Emilio G. Cota Reviewed-by: Llu=C3=ADs Vilanova Signed-off-by: Llu=C3=ADs Vilanova Message-id: 149915725977.6295.15069969323605305641.stgit@frigg.lan Signed-off-by: Stefan Hajnoczi --- include/qom/cpu.h | 9 +++------ qom/cpu.c | 8 -------- trace/control.c | 9 ++++++++- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 04c31e6..5f188d4 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -259,6 +259,7 @@ typedef void (*run_on_cpu_func)(CPUState *cpu, run_on_c= pu_data data); struct qemu_work_item; =20 #define CPU_UNSET_NUMA_NODE_ID -1 +#define CPU_TRACE_DSTATE_MAX_EVENTS 32 =20 /** * CPUState: @@ -370,12 +371,8 @@ struct CPUState { struct KVMState *kvm_state; struct kvm_run *kvm_run; =20 - /* - * Used for events with 'vcpu' and *without* the 'disabled' properties. - * Dynamically allocated based on bitmap requried to hold up to - * trace_get_vcpu_event_count() entries. - */ - unsigned long *trace_dstate; + /* Used for events with 'vcpu' and *without* the 'disabled' properties= */ + DECLARE_BITMAP(trace_dstate, CPU_TRACE_DSTATE_MAX_EVENTS); =20 /* TODO Move common fields from CPUArchState here. */ int cpu_index; /* used by alpha TCG */ diff --git a/qom/cpu.c b/qom/cpu.c index a39ff6c..4f38db0 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -380,7 +380,6 @@ static void cpu_common_unrealizefn(DeviceState *dev, Er= ror **errp) =20 static void cpu_common_initfn(Object *obj) { - uint32_t count; CPUState *cpu =3D CPU(obj); CPUClass *cc =3D CPU_GET_CLASS(obj); =20 @@ -395,18 +394,11 @@ static void cpu_common_initfn(Object *obj) QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); =20 - count =3D trace_get_vcpu_event_count(); - if (count) { - cpu->trace_dstate =3D bitmap_new(count); - } - cpu_exec_initfn(cpu); } =20 static void cpu_common_finalize(Object *obj) { - CPUState *cpu =3D CPU(obj); - g_free(cpu->trace_dstate); } =20 static int64_t cpu_common_get_arch_id(CPUState *cpu) diff --git a/trace/control.c b/trace/control.c index f5fb11d..82d8989 100644 --- a/trace/control.c +++ b/trace/control.c @@ -65,8 +65,15 @@ void trace_event_register_group(TraceEvent **events) size_t i; for (i =3D 0; events[i] !=3D NULL; i++) { events[i]->id =3D next_id++; - if (events[i]->vcpu_id !=3D TRACE_VCPU_EVENT_NONE) { + if (events[i]->vcpu_id =3D=3D TRACE_VCPU_EVENT_NONE) { + continue; + } + + if (likely(next_vcpu_id < CPU_TRACE_DSTATE_MAX_EVENTS)) { events[i]->vcpu_id =3D next_vcpu_id++; + } else { + error_report("WARNING: too many vcpu trace events; dropping '%= s'", + events[i]->name); } } event_groups =3D g_renew(TraceEventGroup, event_groups, nevent_groups = + 1); --=20 2.9.4 From nobody Mon May 6 17:25:39 2024 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 From nobody Mon May 6 17:25:39 2024 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 1500293705215576.1503853507561; Mon, 17 Jul 2017 05:15:05 -0700 (PDT) Received: from localhost ([::1]:50008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4vV-00059u-Ld for importer@patchew.org; Mon, 17 Jul 2017 08:15:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4sM-0002Ub-Ls for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX4sJ-00071k-WF for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57376) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX4sJ-0006zy-N6 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:43 -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 B40127DCD8; Mon, 17 Jul 2017 12:11:42 +0000 (UTC) Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 384955C54A; Mon, 17 Jul 2017 12:11:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B40127DCD8 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 B40127DCD8 From: Stefan Hajnoczi To: Date: Mon, 17 Jul 2017 13:11:23 +0100 Message-Id: <20170717121127.25154-4-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:42 +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 3/7] exec: [tcg] Use different TBs according to the vCPU's dynamic tracing state 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 Every vCPU now uses a separate set of TBs for each set of dynamic tracing event state values. Each set of TBs can be used by any number of vCPUs to maximize TB reuse when vCPUs have the same tracing state. This feature is later used by tracetool to optimize tracing of guest code events. The maximum number of TB sets is defined as 2^E, where E is the number of events that have the 'vcpu' property (their state is stored in CPUState->trace_dstate). For this to work, a change on the dynamic tracing state of a vCPU will force it to flush its virtual TB cache (which is only indexed by address), and fall back to the physical TB cache (which now contains the vCPU's dynamic tracing state as part of the hashing function). Signed-off-by: Llu=C3=ADs Vilanova Reviewed-by: Richard Henderson Reviewed-by: Emilio G. Cota Signed-off-by: Emilio G. Cota Message-id: 149915775266.6295.10060144081246467690.stgit@frigg.lan Signed-off-by: Stefan Hajnoczi --- include/exec/exec-all.h | 3 +++ include/exec/tb-hash-xx.h | 7 +++++-- include/exec/tb-hash.h | 5 +++-- trace/control.h | 3 +++ accel/tcg/cpu-exec.c | 8 ++++++-- accel/tcg/translate-all.c | 11 +++++++++-- tcg/tcg-runtime.c | 3 ++- tests/qht-bench.c | 2 +- trace/control-target.c | 1 + 9 files changed, 33 insertions(+), 10 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index bf8da2a..c09b365 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -330,6 +330,9 @@ struct TranslationBlock { #define CF_USE_ICOUNT 0x20000 #define CF_IGNORE_ICOUNT 0x40000 /* Do not generate icount code */ =20 + /* Per-vCPU dynamic tracing state used to generate this TB */ + uint32_t trace_vcpu_dstate; + uint16_t invalid; =20 void *tc_ptr; /* pointer to the translated code */ diff --git a/include/exec/tb-hash-xx.h b/include/exec/tb-hash-xx.h index 2c40b5c..6cd3022 100644 --- a/include/exec/tb-hash-xx.h +++ b/include/exec/tb-hash-xx.h @@ -49,7 +49,7 @@ * contiguous in memory. */ static inline -uint32_t tb_hash_func5(uint64_t a0, uint64_t b0, uint32_t e) +uint32_t tb_hash_func6(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f) { uint32_t v1 =3D TB_HASH_XX_SEED + PRIME32_1 + PRIME32_2; uint32_t v2 =3D TB_HASH_XX_SEED + PRIME32_2; @@ -78,11 +78,14 @@ uint32_t tb_hash_func5(uint64_t a0, uint64_t b0, uint32= _t e) v4 *=3D PRIME32_1; =20 h32 =3D rol32(v1, 1) + rol32(v2, 7) + rol32(v3, 12) + rol32(v4, 18); - h32 +=3D 20; + h32 +=3D 24; =20 h32 +=3D e * PRIME32_3; h32 =3D rol32(h32, 17) * PRIME32_4; =20 + h32 +=3D f * PRIME32_3; + h32 =3D rol32(h32, 17) * PRIME32_4; + h32 ^=3D h32 >> 15; h32 *=3D PRIME32_2; h32 ^=3D h32 >> 13; diff --git a/include/exec/tb-hash.h b/include/exec/tb-hash.h index b1fe2d0..17b5ee0 100644 --- a/include/exec/tb-hash.h +++ b/include/exec/tb-hash.h @@ -58,9 +58,10 @@ static inline unsigned int tb_jmp_cache_hash_func(target= _ulong pc) #endif /* CONFIG_SOFTMMU */ =20 static inline -uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t fl= ags) +uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t fl= ags, + uint32_t trace_vcpu_dstate) { - return tb_hash_func5(phys_pc, pc, flags); + return tb_hash_func6(phys_pc, pc, flags, trace_vcpu_dstate); } =20 #endif diff --git a/trace/control.h b/trace/control.h index 4ea53e2..b931824 100644 --- a/trace/control.h +++ b/trace/control.h @@ -165,6 +165,9 @@ void trace_event_set_state_dynamic(TraceEvent *ev, bool= state); * Set the dynamic tracing state of an event for the given vCPU. * * Pre-condition: trace_event_get_vcpu_state_static(ev) =3D=3D true + * + * Note: Changes for execution-time events with the 'tcg' property will no= t be + * propagated until the next TB is executed (iff executing in TCG mo= de). */ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev, bool state); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 3581618..d84b01d 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -280,6 +280,7 @@ struct tb_desc { CPUArchState *env; tb_page_addr_t phys_page1; uint32_t flags; + uint32_t trace_vcpu_dstate; }; =20 static bool tb_cmp(const void *p, const void *d) @@ -291,6 +292,7 @@ static bool tb_cmp(const void *p, const void *d) tb->page_addr[0] =3D=3D desc->phys_page1 && tb->cs_base =3D=3D desc->cs_base && tb->flags =3D=3D desc->flags && + tb->trace_vcpu_dstate =3D=3D desc->trace_vcpu_dstate && !atomic_read(&tb->invalid)) { /* check next page if needed */ if (tb->page_addr[1] =3D=3D -1) { @@ -319,10 +321,11 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, tar= get_ulong pc, desc.env =3D (CPUArchState *)cpu->env_ptr; desc.cs_base =3D cs_base; desc.flags =3D flags; + desc.trace_vcpu_dstate =3D *cpu->trace_dstate; desc.pc =3D pc; phys_pc =3D get_page_addr_code(desc.env, pc); desc.phys_page1 =3D phys_pc & TARGET_PAGE_MASK; - h =3D tb_hash_func(phys_pc, pc, flags); + h =3D tb_hash_func(phys_pc, pc, flags, *cpu->trace_dstate); return qht_lookup(&tcg_ctx.tb_ctx.htable, tb_cmp, &desc, h); } =20 @@ -342,7 +345,8 @@ static inline TranslationBlock *tb_find(CPUState *cpu, cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); tb =3D atomic_rcu_read(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]); if (unlikely(!tb || tb->pc !=3D pc || tb->cs_base !=3D cs_base || - tb->flags !=3D flags)) { + tb->flags !=3D flags || + tb->trace_vcpu_dstate !=3D *cpu->trace_dstate)) { tb =3D tb_htable_lookup(cpu, pc, cs_base, flags); if (!tb) { =20 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4e1831c..090ebad 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -54,6 +54,7 @@ #include "exec/tb-hash.h" #include "translate-all.h" #include "qemu/bitmap.h" +#include "qemu/error-report.h" #include "qemu/timer.h" #include "qemu/main-loop.h" #include "exec/log.h" @@ -112,6 +113,11 @@ typedef struct PageDesc { #define V_L2_BITS 10 #define V_L2_SIZE (1 << V_L2_BITS) =20 +/* Make sure all possible CPU event bits fit in tb->trace_vcpu_dstate */ +QEMU_BUILD_BUG_ON(CPU_TRACE_DSTATE_MAX_EVENTS > + sizeof(((TranslationBlock *)0)->trace_vcpu_dstate) + * BITS_PER_BYTE); + /* * L1 Mapping properties */ @@ -1071,7 +1077,7 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page= _addr_t page_addr) =20 /* remove the TB from the hash list */ phys_pc =3D tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); - h =3D tb_hash_func(phys_pc, tb->pc, tb->flags); + h =3D tb_hash_func(phys_pc, tb->pc, tb->flags, tb->trace_vcpu_dstate); qht_remove(&tcg_ctx.tb_ctx.htable, tb, h); =20 /* remove the TB from the page list */ @@ -1216,7 +1222,7 @@ static void tb_link_page(TranslationBlock *tb, tb_pag= e_addr_t phys_pc, } =20 /* add in the hash table */ - h =3D tb_hash_func(phys_pc, tb->pc, tb->flags); + h =3D tb_hash_func(phys_pc, tb->pc, tb->flags, tb->trace_vcpu_dstate); qht_insert(&tcg_ctx.tb_ctx.htable, tb, h); =20 #ifdef DEBUG_TB_CHECK @@ -1262,6 +1268,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb->cs_base =3D cs_base; tb->flags =3D flags; tb->cflags =3D cflags; + tb->trace_vcpu_dstate =3D *cpu->trace_dstate; tb->invalid =3D false; =20 #ifdef CONFIG_PROFILER diff --git a/tcg/tcg-runtime.c b/tcg/tcg-runtime.c index ec3a34e..3e23649 100644 --- a/tcg/tcg-runtime.c +++ b/tcg/tcg-runtime.c @@ -158,7 +158,8 @@ void *HELPER(lookup_tb_ptr)(CPUArchState *env, target_u= long addr) if (unlikely(!(tb && tb->pc =3D=3D addr && tb->cs_base =3D=3D cs_base - && tb->flags =3D=3D flags))) { + && tb->flags =3D=3D flags + && tb->trace_vcpu_dstate =3D=3D *cpu->trace_dstate))) { tb =3D tb_htable_lookup(cpu, addr, cs_base, flags); if (!tb) { return tcg_ctx.code_gen_epilogue; diff --git a/tests/qht-bench.c b/tests/qht-bench.c index 2afa09d..11c1cec 100644 --- a/tests/qht-bench.c +++ b/tests/qht-bench.c @@ -103,7 +103,7 @@ static bool is_equal(const void *obj, const void *userp) =20 static inline uint32_t h(unsigned long v) { - return tb_hash_func5(v, 0, 0); + return tb_hash_func6(v, 0, 0, 0); } =20 /* diff --git a/trace/control-target.c b/trace/control-target.c index 31c2ed1..4e36101 100644 --- a/trace/control-target.c +++ b/trace/control-target.c @@ -66,6 +66,7 @@ static void trace_event_synchronize_vcpu_state_dynamic( { bitmap_copy(vcpu->trace_dstate, vcpu->trace_dstate_delayed, CPU_TRACE_DSTATE_MAX_EVENTS); + cpu_tb_jmp_cache_clear(vcpu); } =20 void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, --=20 2.9.4 From nobody Mon May 6 17:25:39 2024 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 150029371791645.400514217308114; Mon, 17 Jul 2017 05:15:17 -0700 (PDT) Received: from localhost ([::1]:50010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4vh-0005Kt-LS for importer@patchew.org; Mon, 17 Jul 2017 08:15:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4sN-0002V4-8a for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX4sL-00073E-W2 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX4sL-00072r-N4 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA3E3C049D59; Mon, 17 Jul 2017 12:11:44 +0000 (UTC) Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4438A173BD; Mon, 17 Jul 2017 12:11:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BA3E3C049D59 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BA3E3C049D59 From: Stefan Hajnoczi To: Date: Mon, 17 Jul 2017 13:11:24 +0100 Message-Id: <20170717121127.25154-5-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 17 Jul 2017 12:11:44 +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 4/7] trace: [tcg] Do not generate TCG code to trace dynamically-disabled events 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 If an event is dynamically disabled, the TCG code that calls the execution-time tracer is not generated. Removes the overheads of execution-time tracers for dynamically disabled events. As a bonus, also avoids checking the event state when the execution-time tracer is called from TCG-generated code (since otherwise TCG would simply not call it). Signed-off-by: Llu=C3=ADs Vilanova Signed-off-by: Emilio G. Cota Message-id: 149915799921.6295.13067154430923434035.stgit@frigg.lan Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/__init__.py | 3 ++- scripts/tracetool/format/h.py | 26 +++++++++++++++++++------- scripts/tracetool/format/tcg_h.py | 21 +++++++++++++++++---- scripts/tracetool/format/tcg_helper_c.py | 5 +++-- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 1ffbc1d..d4c204a 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -6,7 +6,7 @@ Machinery for generating tracing-related intermediate files. """ =20 __author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2016, Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2017, Llu=C3=ADs Vilanova " __license__ =3D "GPL version 2 or (at your option) any later version" =20 __maintainer__ =3D "Stefan Hajnoczi" @@ -268,6 +268,7 @@ class Event(object): return self._FMT.findall(self.fmt) =20 QEMU_TRACE =3D "trace_%(name)s" + QEMU_TRACE_NOCHECK =3D "_nocheck__" + QEMU_TRACE QEMU_TRACE_TCG =3D QEMU_TRACE + "_tcg" QEMU_DSTATE =3D "_TRACE_%(NAME)s_DSTATE" QEMU_EVENT =3D "_TRACE_%(NAME)s_EVENT" diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index 3682f4e..aecf249 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -6,7 +6,7 @@ trace/generated-tracers.h """ =20 __author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2016, Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2017, Llu=C3=ADs Vilanova " __license__ =3D "GPL version 2 or (at your option) any later version" =20 __maintainer__ =3D "Stefan Hajnoczi" @@ -49,6 +49,19 @@ def generate(events, backend, group): backend.generate_begin(events, group) =20 for e in events: + # tracer without checks + out('', + 'static inline void %(api)s(%(args)s)', + '{', + api=3De.api(e.QEMU_TRACE_NOCHECK), + args=3De.args) + + if "disable" not in e.properties: + backend.generate(e, group) + + out('}') + + # tracer wrapper with checks (per-vCPU tracing) if "vcpu" in e.properties: trace_cpu =3D next(iter(e.args))[1] cond =3D "trace_event_get_vcpu_state(%(cpu)s,"\ @@ -63,16 +76,15 @@ def generate(events, backend, group): 'static inline void %(api)s(%(args)s)', '{', ' if (%(cond)s) {', + ' %(api_nocheck)s(%(names)s);', + ' }', + '}', api=3De.api(), + api_nocheck=3De.api(e.QEMU_TRACE_NOCHECK), args=3De.args, + names=3D", ".join(e.args.names()), cond=3Dcond) =20 - if "disable" not in e.properties: - backend.generate(e, group) - - out(' }', - '}') - backend.generate_end(events, group) =20 out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group.upper()) diff --git a/scripts/tracetool/format/tcg_h.py b/scripts/tracetool/format/t= cg_h.py index db55f52..1651cc3 100644 --- a/scripts/tracetool/format/tcg_h.py +++ b/scripts/tracetool/format/tcg_h.py @@ -6,7 +6,7 @@ Generate .h file for TCG code generation. """ =20 __author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2016, Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2017, Llu=C3=ADs Vilanova " __license__ =3D "GPL version 2 or (at your option) any later version" =20 __maintainer__ =3D "Stefan Hajnoczi" @@ -46,7 +46,7 @@ def generate(events, backend, group): =20 for e in events: # just keep one of them - if "tcg-trans" not in e.properties: + if "tcg-exec" not in e.properties: continue =20 out('static inline void %(name_tcg)s(%(args)s)', @@ -58,12 +58,25 @@ def generate(events, backend, group): args_trans =3D e.original.event_trans.args args_exec =3D tracetool.vcpu.transform_args( "tcg_helper_c", e.original.event_exec, "wrapper") + if "vcpu" in e.properties: + trace_cpu =3D e.args.names()[0] + cond =3D "trace_event_get_vcpu_state(%(cpu)s,"\ + " TRACE_%(id)s)"\ + % dict( + cpu=3Dtrace_cpu, + id=3De.original.event_exec.name.upper()) + else: + cond =3D "true" + out(' %(name_trans)s(%(argnames_trans)s);', - ' gen_helper_%(name_exec)s(%(argnames_exec)s);', + ' if (%(cond)s) {', + ' gen_helper_%(name_exec)s(%(argnames_exec)s);', + ' }', name_trans=3De.original.event_trans.api(e.QEMU_TRACE), name_exec=3De.original.event_exec.api(e.QEMU_TRACE), argnames_trans=3D", ".join(args_trans.names()), - argnames_exec=3D", ".join(args_exec.names())) + argnames_exec=3D", ".join(args_exec.names()), + cond=3Dcond) =20 out('}') =20 diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool/f= ormat/tcg_helper_c.py index ec7acbe..bbbd6ad 100644 --- a/scripts/tracetool/format/tcg_helper_c.py +++ b/scripts/tracetool/format/tcg_helper_c.py @@ -6,7 +6,7 @@ Generate trace/generated-helpers.c. """ =20 __author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2016, Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2017, Llu=C3=ADs Vilanova " __license__ =3D "GPL version 2 or (at your option) any later version" =20 __maintainer__ =3D "Stefan Hajnoczi" @@ -71,10 +71,11 @@ def generate(events, backend, group): =20 out('void %(name_tcg)s(%(args_api)s)', '{', + # NOTE: the check was already performed at TCG-generation time ' %(name)s(%(args_call)s);', '}', name_tcg=3D"helper_%s_proxy" % e.api(), - name=3De.api(), + name=3De.api(e.QEMU_TRACE_NOCHECK), args_api=3De_args_api, args_call=3D", ".join(e_args_call.casted()), ) --=20 2.9.4 From nobody Mon May 6 17:25:39 2024 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 1500293852002329.6484118267347; Mon, 17 Jul 2017 05:17:32 -0700 (PDT) Received: from localhost ([::1]:50022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4xr-0006zT-Dt for importer@patchew.org; Mon, 17 Jul 2017 08:17:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4sP-0002XF-K5 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX4sO-00074l-1p for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX4sN-000744-Of for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:47 -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 C5BFFC0467D8; Mon, 17 Jul 2017 12:11:46 +0000 (UTC) Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FC145C54A; Mon, 17 Jul 2017 12:11:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C5BFFC0467D8 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C5BFFC0467D8 From: Stefan Hajnoczi To: Date: Mon, 17 Jul 2017 13:11:25 +0100 Message-Id: <20170717121127.25154-6-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.31]); Mon, 17 Jul 2017 12:11:46 +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 5/7] trace: [tcg, trivial] Re-align generated code 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 Last patch removed a nesting level in generated code. Re-align all code generated by backends to be 4-column aligned. Signed-off-by: Llu=C3=ADs Vilanova Signed-off-by: Emilio G. Cota Message-id: 149915824586.6295.17820926011082409033.stgit@frigg.lan Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/backend/dtrace.py | 4 ++-- scripts/tracetool/backend/ftrace.py | 20 ++++++++++---------- scripts/tracetool/backend/log.py | 19 ++++++++++--------- scripts/tracetool/backend/simple.py | 4 ++-- scripts/tracetool/backend/syslog.py | 6 +++--- scripts/tracetool/backend/ust.py | 4 ++-- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backen= d/dtrace.py index c469cbd..c6812b7 100644 --- a/scripts/tracetool/backend/dtrace.py +++ b/scripts/tracetool/backend/dtrace.py @@ -6,7 +6,7 @@ DTrace/SystemTAP backend. """ =20 __author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2016, Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2017, Llu=C3=ADs Vilanova " __license__ =3D "GPL version 2 or (at your option) any later version" =20 __maintainer__ =3D "Stefan Hajnoczi" @@ -46,6 +46,6 @@ def generate_h_begin(events, group): =20 =20 def generate_h(event, group): - out(' QEMU_%(uppername)s(%(argnames)s);', + out(' QEMU_%(uppername)s(%(argnames)s);', uppername=3Devent.name.upper(), argnames=3D", ".join(event.args.names())) diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index db9fe7a..dd0eda4 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -29,17 +29,17 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - out(' {', - ' char ftrace_buf[MAX_TRACE_STRLEN];', - ' int unused __attribute__ ((unused));', - ' int trlen;', - ' if (trace_event_get_state(%(event_id)s)) {', - ' trlen =3D snprintf(ftrace_buf, MAX_TRACE_STRLEN,', - ' "%(name)s " %(fmt)s "\\n" %(argn= ames)s);', - ' trlen =3D MIN(trlen, MAX_TRACE_STRLEN - 1);', - ' unused =3D write(trace_marker_fd, ftrace_buf, trl= en);', - ' }', + out(' {', + ' char ftrace_buf[MAX_TRACE_STRLEN];', + ' int unused __attribute__ ((unused));', + ' int trlen;', + ' if (trace_event_get_state(%(event_id)s)) {', + ' trlen =3D snprintf(ftrace_buf, MAX_TRACE_STRLEN,', + ' "%(name)s " %(fmt)s "\\n" %(argnames= )s);', + ' trlen =3D MIN(trlen, MAX_TRACE_STRLEN - 1);', + ' unused =3D write(trace_marker_fd, ftrace_buf, trlen);= ', ' }', + ' }', name=3Devent.name, args=3Devent.args, event_id=3D"TRACE_" + event.name.upper(), diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index 4f4a4d3..54f0a69 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -6,7 +6,7 @@ Stderr built-in backend. """ =20 __author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2016, Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2017, Llu=C3=ADs Vilanova " __license__ =3D "GPL version 2 or (at your option) any later version" =20 __maintainer__ =3D "Stefan Hajnoczi" @@ -35,14 +35,15 @@ def generate_h(event, group): else: cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.uppe= r()) =20 - out(' if (%(cond)s) {', - ' struct timeval _now;', - ' gettimeofday(&_now, NULL);', - ' qemu_log_mask(LOG_TRACE, "%%d@%%zd.%%06zd:%(name)s " = %(fmt)s "\\n",', - ' getpid(),', - ' (size_t)_now.tv_sec, (size_t)_now.tv_us= ec', - ' %(argnames)s);', - ' }', + out(' if (%(cond)s) {', + ' struct timeval _now;', + ' gettimeofday(&_now, NULL);', + ' qemu_log_mask(LOG_TRACE,', + ' "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', + ' getpid(),', + ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', + ' %(argnames)s);', + ' }', cond=3Dcond, name=3Devent.name, fmt=3Devent.fmt.rstrip("\n"), diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backen= d/simple.py index 4acc06e..f983670 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -6,7 +6,7 @@ Simple built-in backend. """ =20 __author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2014, Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2017, Llu=C3=ADs Vilanova " __license__ =3D "GPL version 2 or (at your option) any later version" =20 __maintainer__ =3D "Stefan Hajnoczi" @@ -37,7 +37,7 @@ def generate_h_begin(events, group): =20 =20 def generate_h(event, group): - out(' _simple_%(api)s(%(args)s);', + out(' _simple_%(api)s(%(args)s);', api=3Devent.api(), args=3D", ".join(event.args.names())) =20 diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backen= d/syslog.py index b8ff279..1ce627f 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -35,9 +35,9 @@ def generate_h(event, group): else: cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.uppe= r()) =20 - out(' if (%(cond)s) {', - ' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);', - ' }', + out(' if (%(cond)s) {', + ' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);', + ' }', cond=3Dcond, name=3Devent.name, fmt=3Devent.fmt.rstrip("\n"), diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/u= st.py index 52ce892..2adaf54 100644 --- a/scripts/tracetool/backend/ust.py +++ b/scripts/tracetool/backend/ust.py @@ -6,7 +6,7 @@ LTTng User Space Tracing backend. """ =20 __author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2016, Llu=C3=ADs Vilanova " +__copyright__ =3D "Copyright 2012-2017, Llu=C3=ADs Vilanova " __license__ =3D "GPL version 2 or (at your option) any later version" =20 __maintainer__ =3D "Stefan Hajnoczi" @@ -35,6 +35,6 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - out(' tracepoint(qemu, %(name)s%(tp_args)s);', + out(' tracepoint(qemu, %(name)s%(tp_args)s);', name=3Devent.name, tp_args=3Dargnames) --=20 2.9.4 From nobody Mon May 6 17:25:39 2024 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 1500293825977539.3078585867805; Mon, 17 Jul 2017 05:17:05 -0700 (PDT) Received: from localhost ([::1]:50021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4xO-0006fN-EA for importer@patchew.org; Mon, 17 Jul 2017 08:16:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4sW-0002dV-BA for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX4sS-0007Eo-R3 for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37352) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX4sS-0007CT-Gs for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F94A80460; Mon, 17 Jul 2017 12:11:51 +0000 (UTC) Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D14C70958; Mon, 17 Jul 2017 12:11:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7F94A80460 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7F94A80460 From: Stefan Hajnoczi To: Date: Mon, 17 Jul 2017 13:11:26 +0100 Message-Id: <20170717121127.25154-7-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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 17 Jul 2017 12:11:51 +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 6/7] trace: [trivial] Statically enable all guest events 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 The existing optimizations makes it feasible to have them available on all builds. Some quick'n'dirty numbers with 400.perlbench (SPECcpu2006) on the train in= put (medium size - suns.pl) and the guest_mem_before event: * vanilla, statically disabled real 0m2,259s user 0m2,252s sys 0m0,004s * vanilla, statically enabled (overhead: 2.18x) real 0m4,921s user 0m4,912s sys 0m0,008s * multi-tb, statically disabled (overhead: 0.99x) [within noise range] real 0m2,228s user 0m2,216s sys 0m0,008s * multi-tb, statically enabled (overhead: 0.99x) [within noise range] real 0m2,229s user 0m2,224s sys 0m0,004s Now enabling all events when booting an ARM system that immediately shuts d= own (https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg04085.html): * vanilla, statically disabled real 0m32,153s user 0m31,276s sys 0m0,108s * vanilla, statically enabled (overhead: 1.35x) real 0m43,507s user 0m42,680s sys 0m0,168s * multi-tb, statically disabled (overhead: 1.03x) real 0m32,993s user 0m32,516s sys 0m0,104s * multi-tb, statically enabled (overhead: 1.00x) [within noise range] real 0m32,110s user 0m31,176s sys 0m0,156s And finally enabling all events using Emilio's dbt-bench (where orig =3D=3D vanilla, new =3D=3D multi-tb): NBench score; highe= r is better 180 +-+--------+----------+----------+---------+----------+----------+---= -------+----------+----------+---------+----------+--------+-+ | = | | *** $$$$%% = orig | 160 +-+....................................*.*.$..$.%....................= ........................................orig-enabled +-+ | * * $ $ % = new | 140 +-+....................................*.*.$..$.%....................= ........................................new-disabled.......+-+ | * * $ $ % = | | * * $ $ % = | 120 +-+....................................*.*.$..$.%....................= ...........................................................+-+ | * * $ $ % = | | * * $ $ % = | 100 +-+....................................*.*.$..$.%.....$$$%%%.........= ...........................................................+-+ | * * $ $ % *** $ $ % *** $$$%= % | 80 +-+....................................*.*.$..$.%.*.*.$.$..%.*.*.$.$.= %..........................................................+-+ | * * $ $ % * * $ $ % * * $ $ = % | | * * $ $ % * * $ $ % * * $ $ = % | 60 +-+.........................***..$$$%%.*.*##..$.%.*.*.$.$..%.*.*.$.$.= %..***.$$$%%...............................................+-+ | **** $$$%% * * $ $ % * * # $ % * *## $ % * * $ $ = % * * $ $ % | | * * $ $ % * * $ $ % * * # $ % * * # $ % * *## $ = % * * $ $ % | 40 +-+..............*..*.$.$.%.*.*..$.$.%.*.*.#..$.%.*.*.#.$..%.*.*.#.$.= %..*.*.$.$.%...............................................+-+ | * * $ $ % * * $ $ % * * # $ % * * # $ % * * # $ = % * *## $ % *** $$$%%% | 20 +-+....***.$$$%%.*..*##.$.%.*.*###.$.%.*.*.#..$.%.*.*.#.$..%.*.*.#.$.= %..*.*.#.$.%..................................*.*.$.$..%...+-+ | * *## $ % * * # $ % * * # $ % * * # $ % * * # $ % * * # $ = % * * # $ % * *## $ % | | * * # $ % * * # $ % * * # $ % * * # $ % * * # $ % * * # $ = % * * # $ % ***###$$%% ***##$$$%% * * # $ % | 0 +-+----***##$$%%-****##$$%%-***###$$%%-***##$$$%%-***##$$%%%-***##$$%= %--***##$$%%-****##$$%%-***###$$%%-***##$$$%%-***##$$%%%---+-+ NUMERIC SORTSTRING SORT BITFIEFP EMULATION ASSIGNMENT IDEA = HUFFMAN FOURIER NEURLU DECOMPOSITION gmean png: http://imgur.com/a/8XG5S Signed-off-by: Llu=C3=ADs Vilanova Reviewed-by: Emilio G. Cota Signed-off-by: Emilio G. Cota Message-id: 149915849243.6295.4484103824675839071.stgit@frigg.lan Signed-off-by: Stefan Hajnoczi --- trace-events | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trace-events b/trace-events index bae63fd..f9dbd7f 100644 --- a/trace-events +++ b/trace-events @@ -106,7 +106,7 @@ vcpu guest_cpu_reset(void) # # Mode: user, softmmu # Targets: TCG(all) -disable vcpu tcg guest_mem_before(TCGv vaddr, uint8_t info) "info=3D%d", "= vaddr=3D0x%016"PRIx64" info=3D%d" +vcpu tcg guest_mem_before(TCGv vaddr, uint8_t info) "info=3D%d", "vaddr=3D= 0x%016"PRIx64" info=3D%d" =20 # @num: System call number. # @arg*: System call argument value. @@ -115,7 +115,7 @@ disable vcpu tcg guest_mem_before(TCGv vaddr, uint8_t i= nfo) "info=3D%d", "vaddr=3D0x # # Mode: user # Targets: TCG(all) -disable vcpu guest_user_syscall(uint64_t num, uint64_t arg1, uint64_t arg2= , uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t arg7= , uint64_t arg8) "num=3D0x%016"PRIx64" arg1=3D0x%016"PRIx64" arg2=3D0x%016"= PRIx64" arg3=3D0x%016"PRIx64" arg4=3D0x%016"PRIx64" arg5=3D0x%016"PRIx64" a= rg6=3D0x%016"PRIx64" arg7=3D0x%016"PRIx64" arg8=3D0x%016"PRIx64 +vcpu guest_user_syscall(uint64_t num, uint64_t arg1, uint64_t arg2, uint64= _t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t arg7, uint64= _t arg8) "num=3D0x%016"PRIx64" arg1=3D0x%016"PRIx64" arg2=3D0x%016"PRIx64" = arg3=3D0x%016"PRIx64" arg4=3D0x%016"PRIx64" arg5=3D0x%016"PRIx64" arg6=3D0x= %016"PRIx64" arg7=3D0x%016"PRIx64" arg8=3D0x%016"PRIx64 =20 # @num: System call number. # @ret: System call result value. @@ -124,4 +124,4 @@ disable vcpu guest_user_syscall(uint64_t num, uint64_t = arg1, uint64_t arg2, uint # # Mode: user # Targets: TCG(all) -disable vcpu guest_user_syscall_ret(uint64_t num, uint64_t ret) "num=3D0x%= 016"PRIx64" ret=3D0x%016"PRIx64 +vcpu guest_user_syscall_ret(uint64_t num, uint64_t ret) "num=3D0x%016"PRIx= 64" ret=3D0x%016"PRIx64 --=20 2.9.4 From nobody Mon May 6 17:25:39 2024 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 1500293705716575.5627832125141; Mon, 17 Jul 2017 05:15:05 -0700 (PDT) Received: from localhost ([::1]:50009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4vW-0005Ax-EF for importer@patchew.org; Mon, 17 Jul 2017 08:15:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX4sX-0002eK-BF for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX4sW-0007OH-Gc for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dX4sW-0007Lg-Ae for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:11:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D0C87CB88; Mon, 17 Jul 2017 12:11:55 +0000 (UTC) Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6C56173BD; Mon, 17 Jul 2017 12:11:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D0C87CB88 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D0C87CB88 From: Stefan Hajnoczi To: Date: Mon, 17 Jul 2017 13:11:27 +0100 Message-Id: <20170717121127.25154-8-stefanha@redhat.com> In-Reply-To: <20170717121127.25154-1-stefanha@redhat.com> References: <20170717121127.25154-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 17 Jul 2017 12:11:55 +0000 (UTC) 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 7/7] trace: update old trace events in docs 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 , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit c5f1ad429cdf26023cf331075a7d327708e3db6d ("block: Remove bdrv_aio_readv/writev/flush()") removed bdrv_aio_readv()/bdrv_aio_writev() so the example in the tracing documentation is no longer valid. Reported-by: Wang Dong Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake Message-id: 20170714133111.27359-1-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- docs/devel/tracing.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/devel/tracing.txt b/docs/devel/tracing.txt index 8c0029b..5768a0b 100644 --- a/docs/devel/tracing.txt +++ b/docs/devel/tracing.txt @@ -14,8 +14,7 @@ for debugging, profiling, and observing execution. =20 2. Create a file with the events you want to trace: =20 - echo bdrv_aio_readv > /tmp/events - echo bdrv_aio_writev >> /tmp/events + echo memory_region_ops_read >/tmp/events =20 3. Run the virtual machine to produce a trace file: =20 --=20 2.9.4