From nobody Sat Nov 15 00:06:34 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759161291; cv=none; d=zohomail.com; s=zohoarc; b=MqvFvozOGApFJFIyx8JIf9szeFEp50OuXMUS+Scpuyl9gM/R8pv5H9SDg1Qg9Lqs2LAXQUuaOO0YWWozbwy5oiY0lyJQRh8y9sw0NTsBBosS7HIjK2nv3ZpIzgMJngNsAu1RybuHYwCNR8uOCfNZr0acFs6TIJhJfvqaUH7KCUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759161291; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nXiQoLVud16zJS++9JVhoT2jq7OgO1shPqm/dnBddzo=; b=j6gury2v8v9o1gDN/2fXOdh9CP2y0UKjUjxMQqU6FiQM8IZptebecmcjCerAh6OH7fAfRpgEGnbR2VdKpFV6oQmDZ6PPyip8cm7EURdx0ulFanTJ0cNWrWUWppuQzPymMhnKZXuYXIj9uxG8JVsJLBeBmUTx0qtCdWdFKETnSHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759161291894112.61351988249237; Mon, 29 Sep 2025 08:54:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v3G9a-0001EI-T3; Mon, 29 Sep 2025 11:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v3G8t-0000rN-2M for qemu-devel@nongnu.org; Mon, 29 Sep 2025 11:50:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v3G8d-0000YY-Qr for qemu-devel@nongnu.org; Mon, 29 Sep 2025 11:50:22 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-NAV1bgbnMGyYaJTn5eGlgQ-1; Mon, 29 Sep 2025 11:50:01 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-634c48a0ce7so3885166a12.1 for ; Mon, 29 Sep 2025 08:50:00 -0700 (PDT) Received: from [192.168.10.48] ([176.206.127.188]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-634a364fedesm7967787a12.14.2025.09.29.08.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Sep 2025 08:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759161003; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nXiQoLVud16zJS++9JVhoT2jq7OgO1shPqm/dnBddzo=; b=SjUo9hvjX7kLXGvQ3/FxJjlYrJyq012S4H/eyaJsWJ21zQ8RmhOBE3kEMMtaumDUoOjGMh VKoRfJoj3WQqINsONtnVkYFciYI/p/vyTrPFnxkuwp//UaJA8TGRvTfZBgZWeuFi7vRaD9 gX+MU2Y2aFntR5SCwdYFJeqEXU5SoU0= X-MC-Unique: NAV1bgbnMGyYaJTn5eGlgQ-1 X-Mimecast-MFC-AGG-ID: NAV1bgbnMGyYaJTn5eGlgQ_1759161000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759160999; x=1759765799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nXiQoLVud16zJS++9JVhoT2jq7OgO1shPqm/dnBddzo=; b=CwREv8+yWo3lAtk6pEPNVUD+5DpRgQQMfhP2C/TnT2yl8KOMQswOUL4EeMTrc6M0oC 3EXxiq2enohpgvyJcN/nPj0gy4KMINoo7JLKgEfpKASn2VL7IOs2UqUqTZw1+6KkoeTL Fj2d4nLU2760C4KzsQoVlBH9nika0PjtwxlUU8Hj3TgmZhLQJOXfXJunkDwHbiftGBUA 6UBuAlXls1VttcwOgt+8LCLMihGHJhPAdlz8Iqc0NGBMuJ/MKxqp7Ugsru78o21b7Tcx IglLAzucVp7bMonAhziro7uzq3QmwUxn2/JTIsrTSehwyY/jux0RWo4COLGKXpVi41J0 cEyg== X-Gm-Message-State: AOJu0YwfIEAJkdOJukRbkIUXY+SEOI6k7NpzQCmwQfrhkIktkPR3rcWY WnFhUByblbO6ABHoDO8YmP3zG3ht0KI0PHzaHa2PiBPGnoqPeoxmyQWezfDwgaDoFz1+e9alMRc EfNaty5HGHmie8pxmQkTKeEwvuUZiqqJxVdcBgf59RJCxwTlW9dxBXFNIldir/w832hZ8/PlEI8 kZ0uEjPSw/9NwAamaHTo+QcPwfYV5urLQv8LhCPBbG X-Gm-Gg: ASbGncsDaoWYgpertRDUP5gnnQah24fiqckmIpQ1XTlsyabbnlg1yyLX3IvKUxAJ93A p/cLRSgSC5r0LZ2yqUlrO0rOAFclmIf9d4+l0CzT9cHdMGFMw3ddGdAmr2567IYPT8VRRXwJR5e ssCW9UMXP6AfFw79syzDNMPQubmrwWn7jZGgw4BViyrOtCU+hrZPmITVwljb03pdFWGb3vapyxm jJwqTwJWBQOnL+qLXikGTPtcEiDcRkkz1QgEuEhYx+fjf/6yMrR14BxkVerHawF/wSOVfC/JI3g GHTXFOqyEyFQYQY87IiuPvH7iuuP3MZISFdNMh2EFYTdaMptf4IGUckjrq+KaUmH7PmuKpJMNUT ScmvgRJV5zy1YiQEW4e4YJppqLSK8Hgsx6StvQ7mRsFqKVQ== X-Received: by 2002:a05:6402:4412:b0:631:6713:3ac2 with SMTP id 4fb4d7f45d1cf-6349fabb58bmr15560837a12.38.1759160999505; Mon, 29 Sep 2025 08:49:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGZxxwsuUtbggYL5aOlrGiwf5w+UORwVlsBCtdVLYK9eI9LpaPDy14vpQw9wK3Zo/85HtWwow== X-Received: by 2002:a05:6402:4412:b0:631:6713:3ac2 with SMTP id 4fb4d7f45d1cf-6349fabb58bmr15560810a12.38.1759160999052; Mon, 29 Sep 2025 08:49:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Tanish Desai , Stefan Hajnoczi , Manos Pitsidianakis , Mads Ynddal , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhao Liu , qemu-rust@nongnu.org Subject: [PATCH 07/16] tracetool/backend: remove redundant trace event checks Date: Mon, 29 Sep 2025 17:49:29 +0200 Message-ID: <20250929154938.594389-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250929154938.594389-1-pbonzini@redhat.com> References: <20250929154938.594389-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.513, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759161292958116600 Content-Type: text/plain; charset="utf-8" From: Tanish Desai Use CHECK_TRACE_EVENT_GET_STATE in log, syslog, dtrace and simple backend, so that the "if (trace_event_get_state)" is created from common code and unified when multiple backends are active. When a single backend is active there is no code change (except for the log backend, as shown in tests/tracetool/log.h), but the code in the backends is simpler. Signed-off-by: Tanish Desai Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini --- tests/tracetool/log.h | 16 ++++++++++------ scripts/tracetool/backend/ftrace.py | 6 ++---- scripts/tracetool/backend/log.py | 10 ++++------ scripts/tracetool/backend/simple.py | 8 ++------ scripts/tracetool/backend/syslog.py | 8 ++------ 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/tests/tracetool/log.h b/tests/tracetool/log.h index edcc7f9d47c..c7795871f85 100644 --- a/tests/tracetool/log.h +++ b/tests/tracetool/log.h @@ -21,10 +21,12 @@ extern uint16_t _TRACE_TEST_WIBBLE_DSTATE; =20 static inline void trace_test_blah(void *context, const char *filename) { - if (trace_event_get_state(TRACE_TEST_BLAH) && qemu_loglevel_mask(LOG_T= RACE)) { + if (trace_event_get_state(TRACE_TEST_BLAH)) { + if (qemu_loglevel_mask(LOG_TRACE)) { #line 4 "trace-events" - qemu_log("test_blah " "Blah context=3D%p filename=3D%s" "\n", cont= ext, filename); -#line 28 "log.h" + qemu_log("test_blah " "Blah context=3D%p filename=3D%s" "\n", = context, filename); +#line 29 "log.h" + } } } =20 @@ -34,10 +36,12 @@ static inline void trace_test_blah(void *context, const= char *filename) =20 static inline void trace_test_wibble(void *context, int value) { - if (trace_event_get_state(TRACE_TEST_WIBBLE) && qemu_loglevel_mask(LOG= _TRACE)) { + if (trace_event_get_state(TRACE_TEST_WIBBLE)) { + if (qemu_loglevel_mask(LOG_TRACE)) { #line 5 "trace-events" - qemu_log("test_wibble " "Wibble context=3D%p value=3D%d" "\n", con= text, value); -#line 41 "log.h" + qemu_log("test_wibble " "Wibble context=3D%p value=3D%d" "\n",= context, value); +#line 44 "log.h" + } } } #endif /* TRACE_TESTSUITE_GENERATED_TRACERS_H */ diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backen= d/ftrace.py index 8c0ce3f23a0..7ddd5d11a66 100644 --- a/scripts/tracetool/backend/ftrace.py +++ b/scripts/tracetool/backend/ftrace.py @@ -16,6 +16,7 @@ =20 =20 PUBLIC =3D True +CHECK_TRACE_EVENT_GET_STATE =3D True =20 =20 def generate_h_begin(events, group): @@ -28,14 +29,11 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - out(' if (trace_event_get_state(%(event_id)s)) {', - '#line %(event_lineno)d "%(event_filename)s"', + out('#line %(event_lineno)d "%(event_filename)s"', ' ftrace_write("%(name)s " %(fmt)s "\\n" %(argnames)s);', '#line %(out_next_lineno)d "%(out_filename)s"', - ' }', name=3Devent.name, args=3Devent.args, - event_id=3D"TRACE_" + event.name.upper(), event_lineno=3Devent.lineno, event_filename=3Devent.filename, fmt=3Devent.fmt.rstrip("\n"), diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index faacec46105..d01d234289f 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -16,6 +16,7 @@ =20 =20 PUBLIC =3D True +CHECK_TRACE_EVENT_GET_STATE =3D True =20 =20 def generate_h_begin(events, group): @@ -28,14 +29,11 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper()) - - out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {', + out(' if (qemu_loglevel_mask(LOG_TRACE)) {', '#line %(event_lineno)d "%(event_filename)s"', - ' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);', + ' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);', '#line %(out_next_lineno)d "%(out_filename)s"', - ' }', - cond=3Dcond, + ' }', event_lineno=3Devent.lineno, event_filename=3Devent.filename, name=3Devent.name, diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backen= d/simple.py index 97e40495ee9..b5a6b7205a3 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -16,6 +16,7 @@ =20 =20 PUBLIC =3D True +CHECK_TRACE_EVENT_GET_STATE =3D True =20 =20 def is_string(arg): @@ -36,13 +37,8 @@ def generate_h_begin(events, group): =20 =20 def generate_h(event, group): - event_id =3D 'TRACE_' + event.name.upper() - cond =3D "trace_event_get_state(%s)" % event_id - out(' if (%(cond)s) {', - ' _simple_%(api)s(%(args)s);', - ' }', + out(' _simple_%(api)s(%(args)s);', api=3Devent.api(), - cond=3Dcond, args=3D", ".join(event.args.names())) =20 =20 diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backen= d/syslog.py index 78ee67136b8..177414d56a6 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -16,6 +16,7 @@ =20 =20 PUBLIC =3D True +CHECK_TRACE_EVENT_GET_STATE =3D True =20 =20 def generate_h_begin(events, group): @@ -28,14 +29,9 @@ def generate_h(event, group): if len(event.args) > 0: argnames =3D ", " + argnames =20 - cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper()) - - out(' if (%(cond)s) {', - '#line %(event_lineno)d "%(event_filename)s"', + out('#line %(event_lineno)d "%(event_filename)s"', ' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);', '#line %(out_next_lineno)d "%(out_filename)s"', - ' }', - cond=3Dcond, event_lineno=3Devent.lineno, event_filename=3Devent.filename, name=3Devent.name, --=20 2.51.0