]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/trace: Introduce new API
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 20 Sep 2021 12:36:12 +0000 (13:36 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 20 May 2024 17:29:44 +0000 (18:29 +0100)
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>
Reviewed-by: George Dunlap <george.dunlap@cloud.com>
xen/common/trace.c
xen/include/xen/trace.h

index 4e7b080e6154c9440a43b4bb1dfe5a03af3eef2d..c94ce1f7dc9016e61880920fc08ce164c1805e0c 100644 (file)
@@ -808,6 +808,11 @@ unlock:
         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)
 {
index 055883287e8c3ab91342876a00b5c56fbcb0dca5..9dc7e3d621f3aef67dbe614440b61faa91f1c8ec 100644 (file)
@@ -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 {                                        \