All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tursulin@ursulin.net>
To: Intel-gfx@lists.freedesktop.org
Subject: [RFC 0/3] Engine utilization tracking
Date: Tue,  9 May 2017 15:09:33 +0100	[thread overview]
Message-ID: <20170509140936.19060-1-tvrtko.ursulin@linux.intel.com> (raw)

From: Tvrtko Ursulin <tvrtko.ursulin@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

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

             reply	other threads:[~2017-05-09 14:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09 14:09 Tvrtko Ursulin [this message]
2017-05-09 14:09 ` [RFC 1/3] drm/i915: Wrap context schedule notification Tvrtko Ursulin
2017-05-09 14:09 ` [RFC 2/3] drm/i915: Engine busy time tracking Tvrtko Ursulin
2017-05-10 12:41   ` Joonas Lahtinen
2017-05-09 14:09 ` [RFC 3/3] drm/i915: Export engine busy stats in debugfs Tvrtko Ursulin
2017-05-09 18:17   ` Dmitry Rogozhkin
2017-05-10  8:30     ` Tvrtko Ursulin
2017-05-10 15:57       ` Dmitry Rogozhkin
2017-05-09 14:26 ` [RFC 0/3] Engine utilization tracking Chris Wilson
2017-05-09 15:16   ` Tvrtko Ursulin
2017-05-09 15:29     ` Chris Wilson
2017-05-09 15:51       ` Tvrtko Ursulin
2017-05-09 18:11         ` Dmitry Rogozhkin
2017-05-10  8:38           ` Tvrtko Ursulin
2017-05-10 15:50             ` Dmitry Rogozhkin
2017-05-10 19:45             ` Daniel Vetter
2017-05-12 17:40               ` Dmitry Rogozhkin
2017-05-10 12:31         ` Chris Wilson
2017-05-09 14:51 ` ✓ Fi.CI.BAT: success for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170509140936.19060-1-tvrtko.ursulin@linux.intel.com \
    --to=tursulin@ursulin.net \
    --cc=Intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.