overlay: Monitor interrupts

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-08-25 20:13:31 +01:00
parent 39f9812315
commit c9f0173764
4 changed files with 136 additions and 4 deletions

View File

@ -15,6 +15,8 @@ intel_gpu_overlay_SOURCES = \
cpu-top.c \
debugfs.h \
debugfs.c \
gem-interrupts.h \
gem-interrupts.c \
gem-objects.h \
gem-objects.c \
gpu-top.h \

81
overlay/gem-interrupts.c Normal file
View File

@ -0,0 +1,81 @@
/*
* Copyright © 2013 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gem-interrupts.h"
#include "debugfs.h"
int gem_interrupts_init(struct gem_interrupts *irqs)
{
char buf[1024];
struct stat st;
memset(irqs, 0, sizeof(*irqs));
sprintf(buf, "%s/i915_gem_interrupt", debugfs_dri_path);
if (stat(buf, &st))
return irqs->error = errno;
return 0;
}
int gem_interrupts_update(struct gem_interrupts *irqs)
{
char buf[8192], *b;
int fd, len;
if (irqs->error)
return irqs->error;
sprintf(buf, "%s/i915_gem_interrupt", debugfs_dri_path);
fd = open(buf, 0);
if (fd < 0)
return irqs->error = errno;
len = read(fd, buf, sizeof(buf)-1);
close(fd);
if (len < 0)
return irqs->error = errno;
buf[len] = '\0';
b = strstr(buf, "Interrupts received:");
if (b == NULL)
return irqs->error = ENOENT;
fd = irqs->last_count == 0;
irqs->last_count = irqs->count;
irqs->count = strtoull(b + sizeof("Interrupts received:"), 0, 0);
irqs->delta = irqs->count - irqs->last_count;
return fd ? EAGAIN : 0;
}

38
overlay/gem-interrupts.h Normal file
View File

@ -0,0 +1,38 @@
/*
* Copyright © 2013 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
#ifndef GEM_INTERRUPTS_H
#define GEM_INTERRUPTS_H
#include <stdint.h>
struct gem_interrupts {
long unsigned last_count, count, delta;
int error;
};
int gem_interrupts_init(struct gem_interrupts *irqs);
int gem_interrupts_update(struct gem_interrupts *irqs);
#endif /* GEM_INTERRUPTS_H */

View File

@ -40,6 +40,7 @@
#include "config.h"
#include "cpu-top.h"
#include "debugfs.h"
#include "gem-interrupts.h"
#include "gem-objects.h"
#include "gpu-freq.h"
#include "gpu-top.h"
@ -101,6 +102,7 @@ struct overlay_gpu_perf {
struct overlay_gpu_freq {
struct gpu_freq gpu_freq;
struct rc6 rc6;
struct gem_interrupts irqs;
struct power power;
struct chart current;
struct chart request;
@ -489,6 +491,7 @@ static void init_gpu_freq(struct overlay_context *ctx,
}
rc6_init(&gf->rc6);
gem_interrupts_init(&gf->irqs);
}
static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *gf)
@ -499,6 +502,7 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *
int has_freq = gpu_freq_update(&gf->gpu_freq) == 0;
int has_rc6 = rc6_update(&gf->rc6) == 0;
int has_power = power_update(&gf->power) == 0;
int has_irqs = gem_interrupts_update(&gf->irqs) == 0;
cairo_pattern_t *linear;
cairo_rectangle(ctx->cr, 12-.5, ctx->height/2+6-.5, ctx->width/2-18+1, ctx->height/2-18+1);
@ -545,12 +549,12 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *
y2 += 14;
y2 += 14;
}
if (has_rc6) {
if (has_rc6)
y2 += 14;
}
if (has_power) {
if (has_power)
y2 += 14;
if (has_irqs)
y2 += 14;
}
y1 += -12 - 2;
y2 += -14 + 4;
@ -612,6 +616,13 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *
cairo_show_text(ctx->cr, buf);
y += 14;
}
if (has_irqs) {
sprintf(buf, "Interrupts: %llu", (long long unsigned)gf->irqs.delta);
cairo_move_to(ctx->cr, 12, y);
cairo_show_text(ctx->cr, buf);
y += 14;
}
}
static void init_gem_objects(struct overlay_context *ctx,