From patchwork Thu Sep 15 15:50:58 2016 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: 670504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3sZjtq2wyqz9sC7 for ; Fri, 16 Sep 2016 02:05:39 +1000 (AEST) Received: from localhost ([::1]:35809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkZAO-0007LZ-GK for incoming@patchwork.ozlabs.org; Thu, 15 Sep 2016 12:05:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkYwK-0003tD-Qv for qemu-devel@nongnu.org; Thu, 15 Sep 2016 11:51:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkYwG-0006b4-5O for qemu-devel@nongnu.org; Thu, 15 Sep 2016 11:51:03 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:33390 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkYwF-0006ar-Q5 for qemu-devel@nongnu.org; Thu, 15 Sep 2016 11:51:00 -0400 Received: from gw-2.ac.upc.es (gw-2.ac.upc.es [147.83.30.8]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id u8FFoxDW002272; Thu, 15 Sep 2016 17:50:59 +0200 Received: from localhost (unknown [84.88.51.85]) by gw-2.ac.upc.es (Postfix) with ESMTPSA id CEF4C80E; Thu, 15 Sep 2016 17:50:58 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Thu, 15 Sep 2016 17:50:58 +0200 Message-Id: <147395465853.2399.8315639698512911211.stgit@fimbulvetr.bsc.es> X-Mailer: git-send-email 2.9.3 In-Reply-To: <147395463702.2399.17485798724867278064.stgit@fimbulvetr.bsc.es> References: <147395463702.2399.17485798724867278064.stgit@fimbulvetr.bsc.es> 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 u8FFoxDW002272 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH v2 4/5] 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 Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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/format/h.py | 23 +++++++++++++++++------ scripts/tracetool/format/tcg_h.py | 20 +++++++++++++++++--- scripts/tracetool/format/tcg_helper_c.py | 3 ++- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py index 3763e9a..99fcbc0 100644 --- a/scripts/tracetool/format/h.py +++ b/scripts/tracetool/format/h.py @@ -29,6 +29,19 @@ def generate(events, backend): backend.generate_begin(events) for e in events: + # tracer without checks + out('', + 'static inline void __nocheck__%(api)s(%(args)s)', + '{', + api=e.api(), + args=e.args) + + if "disable" not in e.properties: + backend.generate(e) + + 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,"\ @@ -44,16 +57,14 @@ def generate(events, backend): 'static inline void %(api)s(%(args)s)', '{', ' if (%(cond)s) {', + ' __nocheck__%(api)s(%(names)s);', + ' }', + '}', api=e.api(), args=e.args, + names=", ".join(e.args.names()), cond=cond) - if "disable" not in e.properties: - backend.generate(e) - - out(' }', - '}') - backend.generate_end(events) out('#endif /* TRACE__GENERATED_TRACERS_H */') diff --git a/scripts/tracetool/format/tcg_h.py b/scripts/tracetool/format/tcg_h.py index e2331f2..fb2503a 100644 --- a/scripts/tracetool/format/tcg_h.py +++ b/scripts/tracetool/format/tcg_h.py @@ -41,7 +41,7 @@ def generate(events, backend): 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,26 @@ def generate(events, backend): 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,"\ + " TRACE_VCPU_%(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 e3485b7..f9adb3c 100644 --- a/scripts/tracetool/format/tcg_helper_c.py +++ b/scripts/tracetool/format/tcg_helper_c.py @@ -66,7 +66,8 @@ def generate(events, backend): out('void %(name_tcg)s(%(args_api)s)', '{', - ' %(name)s(%(args_call)s);', + # NOTE: the check was already performed at TCG-generation time + ' __nocheck__%(name)s(%(args_call)s);', '}', name_tcg="helper_%s_proxy" % e.api(), name=e.api(),