From patchwork Fri Jan 13 20:48:41 2017 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: 9516379 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 D85D460761 for ; Fri, 13 Jan 2017 20:50:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C752A28580 for ; Fri, 13 Jan 2017 20:50:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B899828776; Fri, 13 Jan 2017 20:50:03 +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 EDDD028580 for ; Fri, 13 Jan 2017 20:50:02 +0000 (UTC) Received: from localhost ([::1]:45163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cS8nS-00081y-2o for patchwork-qemu-devel@patchwork.kernel.org; Fri, 13 Jan 2017 15:50:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cS8mD-0007Ra-De for qemu-devel@nongnu.org; Fri, 13 Jan 2017 15:48:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cS8mB-00063y-T2 for qemu-devel@nongnu.org; Fri, 13 Jan 2017 15:48:45 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:49720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cS8mB-00063O-GM for qemu-devel@nongnu.org; Fri, 13 Jan 2017 15:48:43 -0500 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 v0DKmhTB027525; Fri, 13 Jan 2017 21:48:43 +0100 Received: from localhost (72.red-2-138-226.dynamicip.rima-tde.net [2.138.226.72]) by gw-3.ac.upc.es (Postfix) with ESMTPSA id 4AAE53D2; Fri, 13 Jan 2017 21:48:42 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Fri, 13 Jan 2017 21:48:41 +0100 Message-Id: <148434052149.31446.3343314758905711046.stgit@frigg.lan> X-Mailer: git-send-email 2.11.0 In-Reply-To: <148434048970.31446.17153056211582691244.stgit@frigg.lan> References: <148434048970.31446.17153056211582691244.stgit@frigg.lan> 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 v0DKmhTB027525 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH v7 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: Eduardo Habkost , Stefan Hajnoczi , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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ís Vilanova --- 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 365446fa53..5f1576539e 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -6,7 +6,7 @@ Machinery for generating tracing-related intermediate files. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012-2016, Lluís Vilanova " +__copyright__ = "Copyright 2012-2017, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -264,6 +264,7 @@ class Event(object): return self._FMT.findall(self.fmt) QEMU_TRACE = "trace_%(name)s" + QEMU_TRACE_NOCHECK = "_nocheck__" + QEMU_TRACE QEMU_TRACE_TCG = QEMU_TRACE + "_tcg" QEMU_DSTATE = "_TRACE_%(NAME)s_DSTATE" QEMU_EVENT = "_TRACE_%(NAME)s_EVENT" diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index 3682f4e6a8..aecf249d66 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -6,7 +6,7 @@ trace/generated-tracers.h """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012-2016, Lluís Vilanova " +__copyright__ = "Copyright 2012-2017, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -49,6 +49,19 @@ def generate(events, backend, group): backend.generate_begin(events, group) for e in events: + # tracer without checks + out('', + 'static inline void %(api)s(%(args)s)', + '{', + api=e.api(e.QEMU_TRACE_NOCHECK), + args=e.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 = next(iter(e.args))[1] cond = "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=e.api(), + api_nocheck=e.api(e.QEMU_TRACE_NOCHECK), args=e.args, + names=", ".join(e.args.names()), cond=cond) - if "disable" not in e.properties: - backend.generate(e, group) - - out(' }', - '}') - backend.generate_end(events, group) out('#endif /* TRACE_%s_GENERATED_TRACERS_H */' % group.upper()) diff --git a/scripts/tracetool/format/tcg_h.py b/scripts/tracetool/format/tcg_h.py index 5f213f6cba..9a73b5b268 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. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012-2016, Lluís Vilanova " +__copyright__ = "Copyright 2012-2017, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -41,7 +41,7 @@ def generate(events, backend, group): for e in events: # just keep one of them - if "tcg-trans" not in e.properties: + if "tcg-exec" not in e.properties: continue out('static inline void %(name_tcg)s(%(args)s)', @@ -53,12 +53,25 @@ def generate(events, backend, group): args_trans = e.original.event_trans.args args_exec = tracetool.vcpu.transform_args( "tcg_helper_c", e.original.event_exec, "wrapper") + if "vcpu" in e.properties: + trace_cpu = e.args.names()[0] + cond = "trace_event_get_vcpu_state(%(cpu)s,"\ + " TRACE_%(id)s)"\ + % dict( + cpu=trace_cpu, + id=e.original.event_exec.name.upper()) + else: + cond = "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=e.original.event_trans.api(e.QEMU_TRACE), name_exec=e.original.event_exec.api(e.QEMU_TRACE), argnames_trans=", ".join(args_trans.names()), - argnames_exec=", ".join(args_exec.names())) + argnames_exec=", ".join(args_exec.names()), + cond=cond) out('}') diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool/format/tcg_helper_c.py index cc26e03008..aec6dbe891 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. """ __author__ = "Lluís Vilanova " -__copyright__ = "Copyright 2012-2016, Lluís Vilanova " +__copyright__ = "Copyright 2012-2017, Lluís Vilanova " __license__ = "GPL version 2 or (at your option) any later version" __maintainer__ = "Stefan Hajnoczi" @@ -66,10 +66,11 @@ def generate(events, backend, group): 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="helper_%s_proxy" % e.api(), - name=e.api(), + name=e.api(e.QEMU_TRACE_NOCHECK), args_api=e_args_api, args_call=", ".join(e_args_call.casted()), )