From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Cc: Rob Clark <robdclark@chromium.org>,
Chris Wilson <chris@chris-wilson.co.uk>
Subject: [Intel-gfx] [PATCH 3/8] drm/i915: Track runtime spent in closed and unreachable GEM contexts
Date: Tue, 22 Feb 2022 14:04:17 +0000 [thread overview]
Message-ID: <20220222140422.1121163-4-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20220222140422.1121163-1-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
As contexts are abandoned we want to remember how much GPU time they used
(per class) so later we can used it for smarter purposes.
As GEM contexts are closed we want to have the DRM client remember how
much GPU time they used (per class) so later we can used it for smarter
purposes.
v2:
* Size past runtimes array by uabi class, not internal.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> # v1
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> # v1
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> # v1
---
drivers/gpu/drm/i915/gem/i915_gem_context.c | 25 +++++++++++++++++++--
drivers/gpu/drm/i915/i915_drm_client.h | 9 ++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index b45f20c71588..46bee8b694ad 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1020,23 +1020,44 @@ static void free_engines_rcu(struct rcu_head *rcu)
free_engines(engines);
}
+static void accumulate_runtime(struct i915_drm_client *client,
+ struct i915_gem_engines *engines)
+{
+ struct i915_gem_engines_iter it;
+ struct intel_context *ce;
+
+ if (!client)
+ return;
+
+ /* Transfer accumulated runtime to the parent GEM context. */
+ for_each_gem_engine(ce, engines, it) {
+ unsigned int class = ce->engine->uabi_class;
+
+ GEM_BUG_ON(class >= ARRAY_SIZE(client->past_runtime));
+ atomic64_add(intel_context_get_total_runtime_ns(ce),
+ &client->past_runtime[class]);
+ }
+}
+
static int
engines_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
{
struct i915_gem_engines *engines =
container_of(fence, typeof(*engines), fence);
+ struct i915_gem_context *ctx = engines->ctx;
switch (state) {
case FENCE_COMPLETE:
if (!list_empty(&engines->link)) {
- struct i915_gem_context *ctx = engines->ctx;
unsigned long flags;
spin_lock_irqsave(&ctx->stale.lock, flags);
list_del(&engines->link);
spin_unlock_irqrestore(&ctx->stale.lock, flags);
}
- i915_gem_context_put(engines->ctx);
+ accumulate_runtime(ctx->client, engines);
+ i915_gem_context_put(ctx);
+
break;
case FENCE_FREE:
diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
index e8986ad51176..cbc3161ab021 100644
--- a/drivers/gpu/drm/i915/i915_drm_client.h
+++ b/drivers/gpu/drm/i915/i915_drm_client.h
@@ -9,6 +9,10 @@
#include <linux/kref.h>
#include <linux/xarray.h>
+#include "gt/intel_engine_types.h"
+
+#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_VIDEO_ENHANCE
+
struct drm_i915_private;
struct i915_drm_clients {
@@ -24,6 +28,11 @@ struct i915_drm_client {
unsigned int id;
struct i915_drm_clients *clients;
+
+ /**
+ * @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
+ */
+ atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
};
void i915_drm_clients_init(struct i915_drm_clients *clients,
--
2.32.0
next prev parent reply other threads:[~2022-02-22 14:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 14:04 [Intel-gfx] [PATCH 0/8] Per client GPU utilisation Tvrtko Ursulin
2022-02-22 14:04 ` [Intel-gfx] [PATCH 1/8] drm/i915: Explicitly track DRM clients Tvrtko Ursulin
2022-02-22 14:04 ` [Intel-gfx] [PATCH 2/8] drm/i915: Make GEM contexts " Tvrtko Ursulin
2022-02-22 14:04 ` Tvrtko Ursulin [this message]
2022-02-22 14:04 ` [Intel-gfx] [PATCH 4/8] drm/i915: Track all user contexts per client Tvrtko Ursulin
2022-02-22 14:04 ` [Intel-gfx] [PATCH 5/8] drm/i915: Track context current active time Tvrtko Ursulin
2022-02-22 14:04 ` [Intel-gfx] [PATCH 6/8] drm: Document fdinfo format specification Tvrtko Ursulin
2022-02-22 14:04 ` [Intel-gfx] [PATCH 7/8] drm/i915: Count engine instances per uabi class Tvrtko Ursulin
2022-03-01 19:34 ` Umesh Nerlige Ramappa
2022-03-02 9:03 ` Tvrtko Ursulin
2022-03-04 0:06 ` Umesh Nerlige Ramappa
2022-02-22 14:04 ` [Intel-gfx] [PATCH 8/8] drm/i915: Expose client engine utilisation via fdinfo Tvrtko Ursulin
2022-03-01 17:40 ` Rob Clark
2022-02-22 21:58 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client GPU utilisation Patchwork
2022-02-22 21:59 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-02-22 22:03 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2022-02-22 22:27 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-02-23 8:52 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-02-23 22:44 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client GPU utilisation (rev2) Patchwork
2022-02-23 22:45 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-02-23 22:49 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2022-02-23 23:11 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-02-24 10:41 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2022-03-31 14:09 [Intel-gfx] [PATCH 0/8] Per client GPU utilisation Tvrtko Ursulin
2022-03-31 14:09 ` [Intel-gfx] [PATCH 3/8] drm/i915: Track runtime spent in closed and unreachable GEM contexts Tvrtko Ursulin
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=20220222140422.1121163-4-tvrtko.ursulin@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=chris@chris-wilson.co.uk \
--cc=robdclark@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox