All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Jan Beulich <JBeulich@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Nicola Vetrini <nicola.vetrini@bugseng.com>,
	"consulting @ bugseng . com" <consulting@bugseng.com>
Subject: [PATCH 1/7] xen/trace: Introduce new API
Date: Mon, 18 Mar 2024 16:35:46 +0000	[thread overview]
Message-ID: <20240318163552.3808695-2-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20240318163552.3808695-1-andrew.cooper3@citrix.com>

trace() and trace_time(), in function form for struct arguments, and macro
form for simple uint32_t list arguments.

This will be used to clean up the mess of macros which exists throughout the
codebase, as well as eventually dropping __trace_var().

There is intentionally no macro to split a 64-bit parameter in the new API,
for MISRA reasons.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Nicola Vetrini <nicola.vetrini@bugseng.com>
CC: consulting@bugseng.com <consulting@bugseng.com>

v3:
 * Extend with trace() and trace_time()
 * Delete TRACE_PARAM64() for MISRA reasons.
---
 xen/common/trace.c      |  5 +++++
 xen/include/xen/trace.h | 30 ++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/xen/common/trace.c b/xen/common/trace.c
index 4e7b080e6154..c94ce1f7dc90 100644
--- a/xen/common/trace.c
+++ b/xen/common/trace.c
@@ -808,6 +808,11 @@ void __trace_var(u32 event, bool cycles, unsigned int extra,
         tasklet_schedule(&trace_notify_dom0_tasklet);
 }
 
+void trace(uint32_t event, unsigned int extra, const void *extra_data)
+{
+    __trace_var(event, event & TRC_HD_CYCLE_FLAG, extra, extra_data);
+}
+
 void __trace_hypercall(uint32_t event, unsigned long op,
                        const xen_ulong_t *args)
 {
diff --git a/xen/include/xen/trace.h b/xen/include/xen/trace.h
index 055883287e8c..f184844e1b55 100644
--- a/xen/include/xen/trace.h
+++ b/xen/include/xen/trace.h
@@ -37,6 +37,9 @@ int tb_control(struct xen_sysctl_tbuf_op *tbc);
 
 int trace_will_trace_event(u32 event);
 
+/* Create a trace record, with pre-constructed additional parameters. */
+void trace(uint32_t event, unsigned int extra, const void *extra_data);
+
 void __trace_var(uint32_t event, bool cycles, unsigned int extra, const void *);
 
 static inline void trace_var(uint32_t event, bool cycles, unsigned int extra,
@@ -66,6 +69,9 @@ static inline int trace_will_trace_event(uint32_t event)
     return 0;
 }
 
+static inline void trace(
+    uint32_t event, unsigned int extra, const void *extra_data) {}
+
 static inline void trace_var(uint32_t event, bool cycles, unsigned int extra,
                              const void *extra_data) {}
 static inline void __trace_var(uint32_t event, bool cycles, unsigned int extra,
@@ -74,6 +80,30 @@ static inline void __trace_hypercall(uint32_t event, unsigned long op,
                                      const xen_ulong_t *args) {}
 #endif /* CONFIG_TRACEBUFFER */
 
+/* Create a trace record with time included. */
+static inline void trace_time(
+    uint32_t event, unsigned int extra, const void *extra_data)
+{
+    trace(event | TRC_HD_CYCLE_FLAG, extra, extra_data);
+}
+
+/*
+ * Create a trace record, packaging up to 7 additional parameters into a
+ * uint32_t array.
+ */
+#define TRACE(_e, ...)                                          \
+    do {                                                        \
+        if ( unlikely(tb_init_done) )                           \
+        {                                                       \
+            uint32_t _d[] = { __VA_ARGS__ };                    \
+            BUILD_BUG_ON(ARRAY_SIZE(_d) > TRACE_EXTRA_MAX);     \
+            trace(_e, sizeof(_d), sizeof(_d) ? _d : NULL);      \
+        }                                                       \
+    } while ( 0 )
+
+/* Create a trace record with time included. */
+#define TRACE_TIME(_e, ...) TRACE((_e) | TRC_HD_CYCLE_FLAG, ##__VA_ARGS__)
+
 /* Convenience macros for calling the trace function. */
 #define TRACE_0D(_e)                            \
     do {                                        \
-- 
2.30.2



  reply	other threads:[~2024-03-18 16:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 16:35 [PATCH 0/7] xen/trace: Treewide API cleanup Andrew Cooper
2024-03-18 16:35 ` Andrew Cooper [this message]
2024-03-20 11:58   ` [PATCH 1/7] xen/trace: Introduce new API George Dunlap
2024-03-20 13:09     ` Jan Beulich
2024-03-18 16:35 ` [PATCH 2/7] xen/credit2: Clean up trace handling Andrew Cooper
2024-03-20 12:16   ` George Dunlap
2024-03-20 12:19     ` Andrew Cooper
2024-03-20 13:04       ` George Dunlap
2024-03-20 13:13       ` Jan Beulich
2024-03-20 13:20         ` George Dunlap
2024-03-20 15:05     ` George Dunlap
2024-03-18 16:35 ` [PATCH 3/7] xen/rt: " Andrew Cooper
2024-03-20 15:11   ` George Dunlap
2024-03-18 16:35 ` [PATCH 4/7] xen/sched: " Andrew Cooper
2024-03-20 15:19   ` George Dunlap
2024-03-18 16:35 ` [PATCH 5/7] xen: Switch to new TRACE() API Andrew Cooper
2024-03-20 13:45   ` Jan Beulich
2024-03-20 15:46     ` George Dunlap
2024-03-20 16:06       ` Jan Beulich
2024-03-20 16:04   ` George Dunlap
2024-03-18 16:35 ` [PATCH 6/7] xen/trace: Update final {__,}trace_var() users to the new API Andrew Cooper
2024-03-20 13:52   ` Jan Beulich
2024-03-20 15:53   ` George Dunlap
2024-03-18 16:35 ` [PATCH 7/7] xen/trace: Drop old trace API Andrew Cooper
2024-03-20 13:54   ` Jan Beulich
2024-03-20 16:06   ` George Dunlap
2024-03-20 11:01 ` [PATCH 0/7] xen/trace: Treewide API cleanup Nicola Vetrini
2024-03-21  9:39   ` Nicola Vetrini

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=20240318163552.3808695-2-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=consulting@bugseng.com \
    --cc=julien@xen.org \
    --cc=nicola.vetrini@bugseng.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.