[Intel-gfx] [RFC 2/6] drm/i915: Track per-context engine busyness

Chris Wilson chris at chris-wilson.co.uk
Fri May 10 14:22:45 UTC 2019


Quoting Tvrtko Ursulin (2019-05-10 14:22:36)
> +static inline void
> +intel_context_in(struct intel_context *ce, bool submit)
> +{
> +       struct intel_engine_cs *engine = ce->engine;
>         unsigned long flags;
> +       ktime_t now;
>  
>         if (READ_ONCE(engine->stats.enabled) == 0)
>                 return;
>  
>         write_seqlock_irqsave(&engine->stats.lock, flags);
>  
> +       if (submit) {
> +               now = ktime_get();
> +               intel_context_stats_start(&ce->stats, now);
> +       } else {
> +               now = 0;
> +       }
> +
>         if (engine->stats.enabled > 0) {
> -               if (engine->stats.active++ == 0)
> -                       engine->stats.start = ktime_get();
> +               if (engine->stats.active++ == 0) {
> +                       if (!now)
> +                               now = ktime_get();
> +                       engine->stats.start = now;
> +               }
>                 GEM_BUG_ON(engine->stats.active == 0);
>         }
>  
> @@ -473,8 +503,9 @@ intel_engine_context_in(struct intel_engine_cs *engine)
>  }
>  
>  static inline void
> -intel_engine_context_out(struct intel_engine_cs *engine)
> +intel_context_out(struct intel_context *ce)
>  {
> +       struct intel_engine_cs *engine = ce->engine;

ce->bound/ce->inflight at this point.

>         unsigned long flags;
>  
>         if (READ_ONCE(engine->stats.enabled) == 0)
> @@ -483,14 +514,25 @@ intel_engine_context_out(struct intel_engine_cs *engine)
>         write_seqlock_irqsave(&engine->stats.lock, flags);
>  
>         if (engine->stats.enabled > 0) {
> +               struct execlist_port *next_port = &engine->execlists.port[1];
> +               ktime_t now = ktime_get();
>                 ktime_t last;
>  
> +               intel_context_stats_stop(&ce->stats, now);
> +
> +               if (port_isset(next_port)) {
> +                       struct i915_request *next_rq = port_request(next_port);
> +
> +                       intel_context_stats_start(&next_rq->hw_context->stats,
> +                                                 now);

Oh crikey. Yeah, I am thinking we need to bite bullet and add the explicit
tracking to ELSP promotion. As luck would happen...
-Chris


More information about the Intel-gfx mailing list