summaryrefslogtreecommitdiff
path: root/overlay/overlay.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-29 12:01:38 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-29 13:33:58 +0100
commit474ce5396e3dc5a3f057da84cb70a642c0ac90d6 (patch)
tree8fac2e048f53960245430fba74cb597b2c3ab7d0 /overlay/overlay.c
parent75ef36713a75bc46faf5b92a4442869ef6999c3a (diff)
overlay: Monitor per-ring context switch rate
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/overlay.c')
-rw-r--r--overlay/overlay.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/overlay/overlay.c b/overlay/overlay.c
index 65137864..3fddde94 100644
--- a/overlay/overlay.c
+++ b/overlay/overlay.c
@@ -102,6 +102,7 @@ struct overlay_gpu_top {
struct overlay_gpu_perf {
struct gpu_perf gpu_perf;
+ time_t show_ctx;
};
struct overlay_gpu_freq {
@@ -127,6 +128,8 @@ struct overlay_context {
cairo_t *cr;
int width, height;
+ time_t time;
+
struct overlay_gpu_top gpu_top;
struct overlay_gpu_perf gpu_perf;
struct overlay_gpu_freq gpu_freq;
@@ -270,6 +273,8 @@ static void init_gpu_perf(struct overlay_context *ctx,
struct overlay_gpu_perf *gp)
{
gpu_perf_init(&gp->gpu_perf, 0);
+
+ gp->show_ctx = 0;
}
static char *get_comm(pid_t pid, char *comm, int len)
@@ -310,6 +315,16 @@ static void show_gpu_perf(struct overlay_context *ctx, struct overlay_gpu_perf *
char buf[1024];
cairo_pattern_t *linear;
int x, y, y1, y2, n;
+ int has_ctx = 0;
+
+ gpu_perf_update(&gp->gpu_perf);
+
+ for (n = 4; n > 0; n--) {
+ if (gp->gpu_perf.ctx_switch[n-1]) {
+ has_ctx = n;
+ break;
+ }
+ }
cairo_rectangle(ctx->cr, ctx->width/2+HALF_PAD-.5, PAD-.5, ctx->width/2-SIZE_PAD+1, ctx->height/2-SIZE_PAD+1);
cairo_set_source_rgb(ctx->cr, .15, .15, .15);
@@ -326,12 +341,9 @@ static void show_gpu_perf(struct overlay_context *ctx, struct overlay_gpu_perf *
return;
}
- gpu_perf_update(&gp->gpu_perf);
-
y = PAD + 12 - 2;
x = ctx->width/2 + HALF_PAD;
-
for (comm = gp->gpu_perf.comm; comm; comm = comm->next) {
int total;
@@ -369,6 +381,8 @@ static void show_gpu_perf(struct overlay_context *ctx, struct overlay_gpu_perf *
chart_draw(comm->user_data, ctx->cr);
y2 += 14;
}
+ if (has_ctx || gp->show_ctx)
+ y2 += 14;
y1 += -12 - 2;
y2 += 14 - 14 + 4;
@@ -465,6 +479,27 @@ skip_comm:
cairo_move_to(ctx->cr, x, y);
cairo_show_text(ctx->cr, buf);
y += 14;
+
+ cairo_set_source_rgba(ctx->cr, 1, 1, 1, 1);
+ cairo_move_to(ctx->cr, x, y);
+ if (has_ctx) {
+ int len = sprintf(buf, "Contexts:");
+ for (n = 0; n < has_ctx; n++)
+ len += sprintf(buf + len, "%s %d",
+ n ? "," : "",
+ gp->gpu_perf.ctx_switch[n]);
+
+ memset(gp->gpu_perf.ctx_switch, 0, sizeof(gp->gpu_perf.ctx_switch));
+ gp->show_ctx = ctx->time;
+
+ cairo_show_text(ctx->cr, buf);
+ y += 14;
+ } else if (gp->show_ctx) {
+ cairo_show_text(ctx->cr, "Contexts: 0");
+ y += 14;
+ if (ctx->time - gp->show_ctx > 10)
+ gp->show_ctx = 0;
+ }
}
static void init_gpu_freq(struct overlay_context *ctx,
@@ -841,6 +876,8 @@ int main(int argc, char **argv)
i = 0;
while (1) {
+ ctx.time = time(NULL);
+
ctx.cr = cairo_create(ctx.surface);
cairo_set_operator(ctx.cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(ctx.cr);