From nobody Mon Feb 9 18:18:24 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 1501593691582900.5351797532403; Tue, 1 Aug 2017 06:21:31 -0700 (PDT) Received: from localhost ([::1]:42535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcX70-0005Aw-3n for importer@patchew.org; Tue, 01 Aug 2017 09:21:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcX2q-0001x1-O6 for qemu-devel@nongnu.org; Tue, 01 Aug 2017 09:17:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcX2p-0005hy-KT for qemu-devel@nongnu.org; Tue, 01 Aug 2017 09:17:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33543) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dcX2p-0005gs-ET for qemu-devel@nongnu.org; Tue, 01 Aug 2017 09:17:07 -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 09E7155279; Tue, 1 Aug 2017 13:17:05 +0000 (UTC) Received: from localhost (ovpn-117-109.ams2.redhat.com [10.36.117.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BF7E5C3FD; Tue, 1 Aug 2017 13:16:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 09E7155279 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=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 1 Aug 2017 14:16:18 +0100 Message-Id: <20170801131618.27332-10-stefanha@redhat.com> In-Reply-To: <20170801131618.27332-1-stefanha@redhat.com> References: <20170801131618.27332-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.28]); Tue, 01 Aug 2017 13:17:06 +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 9/9] monitor: Reduce handle_qmp_command() tracing overhead 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 , "Dr . David Alan Gilbert" , Markus Armbruster , Stefan Hajnoczi , "Denis V. Lunev" , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= 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: "Denis V. Lunev" We are malloc'ing a QString and spending CPU cycles on converting a QObject to string, just for the sake of sticking the string in the trace message. Wasted when we aren't tracing. Avoid that. [Commit message and description suggested by Markus Armbruster to provide more detail about the rationale for this patch. Use trace_event_get_state_backends() instead of trace_event_get_state() to honor DTrace/UST backend dstates. --Stefan] Signed-off-by: Denis V. Lunev Reviewed-by: Eric Blake Message-id: 20170725143923.11241-1-den@openvz.org CC: Stefan Hajnoczi CC: Llu=C3=ADs Vilanova CC: Dr. David Alan Gilbert CC: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- monitor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index 6d040e620f..e0f880107f 100644 --- a/monitor.c +++ b/monitor.c @@ -3823,7 +3823,6 @@ static void handle_qmp_command(JSONMessageParser *par= ser, GQueue *tokens) QDict *qdict =3D NULL; Monitor *mon =3D cur_mon; Error *err =3D NULL; - QString *req_json; =20 req =3D json_parser_parse_err(tokens, NULL, &err); if (!req && !err) { @@ -3841,9 +3840,11 @@ static void handle_qmp_command(JSONMessageParser *pa= rser, GQueue *tokens) qdict_del(qdict, "id"); } /* else will fail qmp_dispatch() */ =20 - req_json =3D qobject_to_json(req); - trace_handle_qmp_command(mon, qstring_get_str(req_json)); - QDECREF(req_json); + if (trace_event_get_state_backends(TRACE_HANDLE_QMP_COMMAND)) { + QString *req_json =3D qobject_to_json(req); + trace_handle_qmp_command(mon, qstring_get_str(req_json)); + QDECREF(req_json); + } =20 rsp =3D qmp_dispatch(cur_mon->qmp.commands, req); =20 --=20 2.13.3