From nobody Wed Nov 5 16:38:14 2025 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.zoho.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 1496975354727661.8259496722842; Thu, 8 Jun 2017 19:29:14 -0700 (PDT) Received: from localhost ([::1]:52309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJ9fk-0003V3-Vv for importer@patchew.org; Thu, 08 Jun 2017 22:29:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dJ9cC-0000Y3-4E for qemu-devel@nongnu.org; Thu, 08 Jun 2017 22:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dJ9c9-00069m-Dh for qemu-devel@nongnu.org; Thu, 08 Jun 2017 22:25:32 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:48143) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dJ9c9-00069H-7v for qemu-devel@nongnu.org; Thu, 08 Jun 2017 22:25:29 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0A5F820B3E; Thu, 8 Jun 2017 22:25:27 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Thu, 08 Jun 2017 22:25:27 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id BB8D27E7A3; Thu, 8 Jun 2017 22:25:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=YTR406Uxla0bTpZ 9r839VCl9Az6Qw09sRr6MDnU167M=; b=szIt5ldgH5XGBUwU/QWkxhTUj/plcLf s2RSAtoGJLAtY9LigqoZI2KMgfPuUpUo6ZAAsG0N1124+WotJrwDaz4q2uC1mMgw RAVZclQv3fkQAzNhPJXE6HAZc4doYWDRWg+YKKr6wXZW72ynwtoqBEoJKBdZP61T sZNRiF0fYe68= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=YTR406Uxla0bTpZ9r839VCl9Az6Qw09sRr6MDnU167M=; b=FAsv0ROr wnxurIYvfRp40L/gejcb5hID4ZnmqSbKHIIfVrVEYNxQoOuDVUXiYp4SrSNU54CQ 8BdhJ35yliqrCEQn81dJHuXoXPixLXiY5FzgpLkviXedtYhhjB568EMm9X6mfnLL cKQrtG/dx57+JnszY0IKfcZ6q8osFwkC8jTOOnvKaiyoRNIbT1MXcm9aK6bM1Qwx 8I+XFK/wOSARR7NgbCl/EszYnUTxCtXdeFkRuo6Zw51AjlePsaZJHSfv/4q2jjxQ ChGpwb2GxhKXkRkhspbXK7/CJ2WDxJSIsfG6/poO5dgAqMQ/796N2slQykSkhwha CaD+rLlO3ZxuRA== X-ME-Sender: X-Sasl-enc: l8YckeL4bnNI3jzGhhjuNXYzNnMwbrCB/N6QSk7/fYRU 1496975126 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 8 Jun 2017 22:25:20 -0400 Message-Id: <1496975122-16999-6-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496975122-16999-1-git-send-email-cota@braap.org> References: <1496975122-16999-1-git-send-email-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: 66.111.4.25 Subject: [Qemu-devel] [PATCH v8 5/7] trace: [tcg] Do not generate TCG code to trace dinamically-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: =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 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 --- 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.7.4