[Intel-gfx] [PATCH 06/10] drm/i915: Track runtime spent in closed GEM contexts

Chris Wilson chris at chris-wilson.co.uk
Wed Mar 18 13:57:04 UTC 2020


Quoting Tvrtko Ursulin (2020-03-18 12:11:35)
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> 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.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_context.c | 12 +++++++++++-
>  drivers/gpu/drm/i915/i915_drm_client.h      |  7 +++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 5edf79ed6247..912375fb8a3b 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -355,8 +355,18 @@ static void i915_gem_context_free(struct i915_gem_context *ctx)
>  
>         GEM_BUG_ON(!i915_gem_context_is_closed(ctx));
>  
> -       if (client)
> +       if (client) {
> +               unsigned int i;
> +
> +               /* Transfer accumulated runtime to the parent drm client. */
> +               BUILD_BUG_ON(ARRAY_SIZE(client->past_runtime) !=
> +                            ARRAY_SIZE(ctx->past_runtime));
> +               for (i = 0; i < ARRAY_SIZE(client->past_runtime); i++)
> +                       atomic64_add(atomic64_read(&ctx->past_runtime[i]),
> +                                    &client->past_runtime[i]);
> +
>                 i915_drm_client_put(client);
> +       }

Ok, order looks good.
-Chris


More information about the Intel-gfx mailing list