summaryrefslogtreecommitdiff
path: root/overlay/gpu-perf.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-17 22:22:21 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-17 22:22:21 +0100
commit6233cac9c9f264961c62bb1330d8f48b3b6922b5 (patch)
tree5dcd740e10f9339f188915e7fbdcdc621926269c /overlay/gpu-perf.c
parente1d8d774f331ba4e515cad4e5efa91ddc18efad6 (diff)
overlay: Couple wait begin/end events together to fix accounting
Since the events may be processed out of order (due to per-cpu ringbuffers) we need to be careful to associated wait pairs in order to compute the correct elapsed time. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/gpu-perf.c')
-rw-r--r--overlay/gpu-perf.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/overlay/gpu-perf.c b/overlay/gpu-perf.c
index ef170909..653148b8 100644
--- a/overlay/gpu-perf.c
+++ b/overlay/gpu-perf.c
@@ -229,12 +229,21 @@ static int wait_begin(struct gpu_perf *gp, const void *event)
{
const struct sample_event *sample = event;
struct gpu_perf_comm *comm;
+ struct gpu_perf_wait *wait;
comm = lookup_comm(gp, sample->pid);
if (comm == NULL)
return 0;
- comm->wait_begin = sample->time;
+ wait = malloc(sizeof(*wait));
+ if (wait == NULL)
+ return 0;
+
+ wait->seqno = sample->raw[3];
+ wait->time = sample->time;
+ wait->next = comm->wait;
+ comm->wait = wait;
+
return 0;
}
@@ -242,12 +251,22 @@ static int wait_end(struct gpu_perf *gp, const void *event)
{
const struct sample_event *sample = event;
struct gpu_perf_comm *comm;
+ struct gpu_perf_wait *wait, **prev;
comm = lookup_comm(gp, sample->pid);
if (comm == NULL)
return 0;
- comm->wait_time += sample->time - comm->wait_begin;
+ for (prev = &comm->wait; (wait = *prev) != NULL; prev = &wait->next) {
+ if (wait->seqno != sample->raw[3])
+ continue;
+
+ comm->wait_time += sample->time - wait->time;
+ *prev = wait->next;
+ free(wait);
+ return 1;
+ }
+
return 0;
}