[Intel-gfx] [RFC 0/3] Engine utilization tracking
Tvrtko Ursulin
tursulin at ursulin.net
Tue May 9 14:09:33 UTC 2017
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
By popular customer demand here is the prototype for cheap engine utilization
tracking.
It uses static branches so in the default off case it really should be cheap.
It exports the per engine total time something has been executing (in nano-
seconds) in debugfs/i915_engine_stats.
This is a problem for something which would preferrably be a stable ABI but I
needed all of the open, release and read hooks for it to work as I imagined it.
So far I did not come up with a different location which would support that.
Userspace is supposed to open the file and keep re-reading it by seeking to its
beginning. This is because first open and last close are a costly operations,
and also because the most interesting is the relative change between two
sampling periods.
Example code which does this looks like this:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "drmtest.h"
#include "igt_debugfs.h"
int main(void)
{
int drm_fd, fd;
drm_fd = drm_open_driver(DRIVER_INTEL);
fd = igt_debugfs_open(drm_fd, "i915_engine_stats", O_RDONLY);
igt_assert(fd >= 0);
for (;;) {
char buf[4096];
ssize_t ret;
off_t off;
ret = read(fd, buf, sizeof(buf));
igt_assert(ret > 0);
ret = write(1, buf, ret);
printf("\n");
off = lseek(fd, 0, SEEK_SET);
igt_assert_eq(off, 0);
sleep(1);
}
close(fd);
close(drm_fd);
return 0;
}
Comments, flames, ideas welcome!
Tvrtko Ursulin (3):
drm/i915: Wrap context schedule notification
drm/i915: Engine busy time tracking
drm/i915: Export engine busy stats in debugfs
drivers/gpu/drm/i915/i915_debugfs.c | 120 ++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_engine_cs.c | 6 ++
drivers/gpu/drm/i915/intel_lrc.c | 24 +++++--
drivers/gpu/drm/i915/intel_ringbuffer.h | 39 +++++++++++
4 files changed, 182 insertions(+), 7 deletions(-)
--
2.9.3
More information about the Intel-gfx
mailing list