qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Tanish Desai <tanishdesai37@gmail.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	Mads Ynddal <mads@ynddal.dk>,
	Tanish Desai <tanishdesai37@gmail.com>
Subject: [PATCH v2 2/3] tracetool: introduce generate_unconditional
Date: Fri, 20 Jun 2025 14:37:19 +0000	[thread overview]
Message-ID: <20250620143720.3143-3-tanishdesai37@gmail.com> (raw)
In-Reply-To: <20250620143720.3143-1-tanishdesai37@gmail.com>

This patch separates the generation logic of trace_foo() for the UST
and DTrace backends from other backends.

The motivation is to remove the unnecessary if (true) in the trace_foo()
function, as UST and DTrace do not require a trace_event_get_state check
without introducing a seperate function it is very difficult to generate
code which keeps them out of unified if condition.

With this separation, we can safely move the trace_event_get_state check
into trace_foo for the other backends only, keeping UST/DTrace generation
paths clean.

A new generate_h_unconditional function has been introduced for UST and DTrace.
It behaves similarly to generate_h, but is defined only in UST and
DTrace backends.

This ensures that generate_h is used by the other backends, while UST/DTrace
selectively use generate_h_unconditional.

Signed-off-by: Tanish Desai <tanishdesai37@gmail.com>
---
 scripts/tracetool/backend/__init__.py |  3 +++
 scripts/tracetool/backend/dtrace.py   |  3 ++-
 scripts/tracetool/backend/ust.py      |  2 +-
 scripts/tracetool/format/h.py         | 10 +++++++---
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/backend/__init__.py
index 7bfcc86cc5..c4456a5efd 100644
--- a/scripts/tracetool/backend/__init__.py
+++ b/scripts/tracetool/backend/__init__.py
@@ -118,6 +118,9 @@ def generate_begin(self, events, group):
     def generate(self, event, group):
         self._run_function("generate_%s", event, group)
 
+    def generate_unconditional(self, event, group):
+        self._run_function("generate_%s_unconditional", event, group)
+    
     def generate_backend_dstate(self, event, group):
         self._run_function("generate_%s_backend_dstate", event, group)
 
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index e17edc9b9d..171b7e09ed 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -61,7 +61,8 @@ def generate_h_begin(events, group):
             '#endif',
             uppername=e.name.upper())
 
-def generate_h(event, group):
+
+def generate_h_unconditional(event, group):
     out('    QEMU_%(uppername)s(%(argnames)s);',
         uppername=event.name.upper(),
         argnames=", ".join(event.args.names()))
diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py
index c857516f21..1564b490ec 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -30,7 +30,7 @@ def generate_h_begin(events, group):
         '')
 
 
-def generate_h(event, group):
+def generate_h_unconditional(event, group):
     argnames = ", ".join(event.args.names())
     if len(event.args) > 0:
         argnames = ", " + argnames
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index ea126b07ea..89d54b9aff 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -76,13 +76,17 @@ def generate(events, backend, group):
         out('',
             'static inline void %(api)s(%(args)s)',
             '{',
-            '    if (%(cond)s) {',
+            api=e.api(),
+            args=e.args)
+        
+        if "disable" not in e.properties:
+            backend.generate_unconditional(e, group)
+
+        out('    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)
 
-- 
2.34.1



  parent reply	other threads:[~2025-06-20 14:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 14:37 [PATCH v2 0/3] tracetool: cleanup "if(true)" check from trace_foo() Tanish Desai
2025-06-20 14:37 ` [PATCH v2 1/3] tracetool: removed the unused vcpu property Tanish Desai
2025-06-20 16:12   ` Alex Bennée
2025-06-20 16:27     ` Tanish Desai
2025-06-20 14:37 ` Tanish Desai [this message]
2025-06-24 14:37   ` [PATCH v2 2/3] tracetool: introduce generate_unconditional Stefan Hajnoczi
2025-06-24 17:37     ` Tanish Desai
2025-06-24 19:03       ` Stefan Hajnoczi
2025-06-25 12:30         ` [PATCH v3] tracetool: generates conitional checks when needed Tanish Desai
2025-06-26 18:43           ` Stefan Hajnoczi
2025-06-26 19:30             ` Tanish Desai
2025-06-20 14:37 ` [PATCH v2 3/3] tracetool: remove redundant event_get_state checks Tanish Desai
2025-06-24 14:26   ` Stefan Hajnoczi
2025-06-20 14:38 ` [PATCH v2 0/3] tracetool: cleanup "if(true)" check from trace_foo() Tanish Desai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250620143720.3143-3-tanishdesai37@gmail.com \
    --to=tanishdesai37@gmail.com \
    --cc=mads@ynddal.dk \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).