Skip to contentSkip to conversation

fix tracing for modules

RFC PATCH In review Gerd Hoffmann 3 participants 24 messages Jun 1, 2021 – Jun 10, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v4 cover fix tracing for modules

First version that actually works. Only qxl covered for this RfC, other modules will follow once the basics are hashed out.

v4:
- rebase to latest master.
- fix systemtap tracing.
- also cover virtio-gpu modules.
- pick up some review tags.
- misc minor tweaks.

v3:
- handle initialization of modular tracepoints.

TODO:
Enabling modular tracepoints via -trace cmd line doesn't work yet. Guess we need to store the list somewhere for later re-processing. Error handling is tricky, specifically the "tracepoint doesn't exist" error. Suggestions / ideas are welcome.

More context:
https://bugzilla.redhat.com/show_bug.cgi?id=1898700
https://bugzilla.redhat.com/show_bug.cgi?id=1869642

take care,
Gerd

Gerd Hoffmann (13):
qemu-trace-stap: changing SYSTEMTAP_TAPSET considered harmful.
trace: iter init tweaks
trace: add trace_event_iter_init_group
trace/simple: pass iter to st_write_event_mapping trace/simple: add st_init_group
meson: add trace_events_config[]
meson: move up hw subdir (specifically before trace subdir)
meson: add module_trace & module_trace_src trace/stap: build stap files for modules
meson: move qxl trace events to separate file
virtio-gpu: split trace points
meson: move virtio trace events to separate file
meson: move virtio-gl trace events to separate file

 hw/display/trace-qxl.h            |  1 +
 hw/display/trace-virtio-gl.h      |  1 +
 hw/display/trace-virtio.h         |  1 +
 trace/control.h                   | 30 ++++++++--
 trace/simple.h                    |  1 +
 hw/display/qxl-render.c           |  2 +-
 hw/display/qxl.c                  |  2 +-
 hw/display/virtio-gpu-base.c      |  2 +-
 hw/display/virtio-gpu-virgl.c     | 50 ++++++++--------
 hw/display/virtio-gpu.c           |  2 +-
 monitor/misc.c                    |  4 +-
 trace/control-target.c            |  2 +-
 trace/control.c                   | 39 ++++++++++---
 trace/qmp.c                       |  6 +-
 trace/simple.c                    | 22 +++++--
 hw/display/meson.build            | 12 ++++
 hw/display/trace-events           | 95 -------------------------------
 hw/display/trace-events-qxl       | 66 +++++++++++++++++++++
 hw/display/trace-events-virtio    | 16 ++++++
 hw/display/trace-events-virtio-gl | 18 ++++++
 meson.build                       | 43 +++++++++++++-
 scripts/qemu-trace-stap           | 14 ++---
 trace/meson.build                 | 36 +++++++++---
 23 files changed, 298 insertions(+), 167 deletions(-)
 create mode 100644 hw/display/trace-qxl.h
 create mode 100644 hw/display/trace-virtio-gl.h
 create mode 100644 hw/display/trace-virtio.h
 create mode 100644 hw/display/trace-events-qxl
 create mode 100644 hw/display/trace-events-virtio
 create mode 100644 hw/display/trace-events-virtio-gl
Signature · 1 line
2.31.1
#1 lore raw

PATCH v4 1/13 qemu-trace-stap: changing SYSTEMTAP_TAPSET considered harmful.

Setting SYSTEMTAP_TAPSET to some value other than /usr/share/systemtap/tapsets results in systemtap not finding the standard tapset library any more, which in turn breaks tracing because pid() and other standard systemtap functions are not available any more.

So using SYSTEMTAP_TAPSET to point systemtap to the qemu probes will only work for the prefix=/usr installs because both qemu and system tapsets in the same directory then. All other prefixes are broken.

Fix that by using the "-I $tapsetdir" command line switch instead.

---
 scripts/qemu-trace-stap | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
scripts/qemu-trace-stap +4 -10
index 90527eb974f4..eb6e951ff235 100755
@@ -55,11 +55,6 @@ def tapset_dir(binary):
     return os.path.realpath(tapset)
 
 
-def tapset_env(tapset_dir):
-    tenv = copy.copy(os.environ)
-    tenv["SYSTEMTAP_TAPSET"] = tapset_dir
-    return tenv
-
 def cmd_run(args):
     prefix = probe_prefix(args.binary)
     tapsets = tapset_dir(args.binary)
@@ -81,11 +76,11 @@ def cmd_run(args):
 
     # We request an 8MB buffer, since the stap default 1MB buffer
     # can be easily overflowed by frequently firing QEMU traces
-    stapargs = ["stap", "-s", "8"]
+    stapargs = ["stap", "-s", "8", "-I", tapsets ]
     if args.pid is not None:
         stapargs.extend(["-x", args.pid])
     stapargs.extend(["-e", script])
-    subprocess.call(stapargs, env=tapset_env(tapsets))
+    subprocess.call(stapargs)
 
 
 def cmd_list(args):
@@ -101,10 +96,9 @@ def cmd_list(args):
 
         if verbose:
             print("Listing probes with name '%s'" % script)
-        proc = subprocess.Popen(["stap", "-l", script],
+        proc = subprocess.Popen(["stap", "-I", tapsets, "-l", script],
                                 stdout=subprocess.PIPE,
-                                universal_newlines=True,
-                                env=tapset_env(tapsets))
+                                universal_newlines=True)
         out, err = proc.communicate()
         if proc.returncode != 0:
             print("No probes found, are the tapsets installed in %s" % tapset_dir(args.binary))
Signature · 1 line
2.31.1
Reviewed-by on v4 1/13
#2 lore raw

Re: [PATCH v4 01/13] qemu-trace-stap: changing SYSTEMTAP_TAPSET considered harmful.

Quoted 9 lines · Gerd Hoffmann

Setting SYSTEMTAP_TAPSET to some value other than /usr/share/systemtap/tapsets results in systemtap not finding the standard tapset library any more, which in turn breaks tracing because pid() and other standard systemtap functions are not available any more.

So using SYSTEMTAP_TAPSET to point systemtap to the qemu probes will only work for the prefix=/usr installs because both qemu and system tapsets in the same directory then. All other prefixes are broken.

Quoted 6 lines

Fix that by using the "-I $tapsetdir" command line switch instead.

---
 scripts/qemu-trace-stap | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
Reviewed-by on v4 1/13
#3 lore raw

Re: [PATCH v4 01/13] qemu-trace-stap: changing SYSTEMTAP_TAPSET considered harmful.

In reply to Gerd Hoffmann
Quoted 9 lines · Gerd Hoffmann

Setting SYSTEMTAP_TAPSET to some value other than /usr/share/systemtap/tapsets results in systemtap not finding the standard tapset library any more, which in turn breaks tracing because pid() and other standard systemtap functions are not available any more.

So using SYSTEMTAP_TAPSET to point systemtap to the qemu probes will only work for the prefix=/usr installs because both qemu and system tapsets in the same directory then. All other prefixes are broken.

Quoted 6 lines

Fix that by using the "-I $tapsetdir" command line switch instead.

---
 scripts/qemu-trace-stap | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

I'm still a little confused how I ever missed this problem when testing usage !

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw

PATCH v4 2/13 trace: iter init tweaks

In reply to Gerd Hoffmann

Rename trace_event_iter_init() to trace_event_iter_init_pattern(), add trace_event_iter_init_all() for interating over all events.

---
 trace/control.h        | 17 +++++++++++++----
 monitor/misc.c         |  4 ++--
 trace/control-target.c |  2 +-
 trace/control.c        | 16 +++++++++++-----
 trace/qmp.c            |  6 +++---
 trace/simple.c         |  2 +-
 6 files changed, 31 insertions(+), 16 deletions(-)
trace/control.h +13 -4
index 9522a7b318e2..ce40bd040574 100644
@@ -20,15 +20,24 @@ typedef struct TraceEventIter {
 
 
 /**
- * trace_event_iter_init:
+ * trace_event_iter_init_all:
  * @iter: the event iterator struct
- * @pattern: optional pattern to filter events on name
  *
  * Initialize the event iterator struct @iter,
- * optionally using @pattern to filter out events
+ * for all events.
+ */
+void trace_event_iter_init_all(TraceEventIter *iter);
+
+/**
+ * trace_event_iter_init_pattern:
+ * @iter: the event iterator struct
+ * @pattern: pattern to filter events on name
+ *
+ * Initialize the event iterator struct @iter,
+ * using @pattern to filter out events
  * with non-matching names.
  */
-void trace_event_iter_init(TraceEventIter *iter, const char *pattern);
+void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern);
 
 /**
  * trace_event_iter_next:
monitor/misc.c +2 -2
index f3a393ea590b..f9b86bf4a778 100644
@@ -1833,7 +1833,7 @@ void info_trace_events_completion(ReadLineState *rs, int nb_args, const char *st
         TraceEventIter iter;
         TraceEvent *ev;
         char *pattern = g_strdup_printf("%s*", str);
-        trace_event_iter_init(&iter, pattern);
+        trace_event_iter_init_pattern(&iter, pattern);
         while ((ev = trace_event_iter_next(&iter)) != NULL) {
             readline_add_completion(rs, trace_event_get_name(ev));
         }
@@ -1851,7 +1851,7 @@ void trace_event_completion(ReadLineState *rs, int nb_args, const char *str)
         TraceEventIter iter;
         TraceEvent *ev;
         char *pattern = g_strdup_printf("%s*", str);
-        trace_event_iter_init(&iter, pattern);
+        trace_event_iter_init_pattern(&iter, pattern);
         while ((ev = trace_event_iter_next(&iter)) != NULL) {
             readline_add_completion(rs, trace_event_get_name(ev));
         }
trace/control-target.c +1 -1
index e293eeed7c00..8418673c18cf 100644
@@ -127,7 +127,7 @@ void trace_init_vcpu(CPUState *vcpu)
 {
     TraceEventIter iter;
     TraceEvent *ev;
-    trace_event_iter_init(&iter, NULL);
+    trace_event_iter_init_all(&iter);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         if (trace_event_is_vcpu(ev) &&
             trace_event_get_state_static(ev) &&
trace/control.c +11 -5
index 4be38e1af28d..ed38e813b23d 100644
@@ -91,7 +91,7 @@ TraceEvent *trace_event_name(const char *name)
 
     TraceEventIter iter;
     TraceEvent *ev;
-    trace_event_iter_init(&iter, NULL);
+    trace_event_iter_init_all(&iter);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         if (strcmp(trace_event_get_name(ev), name) == 0) {
             return ev;
@@ -100,10 +100,16 @@ TraceEvent *trace_event_name(const char *name)
     return NULL;
 }
 
-void trace_event_iter_init(TraceEventIter *iter, const char *pattern)
+void trace_event_iter_init_all(TraceEventIter *iter)
 {
     iter->event = 0;
     iter->group = 0;
+    iter->pattern = NULL;
+}
+
+void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern)
+{
+    trace_event_iter_init_all(iter);
     iter->pattern = pattern;
 }
 
@@ -130,7 +136,7 @@ void trace_list_events(FILE *f)
 {
     TraceEventIter iter;
     TraceEvent *ev;
-    trace_event_iter_init(&iter, NULL);
+    trace_event_iter_init_all(&iter);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         fprintf(f, "%s\n", trace_event_get_name(ev));
     }
@@ -150,7 +156,7 @@ static void do_trace_enable_events(const char *line_buf)
     TraceEvent *ev;
     bool is_pattern = trace_event_is_pattern(line_ptr);
 
-    trace_event_iter_init(&iter, line_ptr);
+    trace_event_iter_init_pattern(&iter, line_ptr);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         if (!trace_event_get_state_static(ev)) {
             if (!is_pattern) {
@@ -256,7 +262,7 @@ void trace_fini_vcpu(CPUState *vcpu)
 
     trace_guest_cpu_exit(vcpu);
 
-    trace_event_iter_init(&iter, NULL);
+    trace_event_iter_init_all(&iter);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         if (trace_event_is_vcpu(ev) &&
             trace_event_get_state_static(ev) &&
trace/qmp.c +3 -3
index 85f81e47cc6d..3b4f4702b4f0 100644
@@ -55,7 +55,7 @@ static bool check_events(bool has_vcpu, bool ignore_unavailable, bool is_pattern
         /* error for unavailable events */
         TraceEventIter iter;
         TraceEvent *ev;
-        trace_event_iter_init(&iter, name);
+        trace_event_iter_init_pattern(&iter, name);
         while ((ev = trace_event_iter_next(&iter)) != NULL) {
             if (!ignore_unavailable && !trace_event_get_state_static(ev)) {
                 error_setg(errp, "event \"%s\" is disabled", trace_event_get_name(ev));
@@ -90,7 +90,7 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
     }
 
     /* Get states (all errors checked above) */
-    trace_event_iter_init(&iter, name);
+    trace_event_iter_init_pattern(&iter, name);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         TraceEventInfo *value;
         bool is_vcpu = trace_event_is_vcpu(ev);
@@ -153,7 +153,7 @@ void qmp_trace_event_set_state(const char *name, bool enable,
     }
 
     /* Apply changes (all errors checked above) */
-    trace_event_iter_init(&iter, name);
+    trace_event_iter_init_pattern(&iter, name);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         if (!trace_event_get_state_static(ev) ||
             (has_vcpu && !trace_event_is_vcpu(ev))) {
trace/simple.c +1 -1
index 9cd2ed1fb3f4..97b6f85168e7 100644
@@ -286,7 +286,7 @@ static int st_write_event_mapping(void)
     TraceEventIter iter;
     TraceEvent *ev;
 
-    trace_event_iter_init(&iter, NULL);
+    trace_event_iter_init_all(&iter);
     while ((ev = trace_event_iter_next(&iter)) != NULL) {
         uint64_t id = trace_event_get_id(ev);
         const char *name = trace_event_get_name(ev);
Signature · 1 line
2.31.1
#5 lore raw

PATCH v4 3/13 trace: add trace_event_iter_init_group

In reply to Gerd Hoffmann

This allows to interate over an event group.

---
 trace/control.h | 13 +++++++++++++
 trace/control.c | 19 ++++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)
trace/control.h +13 -0
index ce40bd040574..23b8393b297e 100644
@@ -13,8 +13,11 @@
 #include "event-internal.h"
 
 typedef struct TraceEventIter {
+    /* iter state */
     size_t event;
     size_t group;
+    /* filter conditions */
+    size_t group_id;
     const char *pattern;
 } TraceEventIter;
 
@@ -39,6 +42,16 @@ void trace_event_iter_init_all(TraceEventIter *iter);
  */
 void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern);
 
+/**
+ * trace_event_iter_init_group:
+ * @iter: the event iterator struct
+ * @group_id: group_id to filter events by group.
+ *
+ * Initialize the event iterator struct @iter,
+ * using @group_id to filter for events in the group.
+ */
+void trace_event_iter_init_group(TraceEventIter *iter, size_t group_id);
+
 /**
  * trace_event_iter_next:
  * @iter: the event iterator struct
trace/control.c +16 -3
index ed38e813b23d..2c904b7ee4c6 100644
@@ -104,6 +104,7 @@ void trace_event_iter_init_all(TraceEventIter *iter)
 {
     iter->event = 0;
     iter->group = 0;
+    iter->group_id = -1;
     iter->pattern = NULL;
 }
 
@@ -113,20 +114,32 @@ void trace_event_iter_init_pattern(TraceEventIter *iter, const char *pattern)
     iter->pattern = pattern;
 }
 
+void trace_event_iter_init_group(TraceEventIter *iter, size_t group_id)
+{
+    trace_event_iter_init_all(iter);
+    iter->group_id = group_id;
+}
+
 TraceEvent *trace_event_iter_next(TraceEventIter *iter)
 {
     while (iter->group < nevent_groups &&
            event_groups[iter->group].events[iter->event] != NULL) {
         TraceEvent *ev = event_groups[iter->group].events[iter->event];
+        size_t group = iter->group;
         iter->event++;
         if (event_groups[iter->group].events[iter->event] == NULL) {
             iter->event = 0;
             iter->group++;
         }
-        if (!iter->pattern ||
-            g_pattern_match_simple(iter->pattern, trace_event_get_name(ev))) {
-            return ev;
+        if (iter->pattern &&
+            !g_pattern_match_simple(iter->pattern, trace_event_get_name(ev))) {
+            continue;
         }
+        if (iter->group_id != -1 &&
+            iter->group_id != group) {
+            continue;
+        }
+        return ev;
     }
 
     return NULL;
Signature · 1 line
2.31.1
#6 lore raw

PATCH v4 4/13 trace/simple: pass iter to st_write_event_mapping

In reply to Gerd Hoffmann

Pass an iter to st_write_event_mapping, so the function can interate different things depending on how we initialize the iter.

---
 trace/simple.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
trace/simple.c +5 -5
index 97b6f85168e7..ec2156d135cb 100644
@@ -280,14 +280,12 @@ void trace_record_finish(TraceBufferRecord *rec)
     }
 }
 
-static int st_write_event_mapping(void)
+static int st_write_event_mapping(TraceEventIter *iter)
 {
     uint64_t type = TRACE_RECORD_TYPE_MAPPING;
-    TraceEventIter iter;
     TraceEvent *ev;
 
-    trace_event_iter_init_all(&iter);
-    while ((ev = trace_event_iter_next(&iter)) != NULL) {
+    while ((ev = trace_event_iter_next(iter)) != NULL) {
         uint64_t id = trace_event_get_id(ev);
         const char *name = trace_event_get_name(ev);
         uint32_t len = strlen(name);
@@ -309,6 +307,7 @@ static int st_write_event_mapping(void)
  */
 bool st_set_trace_file_enabled(bool enable)
 {
+    TraceEventIter iter;
     bool was_enabled = trace_fp;
 
     if (enable == !!trace_fp) {
@@ -333,8 +332,9 @@ bool st_set_trace_file_enabled(bool enable)
             return was_enabled;
         }
 
+        trace_event_iter_init_all(&iter);
         if (fwrite(&header, sizeof header, 1, trace_fp) != 1 ||
-            st_write_event_mapping() < 0) {
+            st_write_event_mapping(&iter) < 0) {
             fclose(trace_fp);
             trace_fp = NULL;
             return was_enabled;
Signature · 1 line
2.31.1
#7 lore raw

PATCH v4 5/13 trace/simple: add st_init_group

In reply to Gerd Hoffmann

Add helper function and call it for each trace event group added. Makes sure that events added at module load time are initialized properly.

---
 trace/simple.h  |  1 +
 trace/control.c |  4 ++++
 trace/simple.c  | 12 ++++++++++++
 3 files changed, 17 insertions(+)
trace/simple.h +1 -0
index 26ccbc8b8ae3..ee1983ce5617 100644
@@ -15,6 +15,7 @@ void st_print_trace_file_status(void);
 bool st_set_trace_file_enabled(bool enable);
 void st_set_trace_file(const char *file);
 bool st_init(void);
+void st_init_group(size_t group);
 void st_flush_trace_buffer(void);
 
 typedef struct {
trace/control.c +4 -0
index 2c904b7ee4c6..d5b68e846eeb 100644
@@ -82,6 +82,10 @@ void trace_event_register_group(TraceEvent **events)
     event_groups = g_renew(TraceEventGroup, event_groups, nevent_groups + 1);
     event_groups[nevent_groups].events = events;
     nevent_groups++;
+
+#ifdef CONFIG_TRACE_SIMPLE
+    st_init_group(nevent_groups - 1);
+#endif
 }
 
 
trace/simple.c +12 -0
index ec2156d135cb..ac499edee0d5 100644
@@ -422,3 +422,15 @@ bool st_init(void)
     atexit(st_flush_trace_buffer);
     return true;
 }
+
+void st_init_group(size_t group)
+{
+    TraceEventIter iter;
+
+    if (!trace_writeout_enabled) {
+        return;
+    }
+
+    trace_event_iter_init_group(&iter, group);
+    st_write_event_mapping(&iter);
+}
Signature · 1 line
2.31.1
#8 lore raw

PATCH v4 6/13 meson: add trace_events_config[]

In reply to Gerd Hoffmann

It's an array of dicts, where each dict holds the configuration for one trace-events file. For now just fill it from trace_events_subdirs.

---
 meson.build       |  1 +
 trace/meson.build | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
meson.build +1 -0
index a45f1a844f13..84a9e17533cb 100644
@@ -1774,6 +1774,7 @@ target_user_arch = {}
 
 # TODO: add each directory to the subdirs from its own meson.build, once
 # we have those
+trace_events_config = []
 trace_events_subdirs = [
   'crypto',
   'qapi',
trace/meson.build +15 -3
index 08f83a15c316..bc946495a714 100644
@@ -2,10 +2,22 @@
 specific_ss.add(files('control-target.c'))
 
 trace_events_files = []
-foreach dir : [ '.' ] + trace_events_subdirs
-  trace_events_file = meson.source_root() / dir / 'trace-events'
+
+trace_events_config += {
+  'file'  : meson.source_root() / 'trace-events',
+  'group' : 'root',
+}
+foreach dir : trace_events_subdirs
+  trace_events_config += {
+    'file'  : meson.source_root() / dir / 'trace-events',
+    'group' : dir.underscorify(),
+  }
+endforeach
+
+foreach c : trace_events_config
+  trace_events_file = c.get('file')
   trace_events_files += [ trace_events_file ]
-  group_name = dir == '.' ? 'root' : dir.underscorify()
+  group_name = c.get('group')
   group = '--group=' + group_name
   fmt = '@0@-' + group_name + '.@1@'
 
Signature · 1 line
2.31.1
#9 lore raw

PATCH v4 7/13 meson: move up hw subdir (specifically before trace subdir)

In reply to Gerd Hoffmann

Needed so trace/meson.build can see trace_events_config[] changes done in hw/*/meson.build.

---
 meson.build | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meson.build +4 -1
index 84a9e17533cb..b1f2e7920977 100644
@@ -1878,6 +1878,10 @@ if 'CONFIG_VHOST_USER' in config_host
   vhost_user = libvhost_user.get_variable('vhost_user_dep')
 endif
 
+# any subdir updating trace_events_config[] must
+# come before the 'trace' subdir.
+subdir('hw')
+
 subdir('qapi')
 subdir('qobject')
 subdir('stubs')
@@ -1988,7 +1992,6 @@ subdir('monitor')
 subdir('net')
 subdir('replay')
 subdir('semihosting')
-subdir('hw')
 subdir('accel')
 subdir('plugins')
 subdir('bsd-user')
Signature · 1 line
2.31.1
#11 lore raw

PATCH v4 8/13 meson: add module_trace & module_trace_src

In reply to Gerd Hoffmann

module_trace is a dict which keeps track of the trace source files for a module.

module_trace_src collects the trace source files for a given trace-events file, which then either added to the source set or to a new module_trace dict depending on whenever they are for a module or core qemu.

---
 meson.build       |  5 ++++-
 trace/meson.build | 17 ++++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)
meson.build +4 -1
index b1f2e7920977..0e1c2f995d79 100644
@@ -1763,6 +1763,7 @@ user_ss = ss.source_set()
 util_ss = ss.source_set()
 
 modules = {}
+module_trace = {}
 hw_arch = {}
 target_arch = {}
 target_softmmu_arch = {}
@@ -2017,7 +2018,9 @@ foreach d, list : modules
   foreach m, module_ss : list
     if enable_modules and targetos != 'windows'
       module_ss = module_ss.apply(config_all, strict: false)
-      sl = static_library(d + '-' + m, [genh, module_ss.sources()],
+      module_trace_cfg = module_trace.get(d + '-' + m, {})
+      module_trace_src = module_trace_cfg.get('src', [])
+      sl = static_library(d + '-' + m, [genh, module_ss.sources(), module_trace_src],
                           dependencies: [modulecommon, module_ss.dependencies()], pic: true)
       if d == 'block'
         block_mods += sl
trace/meson.build +12 -5
index bc946495a714..834ebaa7cc5f 100644
@@ -17,9 +17,11 @@ endforeach
 foreach c : trace_events_config
   trace_events_file = c.get('file')
   trace_events_files += [ trace_events_file ]
-  group_name = c.get('group')
+  module_name = c.get('module', '')
+  group_name = c.get('group', module_name.underscorify())
   group = '--group=' + group_name
   fmt = '@0@-' + group_name + '.@1@'
+  module_trace_src = []
 
   trace_h = custom_target(fmt.format('trace', 'h'),
                           output: fmt.format('trace', 'h'),
@@ -38,10 +40,10 @@ foreach c : trace_events_config
                                 input: trace_events_file,
                                 command: [ tracetool, group, '--format=ust-events-h', '@INPUT@', '@OUTPUT@' ],
                                 depend_files: tracetool_depends)
-    trace_ss.add(trace_ust_h, lttng, urcubp)
+    module_trace_src += [ trace_ust_h, lttng, urcubp ]
     genh += trace_ust_h
   endif
-  trace_ss.add(trace_h, trace_c)
+  module_trace_src += [ trace_h, trace_c ]
   if 'CONFIG_TRACE_DTRACE' in config_host
     trace_dtrace = custom_target(fmt.format('trace-dtrace', 'dtrace'),
                                  output: fmt.format('trace-dtrace', 'dtrace'),
@@ -52,17 +54,22 @@ foreach c : trace_events_config
                                    output: fmt.format('trace-dtrace', 'h'),
                                    input: trace_dtrace,
                                    command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ])
-    trace_ss.add(trace_dtrace_h)
+    module_trace_src += trace_dtrace_h
     if host_machine.system() != 'darwin'
       trace_dtrace_o = custom_target(fmt.format('trace-dtrace', 'o'),
                                      output: fmt.format('trace-dtrace', 'o'),
                                      input: trace_dtrace,
                                      command: [ 'dtrace', '-DSTAP_SDT_V2', '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ])
-      trace_ss.add(trace_dtrace_o)
+      module_trace_src += trace_dtrace_o
     endif
 
     genh += trace_dtrace_h
   endif
+  if enable_modules and module_name != ''
+    module_trace += { module_name : { 'src' : module_trace_src } }
+  else
+    trace_ss.add(module_trace_src)
+  endif
 endforeach
 
 trace_events_all = custom_target('trace-events-all',
Signature · 1 line
2.31.1
#12 lore raw

PATCH v4 9/13 trace/stap: build stap files for modules

In reply to Gerd Hoffmann
---
 meson.build       | 32 ++++++++++++++++++++++++++++++++
 trace/meson.build |  5 +++--
 2 files changed, 35 insertions(+), 2 deletions(-)
meson.build +32 -0
index 0e1c2f995d79..51fc261a22d3 100644
@@ -2020,6 +2020,7 @@ foreach d, list : modules
       module_ss = module_ss.apply(config_all, strict: false)
       module_trace_cfg = module_trace.get(d + '-' + m, {})
       module_trace_src = module_trace_cfg.get('src', [])
+      module_trace_evt = module_trace_cfg.get('evt', '')
       sl = static_library(d + '-' + m, [genh, module_ss.sources(), module_trace_src],
                           dependencies: [modulecommon, module_ss.dependencies()], pic: true)
       if d == 'block'
@@ -2027,6 +2028,37 @@ foreach d, list : modules
       else
         softmmu_mods += sl
       endif
+      if 'CONFIG_TRACE_SYSTEMTAP' in config_host and module_trace_evt != ''
+        modname = d + '-' + m
+	modlib = modname + '.so'
+        foreach stp: [
+          {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / modlib, 'install': false},
+          {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / qemu_moddir / modlib, 'install': true},
+          {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
+          {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
+        ]
+          foreach target : target_dirs
+            config_target = config_target_mak[target]
+            target_name = config_target['TARGET_NAME']
+            if target.endswith('-softmmu')
+              custom_target(modname + '-' + target_name + stp['ext'],
+                            input: module_trace_evt,
+                            output: modname + '-' + target_name + stp['ext'],
+                            install: stp['install'],
+                            install_dir: get_option('datadir') / 'systemtap/tapset',
+                            command: [
+                              tracetool, '--group=all', '--format=' + stp['fmt'],
+                              '--binary=' + stp['bin'],
+                              '--target-name=' + target_name,
+                              '--target-type=system',
+                              '--probe-prefix=qemu.system.' + target_name,
+                              '@INPUT@', '@OUTPUT@'
+                            ],
+                            depend_files: tracetool_depends)
+            endif
+          endforeach
+        endforeach
+      endif
     else
       if d == 'block'
         block_ss.add_all(module_ss)
trace/meson.build +3 -2
index 834ebaa7cc5f..82332a4a772b 100644
@@ -16,7 +16,6 @@ endforeach
 
 foreach c : trace_events_config
   trace_events_file = c.get('file')
-  trace_events_files += [ trace_events_file ]
   module_name = c.get('module', '')
   group_name = c.get('group', module_name.underscorify())
   group = '--group=' + group_name
@@ -66,9 +65,11 @@ foreach c : trace_events_config
     genh += trace_dtrace_h
   endif
   if enable_modules and module_name != ''
-    module_trace += { module_name : { 'src' : module_trace_src } }
+    module_trace += { module_name : { 'src' : module_trace_src,
+                                      'evt' : trace_events_file } }
   else
     trace_ss.add(module_trace_src)
+    trace_events_files += [ trace_events_file ]
   endif
 endforeach
 
Signature · 1 line
2.31.1
Reviewed-by on v4 9/13
#13 lore raw

Re: [PATCH v4 09/13] trace/stap: build stap files for modules

meson.build foreach d, list : modules · line 2033

Quoted 7 lines · Gerd Hoffmann
meson.build +3 -0
@@ -2027,6 +2028,37 @@ foreach d, list : modules
       else
         softmmu_mods += sl
       endif
+      if 'CONFIG_TRACE_SYSTEMTAP' in config_host and module_trace_evt != ''
+        modname = d + '-' + m
+	modlib = modname + '.so'

Indentation looks odd. Otherwise:

#14 lore raw

PATCH v4 10/13 meson: move qxl trace events to separate file

In reply to Gerd Hoffmann

Move qxl trace events to separate trace-events-qxl file.

---
 hw/display/trace-qxl.h      |  1 +
 hw/display/qxl-render.c     |  2 +-
 hw/display/qxl.c            |  2 +-
 hw/display/meson.build      |  4 +++
 hw/display/trace-events     | 67 -------------------------------------
 hw/display/trace-events-qxl | 66 ++++++++++++++++++++++++++++++++++++
 6 files changed, 73 insertions(+), 69 deletions(-)
 create mode 100644 hw/display/trace-qxl.h
 create mode 100644 hw/display/trace-events-qxl
hw/display/trace-qxl.h new file +1 -0
new file mode 100644
index 000000000000..aa6355abc34e
@@ -0,0 +1 @@
+#include "trace/trace-hw_display_qxl.h"
hw/display/qxl-render.c +1 -1
index d28849b12176..7a61a750f5a0 100644
@@ -22,7 +22,7 @@
 #include "qemu/osdep.h"
 #include "qxl.h"
 #include "sysemu/runstate.h"
-#include "trace.h"
+#include "trace-qxl.h"
 
 static void qxl_blit(PCIQXLDevice *qxl, QXLRect *rect)
 {
hw/display/qxl.c +1 -1
index 6e1f8ff1b2a7..9d936cbac049 100644
@@ -32,7 +32,7 @@
 #include "sysemu/runstate.h"
 #include "migration/blocker.h"
 #include "migration/vmstate.h"
-#include "trace.h"
+#include "trace-qxl.h"
 
 #include "qxl.h"
 
hw/display/meson.build +4 -0
index e1f473c1dff5..ac98861986d1 100644
@@ -42,6 +42,10 @@ if config_all_devices.has_key('CONFIG_QXL')
   qxl_ss = ss.source_set()
   qxl_ss.add(when: 'CONFIG_QXL', if_true: [files('qxl.c', 'qxl-logger.c', 'qxl-render.c'),
                                            pixman, spice])
+  trace_events_config += {
+    'file'   : meson.source_root() / 'hw' / 'display' / 'trace-events-qxl',
+    'module' : 'hw-display-qxl',
+  }
   hw_display_modules += {'qxl': qxl_ss}
 endif
 
hw/display/trace-events +0 -67

73 lines not on this page · raw message

hw/display/trace-events-qxl new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.31.1
#15 lore raw

PATCH v4 11/13 virtio-gpu: split trace points

In reply to Gerd Hoffmann

Create separate trace points for the simple and virgl variants of the virtio-gpu device.

---
 hw/display/virtio-gpu-virgl.c | 48 +++++++++++++++++------------------
 hw/display/trace-events       | 30 ++++++++++++++--------
 2 files changed, 43 insertions(+), 35 deletions(-)
hw/display/virtio-gpu-virgl.c +24 -24
index 092c6dc380d9..ae48b98382ad 100644
@@ -28,8 +28,8 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g,
     struct virgl_renderer_resource_create_args args;
 
     VIRTIO_GPU_FILL_CMD(c2d);
-    trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format,
-                                       c2d.width, c2d.height);
+    trace_virtio_gpu_gl_cmd_res_create_2d(c2d.resource_id, c2d.format,
+                                          c2d.width, c2d.height);
 
     args.handle = c2d.resource_id;
     args.target = 2;
@@ -52,8 +52,8 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
     struct virgl_renderer_resource_create_args args;
 
     VIRTIO_GPU_FILL_CMD(c3d);
-    trace_virtio_gpu_cmd_res_create_3d(c3d.resource_id, c3d.format,
-                                       c3d.width, c3d.height, c3d.depth);
+    trace_virtio_gpu_gl_cmd_res_create_3d(c3d.resource_id, c3d.format,
+                                          c3d.width, c3d.height, c3d.depth);
 
     args.handle = c3d.resource_id;
     args.target = c3d.target;
@@ -77,7 +77,7 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g,
     int num_iovs = 0;
 
     VIRTIO_GPU_FILL_CMD(unref);
-    trace_virtio_gpu_cmd_res_unref(unref.resource_id);
+    trace_virtio_gpu_gl_cmd_res_unref(unref.resource_id);
 
     virgl_renderer_resource_detach_iov(unref.resource_id,
                                        &res_iovs,
@@ -94,8 +94,8 @@ static void virgl_cmd_context_create(VirtIOGPU *g,
     struct virtio_gpu_ctx_create cc;
 
     VIRTIO_GPU_FILL_CMD(cc);
-    trace_virtio_gpu_cmd_ctx_create(cc.hdr.ctx_id,
-                                    cc.debug_name);
+    trace_virtio_gpu_gl_cmd_ctx_create(cc.hdr.ctx_id,
+                                       cc.debug_name);
 
     virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen,
                                   cc.debug_name);
@@ -107,7 +107,7 @@ static void virgl_cmd_context_destroy(VirtIOGPU *g,
     struct virtio_gpu_ctx_destroy cd;
 
     VIRTIO_GPU_FILL_CMD(cd);
-    trace_virtio_gpu_cmd_ctx_destroy(cd.hdr.ctx_id);
+    trace_virtio_gpu_gl_cmd_ctx_destroy(cd.hdr.ctx_id);
 
     virgl_renderer_context_destroy(cd.hdr.ctx_id);
 }
@@ -129,8 +129,8 @@ static void virgl_cmd_resource_flush(VirtIOGPU *g,
     int i;
 
     VIRTIO_GPU_FILL_CMD(rf);
-    trace_virtio_gpu_cmd_res_flush(rf.resource_id,
-                                   rf.r.width, rf.r.height, rf.r.x, rf.r.y);
+    trace_virtio_gpu_gl_cmd_res_flush(rf.resource_id,
+                                      rf.r.width, rf.r.height, rf.r.x, rf.r.y);
 
     for (i = 0; i < g->parent_obj.conf.max_outputs; i++) {
         if (g->parent_obj.scanout[i].resource_id != rf.resource_id) {
@@ -148,8 +148,8 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
     int ret;
 
     VIRTIO_GPU_FILL_CMD(ss);
-    trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id,
-                                     ss.r.width, ss.r.height, ss.r.x, ss.r.y);
+    trace_virtio_gpu_gl_cmd_set_scanout(ss.scanout_id, ss.resource_id,
+                                        ss.r.width, ss.r.height, ss.r.x, ss.r.y);
 
     if (ss.scanout_id >= g->parent_obj.conf.max_outputs) {
         qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified %d",
@@ -194,7 +194,7 @@ static void virgl_cmd_submit_3d(VirtIOGPU *g,
     size_t s;
 
     VIRTIO_GPU_FILL_CMD(cs);
-    trace_virtio_gpu_cmd_ctx_submit(cs.hdr.ctx_id, cs.size);
+    trace_virtio_gpu_gl_cmd_ctx_submit(cs.hdr.ctx_id, cs.size);
 
     buf = g_malloc(cs.size);
     s = iov_to_buf(cmd->elem.out_sg, cmd->elem.out_num,
@@ -224,7 +224,7 @@ static void virgl_cmd_transfer_to_host_2d(VirtIOGPU *g,
     struct virtio_gpu_box box;
 
     VIRTIO_GPU_FILL_CMD(t2d);
-    trace_virtio_gpu_cmd_res_xfer_toh_2d(t2d.resource_id);
+    trace_virtio_gpu_gl_cmd_res_xfer_toh_2d(t2d.resource_id);
 
     box.x = t2d.r.x;
     box.y = t2d.r.y;
@@ -248,7 +248,7 @@ static void virgl_cmd_transfer_to_host_3d(VirtIOGPU *g,
     struct virtio_gpu_transfer_host_3d t3d;
 
     VIRTIO_GPU_FILL_CMD(t3d);
-    trace_virtio_gpu_cmd_res_xfer_toh_3d(t3d.resource_id);
+    trace_virtio_gpu_gl_cmd_res_xfer_toh_3d(t3d.resource_id);
 
     virgl_renderer_transfer_write_iov(t3d.resource_id,
                                       t3d.hdr.ctx_id,
@@ -266,7 +266,7 @@ virgl_cmd_transfer_from_host_3d(VirtIOGPU *g,
     struct virtio_gpu_transfer_host_3d tf3d;
 
     VIRTIO_GPU_FILL_CMD(tf3d);
-    trace_virtio_gpu_cmd_res_xfer_fromh_3d(tf3d.resource_id);
+    trace_virtio_gpu_gl_cmd_res_xfer_fromh_3d(tf3d.resource_id);
 
     virgl_renderer_transfer_read_iov(tf3d.resource_id,
                                      tf3d.hdr.ctx_id,
@@ -287,7 +287,7 @@ static void virgl_resource_attach_backing(VirtIOGPU *g,
     int ret;
 
     VIRTIO_GPU_FILL_CMD(att_rb);
-    trace_virtio_gpu_cmd_res_back_attach(att_rb.resource_id);
+    trace_virtio_gpu_gl_cmd_res_back_attach(att_rb.resource_id);
 
     ret = virtio_gpu_create_mapping_iov(g, att_rb.nr_entries, sizeof(att_rb),
                                         cmd, NULL, &res_iovs, &res_niov);
@@ -311,7 +311,7 @@ static void virgl_resource_detach_backing(VirtIOGPU *g,
     int num_iovs = 0;
 
     VIRTIO_GPU_FILL_CMD(detach_rb);
-    trace_virtio_gpu_cmd_res_back_detach(detach_rb.resource_id);
+    trace_virtio_gpu_gl_cmd_res_back_detach(detach_rb.resource_id);
 
     virgl_renderer_resource_detach_iov(detach_rb.resource_id,
                                        &res_iovs,
@@ -329,8 +329,8 @@ static void virgl_cmd_ctx_attach_resource(VirtIOGPU *g,
     struct virtio_gpu_ctx_resource att_res;
 
     VIRTIO_GPU_FILL_CMD(att_res);
-    trace_virtio_gpu_cmd_ctx_res_attach(att_res.hdr.ctx_id,
-                                        att_res.resource_id);
+    trace_virtio_gpu_gl_cmd_ctx_res_attach(att_res.hdr.ctx_id,
+                                           att_res.resource_id);
 
     virgl_renderer_ctx_attach_resource(att_res.hdr.ctx_id, att_res.resource_id);
 }
@@ -341,8 +341,8 @@ static void virgl_cmd_ctx_detach_resource(VirtIOGPU *g,
     struct virtio_gpu_ctx_resource det_res;
 
     VIRTIO_GPU_FILL_CMD(det_res);
-    trace_virtio_gpu_cmd_ctx_res_detach(det_res.hdr.ctx_id,
-                                        det_res.resource_id);
+    trace_virtio_gpu_gl_cmd_ctx_res_detach(det_res.hdr.ctx_id,
+                                           det_res.resource_id);
 
     virgl_renderer_ctx_detach_resource(det_res.hdr.ctx_id, det_res.resource_id);
 }
@@ -483,7 +483,7 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
         return;
     }
 
-    trace_virtio_gpu_fence_ctrl(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type);
+    trace_virtio_gpu_gl_fence_ctrl(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type);
     virgl_renderer_create_fence(cmd->cmd_hdr.fence_id, cmd->cmd_hdr.type);
 }
 
@@ -500,7 +500,7 @@ static void virgl_write_fence(void *opaque, uint32_t fence)
         if (cmd->cmd_hdr.fence_id > fence) {
             continue;
         }
-        trace_virtio_gpu_fence_resp(cmd->cmd_hdr.fence_id);
+        trace_virtio_gpu_gl_fence_resp(cmd->cmd_hdr.fence_id);
         virtio_gpu_ctrl_response_nodata(g, cmd, VIRTIO_GPU_RESP_OK_NODATA);
         QTAILQ_REMOVE(&g->fenceq, cmd, next);
         g_free(cmd);
hw/display/trace-events +19 -11
index d9606677a436..9c1c972c29c6 100644
@@ -25,30 +25,38 @@ vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp) "%dx%d @ %d bpp"
 # virtio-gpu-base.c
 virtio_gpu_features(bool virgl) "virgl %d"
 
-# virtio-gpu-3d.c
 # virtio-gpu.c
 virtio_gpu_cmd_get_display_info(void) ""
 virtio_gpu_cmd_get_edid(uint32_t scanout) "scanout %d"
 virtio_gpu_cmd_set_scanout(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
 virtio_gpu_cmd_set_scanout_blob(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
 virtio_gpu_cmd_res_create_2d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h) "res 0x%x, fmt 0x%x, w %d, h %d"
-virtio_gpu_cmd_res_create_3d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h, uint32_t d) "res 0x%x, fmt 0x%x, w %d, h %d, d %d"
 virtio_gpu_cmd_res_create_blob(uint32_t res, uint64_t size) "res 0x%x, size %" PRId64
 virtio_gpu_cmd_res_unref(uint32_t res) "res 0x%x"
 virtio_gpu_cmd_res_back_attach(uint32_t res) "res 0x%x"
 virtio_gpu_cmd_res_back_detach(uint32_t res) "res 0x%x"
 virtio_gpu_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x"
-virtio_gpu_cmd_res_xfer_toh_3d(uint32_t res) "res 0x%x"
-virtio_gpu_cmd_res_xfer_fromh_3d(uint32_t res) "res 0x%x"
 virtio_gpu_cmd_res_flush(uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "res 0x%x, w %d, h %d, x %d, y %d"
-virtio_gpu_cmd_ctx_create(uint32_t ctx, const char *name) "ctx 0x%x, name %s"
-virtio_gpu_cmd_ctx_destroy(uint32_t ctx) "ctx 0x%x"
-virtio_gpu_cmd_ctx_res_attach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
-virtio_gpu_cmd_ctx_res_detach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
-virtio_gpu_cmd_ctx_submit(uint32_t ctx, uint32_t size) "ctx 0x%x, size %d"
 virtio_gpu_update_cursor(uint32_t scanout, uint32_t x, uint32_t y, const char *type, uint32_t res) "scanout %d, x %d, y %d, %s, res 0x%x"
-virtio_gpu_fence_ctrl(uint64_t fence, uint32_t type) "fence 0x%" PRIx64 ", type 0x%x"
-virtio_gpu_fence_resp(uint64_t fence) "fence 0x%" PRIx64
+
+# virtio-gpu-virgl.c
+virtio_gpu_gl_cmd_set_scanout(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_gl_cmd_res_create_2d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h) "res 0x%x, fmt 0x%x, w %d, h %d"
+virtio_gpu_gl_cmd_res_create_3d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h, uint32_t d) "res 0x%x, fmt 0x%x, w %d, h %d, d %d"
+virtio_gpu_gl_cmd_res_unref(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_back_attach(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_back_detach(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_xfer_toh_3d(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_xfer_fromh_3d(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_flush(uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_gl_cmd_ctx_create(uint32_t ctx, const char *name) "ctx 0x%x, name %s"
+virtio_gpu_gl_cmd_ctx_destroy(uint32_t ctx) "ctx 0x%x"
+virtio_gpu_gl_cmd_ctx_res_attach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
+virtio_gpu_gl_cmd_ctx_res_detach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
+virtio_gpu_gl_cmd_ctx_submit(uint32_t ctx, uint32_t size) "ctx 0x%x, size %d"
+virtio_gpu_gl_fence_ctrl(uint64_t fence, uint32_t type) "fence 0x%" PRIx64 ", type 0x%x"
+virtio_gpu_gl_fence_resp(uint64_t fence) "fence 0x%" PRIx64
 
 # vga.c
 vga_std_read_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
Signature · 1 line
2.31.1
Reviewed-by on v4 11/13
#16 lore raw

Re: [PATCH v4 11/13] virtio-gpu: split trace points

Quoted 8 lines · Gerd Hoffmann

Create separate trace points for the simple and virgl variants of the virtio-gpu device.

---
 hw/display/virtio-gpu-virgl.c | 48 +++++++++++++++++------------------
 hw/display/trace-events       | 30 ++++++++++++++--------
 2 files changed, 43 insertions(+), 35 deletions(-)
#17 lore raw

PATCH v4 12/13 meson: move virtio trace events to separate file

In reply to Gerd Hoffmann

Move virtio-gpu trace events to separate trace-events-virtio file.

---
 hw/display/trace-virtio.h      |  1 +
 hw/display/virtio-gpu-base.c   |  2 +-
 hw/display/virtio-gpu.c        |  2 +-
 hw/display/meson.build         |  4 ++++
 hw/display/trace-events        | 17 -----------------
 hw/display/trace-events-virtio | 16 ++++++++++++++++
 6 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 hw/display/trace-virtio.h
 create mode 100644 hw/display/trace-events-virtio
hw/display/trace-virtio.h new file +1 -0
new file mode 100644
index 000000000000..eb0d7dd8fc9f
@@ -0,0 +1 @@
+#include "trace/trace-hw_display_virtio_gpu.h"
hw/display/virtio-gpu-base.c +1 -1
index dd294276cb38..4c654d5af594 100644
@@ -17,7 +17,7 @@
 #include "migration/blocker.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
-#include "trace.h"
+#include "trace-virtio.h"
 
 void
 virtio_gpu_base_reset(VirtIOGPUBase *g)
hw/display/virtio-gpu.c +1 -1
index 4d549377cbc1..a7932126e3c7 100644
@@ -15,7 +15,7 @@
 #include "qemu/units.h"
 #include "qemu/iov.h"
 #include "ui/console.h"
-#include "trace.h"
+#include "trace-virtio.h"
 #include "sysemu/dma.h"
 #include "sysemu/sysemu.h"
 #include "hw/virtio/virtio.h"
hw/display/meson.build +4 -0
index ac98861986d1..645a12a7af99 100644
@@ -62,6 +62,10 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
                     if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c'), pixman])
   virtio_gpu_ss.add(when: 'CONFIG_LINUX', if_true: files('virtio-gpu-udmabuf.c'))
   virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
+  trace_events_config += {
+    'file'   : meson.source_root() / 'hw' / 'display' / 'trace-events-virtio',
+    'module' : 'hw-display-virtio-gpu',
+  }
   hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
 
   virtio_gpu_gl_ss = ss.source_set()
hw/display/trace-events +0 -17
index 9c1c972c29c6..27654aee8799 100644
@@ -22,23 +22,6 @@ vmware_scratch_read(uint32_t index, uint32_t value) "index %d, value 0x%x"
 vmware_scratch_write(uint32_t index, uint32_t value) "index %d, value 0x%x"
 vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp) "%dx%d @ %d bpp"
 
-# virtio-gpu-base.c
-virtio_gpu_features(bool virgl) "virgl %d"
-
-# virtio-gpu.c
-virtio_gpu_cmd_get_display_info(void) ""
-virtio_gpu_cmd_get_edid(uint32_t scanout) "scanout %d"
-virtio_gpu_cmd_set_scanout(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
-virtio_gpu_cmd_set_scanout_blob(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
-virtio_gpu_cmd_res_create_2d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h) "res 0x%x, fmt 0x%x, w %d, h %d"
-virtio_gpu_cmd_res_create_blob(uint32_t res, uint64_t size) "res 0x%x, size %" PRId64
-virtio_gpu_cmd_res_unref(uint32_t res) "res 0x%x"
-virtio_gpu_cmd_res_back_attach(uint32_t res) "res 0x%x"
-virtio_gpu_cmd_res_back_detach(uint32_t res) "res 0x%x"
-virtio_gpu_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x"
-virtio_gpu_cmd_res_flush(uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "res 0x%x, w %d, h %d, x %d, y %d"
-virtio_gpu_update_cursor(uint32_t scanout, uint32_t x, uint32_t y, const char *type, uint32_t res) "scanout %d, x %d, y %d, %s, res 0x%x"
-
 # virtio-gpu-virgl.c
 virtio_gpu_gl_cmd_set_scanout(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
 virtio_gpu_gl_cmd_res_create_2d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h) "res 0x%x, fmt 0x%x, w %d, h %d"
hw/display/trace-events-virtio new file +16 -0
new file mode 100644
index 000000000000..52d5c5152f79
@@ -0,0 +1,16 @@
+# virtio-gpu-base.c
+virtio_gpu_features(bool virgl) "virgl %d"
+
+# virtio-gpu.c
+virtio_gpu_cmd_get_display_info(void) ""
+virtio_gpu_cmd_get_edid(uint32_t scanout) "scanout %d"
+virtio_gpu_cmd_set_scanout(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_cmd_set_scanout_blob(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_cmd_res_create_2d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h) "res 0x%x, fmt 0x%x, w %d, h %d"
+virtio_gpu_cmd_res_create_blob(uint32_t res, uint64_t size) "res 0x%x, size %" PRId64
+virtio_gpu_cmd_res_unref(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_back_attach(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_back_detach(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x"
+virtio_gpu_cmd_res_flush(uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_update_cursor(uint32_t scanout, uint32_t x, uint32_t y, const char *type, uint32_t res) "scanout %d, x %d, y %d, %s, res 0x%x"
Signature · 1 line
2.31.1
Reviewed-by on v4 12/13
#18 lore raw

Re: [PATCH v4 12/13] meson: move virtio trace events to separate file

Quoted 13 lines · Gerd Hoffmann

Move virtio-gpu trace events to separate trace-events-virtio file.

---
 hw/display/trace-virtio.h      |  1 +
 hw/display/virtio-gpu-base.c   |  2 +-
 hw/display/virtio-gpu.c        |  2 +-
 hw/display/meson.build         |  4 ++++
 hw/display/trace-events        | 17 -----------------
 hw/display/trace-events-virtio | 16 ++++++++++++++++
 6 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 hw/display/trace-virtio.h
 create mode 100644 hw/display/trace-events-virtio
#19 lore raw

PATCH v4 13/13 meson: move virtio-gl trace events to separate file

In reply to Gerd Hoffmann

Move virtio-gpu-gl trace events to separate trace-events-virtio-gl file.

---
 hw/display/trace-virtio-gl.h      |  1 +
 hw/display/virtio-gpu-virgl.c     |  2 +-
 hw/display/meson.build            |  4 ++++
 hw/display/trace-events           | 19 -------------------
 hw/display/trace-events-virtio-gl | 18 ++++++++++++++++++
 5 files changed, 24 insertions(+), 20 deletions(-)
 create mode 100644 hw/display/trace-virtio-gl.h
 create mode 100644 hw/display/trace-events-virtio-gl
hw/display/trace-virtio-gl.h new file +1 -0
new file mode 100644
index 000000000000..7fbccbf8bd77
@@ -0,0 +1 @@
+#include "trace/trace-hw_display_virtio_gpu_gl.h"
hw/display/virtio-gpu-virgl.c +1 -1
index ae48b98382ad..16f15ead4c76 100644
@@ -13,7 +13,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/iov.h"
-#include "trace.h"
+#include "trace-virtio-gl.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-gpu.h"
 
hw/display/meson.build +4 -0
index 645a12a7af99..373a0dce7cca 100644
@@ -71,6 +71,10 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
   virtio_gpu_gl_ss = ss.source_set()
   virtio_gpu_gl_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRGL', opengl],
                        if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl])
+  trace_events_config += {
+    'file'   : meson.source_root() / 'hw' / 'display' / 'trace-events-virtio-gl',
+    'module' : 'hw-display-virtio-gpu-gl',
+  }
   hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss}
 endif
 
hw/display/trace-events +0 -19
index 27654aee8799..2127af5a14ef 100644
@@ -22,25 +22,6 @@ vmware_scratch_read(uint32_t index, uint32_t value) "index %d, value 0x%x"
 vmware_scratch_write(uint32_t index, uint32_t value) "index %d, value 0x%x"
 vmware_setmode(uint32_t w, uint32_t h, uint32_t bpp) "%dx%d @ %d bpp"
 
-# virtio-gpu-virgl.c
-virtio_gpu_gl_cmd_set_scanout(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
-virtio_gpu_gl_cmd_res_create_2d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h) "res 0x%x, fmt 0x%x, w %d, h %d"
-virtio_gpu_gl_cmd_res_create_3d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h, uint32_t d) "res 0x%x, fmt 0x%x, w %d, h %d, d %d"
-virtio_gpu_gl_cmd_res_unref(uint32_t res) "res 0x%x"
-virtio_gpu_gl_cmd_res_back_attach(uint32_t res) "res 0x%x"
-virtio_gpu_gl_cmd_res_back_detach(uint32_t res) "res 0x%x"
-virtio_gpu_gl_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x"
-virtio_gpu_gl_cmd_res_xfer_toh_3d(uint32_t res) "res 0x%x"
-virtio_gpu_gl_cmd_res_xfer_fromh_3d(uint32_t res) "res 0x%x"
-virtio_gpu_gl_cmd_res_flush(uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "res 0x%x, w %d, h %d, x %d, y %d"
-virtio_gpu_gl_cmd_ctx_create(uint32_t ctx, const char *name) "ctx 0x%x, name %s"
-virtio_gpu_gl_cmd_ctx_destroy(uint32_t ctx) "ctx 0x%x"
-virtio_gpu_gl_cmd_ctx_res_attach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
-virtio_gpu_gl_cmd_ctx_res_detach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
-virtio_gpu_gl_cmd_ctx_submit(uint32_t ctx, uint32_t size) "ctx 0x%x, size %d"
-virtio_gpu_gl_fence_ctrl(uint64_t fence, uint32_t type) "fence 0x%" PRIx64 ", type 0x%x"
-virtio_gpu_gl_fence_resp(uint64_t fence) "fence 0x%" PRIx64
-
 # vga.c
 vga_std_read_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
 vga_std_write_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
hw/display/trace-events-virtio-gl new file +18 -0
new file mode 100644
index 000000000000..1ccb0388917f
@@ -0,0 +1,18 @@
+# virtio-gpu-virgl.c
+virtio_gpu_gl_cmd_set_scanout(uint32_t id, uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "id %d, res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_gl_cmd_res_create_2d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h) "res 0x%x, fmt 0x%x, w %d, h %d"
+virtio_gpu_gl_cmd_res_create_3d(uint32_t res, uint32_t fmt, uint32_t w, uint32_t h, uint32_t d) "res 0x%x, fmt 0x%x, w %d, h %d, d %d"
+virtio_gpu_gl_cmd_res_unref(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_back_attach(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_back_detach(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_xfer_toh_3d(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_xfer_fromh_3d(uint32_t res) "res 0x%x"
+virtio_gpu_gl_cmd_res_flush(uint32_t res, uint32_t w, uint32_t h, uint32_t x, uint32_t y) "res 0x%x, w %d, h %d, x %d, y %d"
+virtio_gpu_gl_cmd_ctx_create(uint32_t ctx, const char *name) "ctx 0x%x, name %s"
+virtio_gpu_gl_cmd_ctx_destroy(uint32_t ctx) "ctx 0x%x"
+virtio_gpu_gl_cmd_ctx_res_attach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
+virtio_gpu_gl_cmd_ctx_res_detach(uint32_t ctx, uint32_t res) "ctx 0x%x, res 0x%x"
+virtio_gpu_gl_cmd_ctx_submit(uint32_t ctx, uint32_t size) "ctx 0x%x, size %d"
+virtio_gpu_gl_fence_ctrl(uint64_t fence, uint32_t type) "fence 0x%" PRIx64 ", type 0x%x"
+virtio_gpu_gl_fence_resp(uint64_t fence) "fence 0x%" PRIx64
Signature · 1 line
2.31.1
Reviewed-by on v4 13/13
#20 lore raw

Re: [PATCH v4 13/13] meson: move virtio-gl trace events to separate file

Quoted 12 lines · Gerd Hoffmann

Move virtio-gpu-gl trace events to separate trace-events-virtio-gl file.

---
 hw/display/trace-virtio-gl.h      |  1 +
 hw/display/virtio-gpu-virgl.c     |  2 +-
 hw/display/meson.build            |  4 ++++
 hw/display/trace-events           | 19 -------------------
 hw/display/trace-events-virtio-gl | 18 ++++++++++++++++++
 5 files changed, 24 insertions(+), 20 deletions(-)
 create mode 100644 hw/display/trace-virtio-gl.h
 create mode 100644 hw/display/trace-events-virtio-gl
#21 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann

First version that actually works. Only qxl covered for this RfC, other modules will follow once the basics are hashed out.

v4:
- rebase to latest master.
- fix systemtap tracing.
- also cover virtio-gpu modules.
- pick up some review tags.
- misc minor tweaks.

Quoted 8 lines

v3:
- handle initialization of modular tracepoints.

TODO:
Enabling modular tracepoints via -trace cmd line doesn't work yet. Guess we need to store the list somewhere for later re-processing. Error handling is tricky, specifically the "tracepoint doesn't exist" error. Suggestions / ideas are welcome.

Excellent! I think we discussed these TODOs in the past. Can we merge this series in close to its current form or does it degrade the tracing experience (e.g. does the -trace command-line no longer work for trace-events files that were split off into modules)?

Stefan

#22 lore raw
Quoted 20 lines · Stefan Hajnoczi
Quoted 10 lines · Gerd Hoffmann

First version that actually works. Only qxl covered for this RfC, other modules will follow once the basics are hashed out.

v4:
- rebase to latest master.
- fix systemtap tracing.
- also cover virtio-gpu modules.
- pick up some review tags.
- misc minor tweaks.

Quoted 8 lines

v3:
- handle initialization of modular tracepoints.

TODO:
Enabling modular tracepoints via -trace cmd line doesn't work yet. Guess we need to store the list somewhere for later re-processing. Error handling is tricky, specifically the "tracepoint doesn't exist" error. Suggestions / ideas are welcome.

Quoted 4 lines

Excellent! I think we discussed these TODOs in the past. Can we merge this series in close to its current form or does it degrade the tracing experience (e.g. does the -trace command-line no longer work for trace-events files that were split off into modules)?

Main focus for v4 was to make stap work.
The cmd line issue is still there.

Patches 1-5 can be cherry-picked without breaking something.

take care,
Gerd

#23 lore raw
Quoted 26 lines · Gerd Hoffmann
Quoted 20 lines · Stefan Hajnoczi
Quoted 10 lines · Gerd Hoffmann

First version that actually works. Only qxl covered for this RfC, other modules will follow once the basics are hashed out.

v4:
- rebase to latest master.
- fix systemtap tracing.
- also cover virtio-gpu modules.
- pick up some review tags.
- misc minor tweaks.

Quoted 8 lines

v3:
- handle initialization of modular tracepoints.

TODO:
Enabling modular tracepoints via -trace cmd line doesn't work yet. Guess we need to store the list somewhere for later re-processing. Error handling is tricky, specifically the "tracepoint doesn't exist" error. Suggestions / ideas are welcome.

Quoted 4 lines

Excellent! I think we discussed these TODOs in the past. Can we merge this series in close to its current form or does it degrade the tracing experience (e.g. does the -trace command-line no longer work for trace-events files that were split off into modules)?

Quoted 4 lines

Main focus for v4 was to make stap work.
The cmd line issue is still there.

Patches 1-5 can be cherry-picked without breaking something.

Thanks, I have applied Patches 1-5 to my tracing tree:
https://gitlab.com/stefanha/qemu/-/tree/tracing

Stefan