summaryrefslogtreecommitdiff
path: root/overlay/gpu-perf.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-17 21:14:10 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-17 21:14:10 +0100
commiteed59eac47bae095513a5b1b6286fdd556d8a760 (patch)
tree3937d8c00440dacc50358b1156bd0228a04fc55f /overlay/gpu-perf.c
parentcc9de398cf5232e547e9131d72782732a552fc56 (diff)
overlay: Show per-process wait times
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/gpu-perf.c')
-rw-r--r--overlay/gpu-perf.c55
1 files changed, 47 insertions, 8 deletions
diff --git a/overlay/gpu-perf.c b/overlay/gpu-perf.c
index 87174377..78d1756c 100644
--- a/overlay/gpu-perf.c
+++ b/overlay/gpu-perf.c
@@ -169,27 +169,38 @@ static char *get_comm(pid_t pid, char *comm, int len)
return comm;
}
-static int request_add(struct gpu_perf *gp, const void *event)
+static struct gpu_perf_comm *
+lookup_comm(struct gpu_perf *gp, pid_t pid)
{
- const struct sample_event *sample = event;
struct gpu_perf_comm *comm;
for (comm = gp->comm; comm != NULL; comm = comm->next) {
- if (comm->pid == sample->pid)
+ if (comm->pid == pid)
break;
}
if (comm == NULL) {
- comm = malloc(sizeof(*comm));
+ comm = calloc(1, sizeof(*comm));
if (comm == NULL)
- return 0;
+ return NULL;
comm->next = gp->comm;
gp->comm = comm;
- get_comm(sample->pid, comm->name, sizeof(comm->name));
- comm->pid = sample->pid;
- memset(comm->nr_requests, 0, sizeof(comm->nr_requests));
+ get_comm(pid, comm->name, sizeof(comm->name));
+ comm->pid = pid;
}
+ return comm;
+}
+
+static int request_add(struct gpu_perf *gp, const void *event)
+{
+ const struct sample_event *sample = event;
+ struct gpu_perf_comm *comm;
+
+ comm = lookup_comm(gp, sample->pid);
+ if (comm == NULL)
+ return 0;
+
comm->nr_requests[sample->raw[1]]++;
return 1;
}
@@ -211,6 +222,32 @@ static int flip_complete(struct gpu_perf *gp, const void *event)
return 1;
}
+static int wait_begin(struct gpu_perf *gp, const void *event)
+{
+ const struct sample_event *sample = event;
+ struct gpu_perf_comm *comm;
+
+ comm = lookup_comm(gp, sample->pid);
+ if (comm == NULL)
+ return 0;
+
+ comm->wait_begin = sample->time;
+ return 0;
+}
+
+static int wait_end(struct gpu_perf *gp, const void *event)
+{
+ const struct sample_event *sample = event;
+ struct gpu_perf_comm *comm;
+
+ comm = lookup_comm(gp, sample->pid);
+ if (comm == NULL)
+ return 0;
+
+ comm->wait_time += sample->time - comm->wait_begin;
+ return 0;
+}
+
void gpu_perf_init(struct gpu_perf *gp, unsigned flags)
{
memset(gp, 0, sizeof(*gp));
@@ -220,6 +257,8 @@ void gpu_perf_init(struct gpu_perf *gp, unsigned flags)
perf_tracepoint_open(gp, "i915", "i915_gem_request_add", request_add);
if (perf_tracepoint_open(gp, "i915", "i915_gem_ring_complete", seqno_end) == 0)
perf_tracepoint_open(gp, "i915", "i915_gem_ring_dispatch", seqno_start);
+ if (perf_tracepoint_open(gp, "i915", "i915_gem_request_wait_begin", wait_begin) == 0)
+ perf_tracepoint_open(gp, "i915", "i915_gem_request_wait_end", wait_end);
perf_tracepoint_open(gp, "i915", "i915_flip_complete", flip_complete);
if (gp->nr_events == 0)