From nobody Mon Feb 9 11:30:29 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 1501234284606866.163323265345; Fri, 28 Jul 2017 02:31:24 -0700 (PDT) Received: from localhost ([::1]:47044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1db1cB-000813-3p for importer@patchew.org; Fri, 28 Jul 2017 05:31:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1db1SE-00078z-H7 for qemu-devel@nongnu.org; Fri, 28 Jul 2017 05:21:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1db1SD-00076n-AI for qemu-devel@nongnu.org; Fri, 28 Jul 2017 05:21:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58440) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1db1SD-00076I-06 for qemu-devel@nongnu.org; Fri, 28 Jul 2017 05:21:05 -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 EAA2E7036E; Fri, 28 Jul 2017 09:21:03 +0000 (UTC) Received: from localhost (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44AA160BF1; Fri, 28 Jul 2017 09:21:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EAA2E7036E 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=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Fri, 28 Jul 2017 10:20:53 +0100 Message-Id: <20170728092053.10122-3-stefanha@redhat.com> In-Reply-To: <20170728092053.10122-1-stefanha@redhat.com> References: <20170728092053.10122-1-stefanha@redhat.com> 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.26]); Fri, 28 Jul 2017 09:21:04 +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] [PATCH 2/2] trace: check backend dstate in trace_event_get_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: "Denis V. Lunev" , =?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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Code that checks dstate is unaware of SystemTap and LTTng UST dstate, so the following trace event will not fire when solely enabled by SystemTap or LTTng UST: if (trace_event_get_state(TRACE_MY_EVENT)) { str =3D g_strdup_printf("Expensive string to generate ...", ...); trace_my_event(str); g_free(str); } Most users of trace_event_get_state() want to know both QEMU and backend dstate for the event. Update the macro to include backend dstate. Introduce trace_event_get_state_qemu() for those callers who really only want QEMU dstate. This includes the trace backends (like 'log') which should only trigger when event are enabled via QEMU. Signed-off-by: Stefan Hajnoczi --- trace/control.h | 20 ++++++++++++++++++-- scripts/tracetool/backend/ftrace.py | 2 +- scripts/tracetool/backend/log.py | 3 ++- scripts/tracetool/backend/simple.py | 2 +- scripts/tracetool/backend/syslog.py | 3 ++- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/trace/control.h b/trace/control.h index b931824d60..b996c34c08 100644 --- a/trace/control.h +++ b/trace/control.h @@ -93,16 +93,32 @@ static bool trace_event_is_vcpu(TraceEvent *ev); static const char * trace_event_get_name(TraceEvent *ev); =20 /** + * trace_event_get_state_qemu: + * @id: Event identifier name. + * + * Get the tracing state of an event, both static and the QEMU dynamic sta= te. + * Note that some backends maintain their own dynamic state, use + * trace_event_get_state() instead if you wish to include it. + * + * If the event has the disabled property, the check will have no performa= nce + * impact. + */ +#define trace_event_get_state_qemu(id) \ + ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id)) + +/** * trace_event_get_state: * @id: Event identifier name. * - * Get the tracing state of an event (both static and dynamic). + * Get the tracing state of an event (both static and dynamic). Both QEMU= and + * backend-specific dynamic state are included. * * If the event has the disabled property, the check will have no performa= nce * impact. */ #define trace_event_get_state(id) \ - ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id)) + ((id ##_ENABLED) && (trace_event_get_state_dynamic_by_id(id) || \ + id ##_BACKEND_DSTATE())) =20 /** * trace_event_get_vcpu_state: diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index dd0eda4441..fba637b376 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -33,7 +33,7 @@ def generate_h(event, group): ' char ftrace_buf[MAX_TRACE_STRLEN];', ' int unused __attribute__ ((unused));', ' int trlen;', - ' if (trace_event_get_state(%(event_id)s)) {', + ' if (trace_event_get_state_qemu(%(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);', diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index 54f0a69886..4562b9d12d 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -33,7 +33,8 @@ def generate_h(event, group): # already checked on the generic format code cond =3D "true" else: - cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.uppe= r()) + cond =3D "trace_event_get_state_qemu(%s)" % \ + ("TRACE_" + event.name.upper()) =20 out(' if (%(cond)s) {', ' struct timeval _now;', diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backen= d/simple.py index f983670ee1..a39bbdc5c6 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -73,7 +73,7 @@ def generate_c(event, group): # already checked on the generic format code cond =3D "true" else: - cond =3D "trace_event_get_state(%s)" % event_id + cond =3D "trace_event_get_state_qemu(%s)" % event_id =20 out('', ' if (!%(cond)s) {', diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backen= d/syslog.py index 1ce627f0fc..3ee07bf7fd 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -33,7 +33,8 @@ def generate_h(event, group): # already checked on the generic format code cond =3D "true" else: - cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.uppe= r()) + cond =3D "trace_event_get_state_qemu(%s)" % \ + ("TRACE_" + event.name.upper()) =20 out(' if (%(cond)s) {', ' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);', --=20 2.13.3