[RFC 0/3] Engine utilization tracking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>

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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux