overlay: Count number of semaphores used by each process
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 26 Aug 2013 13:11:27 +0000 (14:11 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 26 Aug 2013 13:34:05 +0000 (14:34 +0100)
This required me to contract the per-process information considerably,
hopefully readability is not sacrificed too much.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
overlay/gpu-perf.c
overlay/gpu-perf.h
overlay/overlay.c

index 61e447d..142357c 100644 (file)
@@ -249,6 +249,19 @@ static int flip_complete(struct gpu_perf *gp, const void *event)
        return 1;
 }
 
+static int ring_sync(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_sema++;
+       return 1;
+}
+
 static int wait_begin(struct gpu_perf *gp, const void *event)
 {
        const struct sample_event *sample = event;
@@ -300,6 +313,7 @@ void gpu_perf_init(struct gpu_perf *gp, unsigned flags)
        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);
+       perf_tracepoint_open(gp, "i915", "i915_gem_ring_sync_to", ring_sync);
 
        if (gp->nr_events == 0) {
                gp->error = "i915.ko tracepoints not available";
index 53699f7..395eb8a 100644 (file)
@@ -50,7 +50,7 @@ struct gpu_perf {
                void *user_data;
 
                uint64_t wait_time;
-               uint64_t busy_time;
+               uint32_t nr_sema;
        } *comm;
        struct gpu_perf_time {
                struct gpu_perf_time *next;
index acbd853..6ee51e8 100644 (file)
@@ -282,9 +282,9 @@ static void show_gpu_perf(struct overlay_context *ctx, struct overlay_gpu_perf *
        };
        struct gpu_perf_comm *comm, **prev;
        const char *ring_name[] = {
-               "render",
-               "video",
-               "blt",
+               "R",
+               "V",
+               "B",
        };
        double range[2];
        char buf[1024];
@@ -361,71 +361,57 @@ static void show_gpu_perf(struct overlay_context *ctx, struct overlay_gpu_perf *
        cairo_fill(ctx->cr);
 
        for (prev = &gp->gpu_perf.comm; (comm = *prev) != NULL; ) {
-               int need_comma = 0;
+               int need_comma = 0, len;
 
-               if (comm->user_data) {
-                       struct chart *c = comm->user_data;
-                       cairo_set_source_rgba(ctx->cr,
-                                             c->stroke_rgb[0],
-                                             c->stroke_rgb[1],
-                                             c->stroke_rgb[2],
-                                             c->stroke_rgb[3]);
-               } else
-                       cairo_set_source_rgba(ctx->cr, 1, 1, 1, 1);
-               cairo_move_to(ctx->cr, x, y);
-               sprintf(buf, "%s:", comm->name);
-               cairo_show_text(ctx->cr, buf);
+               if (comm->name[0] == '\0')
+                       goto skip_comm;
+
+               len = sprintf(buf, "%s:", comm->name);
                for (n = 0; n < 3; n++) {
                        if (comm->nr_requests[n] == 0)
                                continue;
-                       sprintf(buf, "%s %d %s", need_comma ? "," : "", comm->nr_requests[n], ring_name[n]);
-                       cairo_show_text(ctx->cr, buf);
+                       len += sprintf(buf + len, "%s %d%s", need_comma ? "," : "", comm->nr_requests[n], ring_name[n]);
                        need_comma = true;
                }
                if (comm->wait_time) {
-                       buf[0] = '\0';
                        if (comm->wait_time > 1000*1000) {
-                               sprintf(buf, "%s %.1f ms waiting",
-                                       need_comma ? "," : "",
-                                       comm->wait_time / (1000*1000.));
+                               len += sprintf(buf + len, "%s %.1fms waits",
+                                              need_comma ? "," : "",
+                                              comm->wait_time / (1000*1000.));
                        } else if (comm->wait_time > 100) {
-                               sprintf(buf, "%s %.1f us waiting",
-                                       need_comma ? "," : "",
-                                       comm->wait_time / 1000.);
+                               len += sprintf(buf + len, "%s %.1fus waits",
+                                              need_comma ? "," : "",
+                                              comm->wait_time / 1000.);
                        } else {
-                               sprintf(buf, "%s %.0f ns waiting",
-                                       need_comma ? "," : "",
-                                       (double)comm->wait_time);
-                       }
-                       if (buf[0] != '\0') {
-                               cairo_show_text(ctx->cr, buf);
-                               need_comma = true;
+                               len += sprintf(buf, "%s %.0fns waits",
+                                              need_comma ? "," : "",
+                                              (double)comm->wait_time);
                        }
+                       need_comma = true;
                        comm->wait_time = 0;
                }
-               if (comm->busy_time) {
-                       buf[0] = '\0';
-                       if (comm->busy_time > 1000*1000) {
-                               sprintf(buf, "%s %.1f ms busy",
-                                       need_comma ? "," : "",
-                                       comm->busy_time / (1000*1000.));
-                       } else if (comm->busy_time > 100) {
-                               sprintf(buf, "%s %.1f us busy",
-                                       need_comma ? "," : "",
-                                       comm->busy_time / 1000.);
-                       } else {
-                               sprintf(buf, "%s %.0f ns busy",
-                                       need_comma ? "," : "",
-                                       (double)comm->busy_time);
-                       }
-                       if (buf[0] != '\0') {
-                               cairo_show_text(ctx->cr, buf);
-                               need_comma = true;
-                       }
-                       comm->busy_time = 0;
+               if (comm->nr_sema) {
+                       len += sprintf(buf + len, "%s %d syncs",
+                                      need_comma ? "," : "",
+                                      comm->nr_sema);
+                       need_comma = true;
+                       comm->nr_sema = 0;
                }
+
+               if (comm->user_data) {
+                       struct chart *c = comm->user_data;
+                       cairo_set_source_rgba(ctx->cr,
+                                             c->stroke_rgb[0],
+                                             c->stroke_rgb[1],
+                                             c->stroke_rgb[2],
+                                             c->stroke_rgb[3]);
+               } else
+                       cairo_set_source_rgba(ctx->cr, 1, 1, 1, 1);
+               cairo_move_to(ctx->cr, x, y);
+               cairo_show_text(ctx->cr, buf);
                y += 14;
 
+skip_comm:
                memset(comm->nr_requests, 0, sizeof(comm->nr_requests));
                if (strcmp(comm->name, get_comm(comm->pid, buf, sizeof(buf)))) {
                        *prev = comm->next;