[Intel-gfx] [RFC 03/10] drm/i915: Make GEM contexts track DRM clients

Chris Wilson chris at chris-wilson.co.uk
Fri Mar 13 11:00:50 UTC 2020


Quoting Tvrtko Ursulin (2020-03-11 18:26:11)
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 6ca797128aa1..ae236058c87e 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -330,17 +330,17 @@ static void print_context_stats(struct seq_file *m,
>                                 .vm = rcu_access_pointer(ctx->vm),
>                         };
>                         struct drm_file *file = ctx->file_priv->file;
> -                       struct task_struct *task;
>                         char name[80];
>  
>                         rcu_read_lock();
> +
>                         idr_for_each(&file->object_idr, per_file_stats, &stats);
> -                       rcu_read_unlock();
>  
> -                       rcu_read_lock();
> -                       task = pid_task(ctx->pid ?: file->pid, PIDTYPE_PID);
>                         snprintf(name, sizeof(name), "%s",
> -                                task ? task->comm : "<unknown>");
> +                                I915_SELFTEST_ONLY(!ctx->client) ?
> +                                "[kernel]" :
> +                                rcu_dereference(ctx->client->name));
> +
>                         rcu_read_unlock();
>  
>                         print_file_stats(m, name, stats);
> @@ -1059,19 +1059,16 @@ static int i915_context_status(struct seq_file *m, void *unused)
>                 spin_unlock(&i915->gem.contexts.lock);
>  
>                 seq_puts(m, "HW context ");
> -               if (ctx->pid) {
> -                       struct task_struct *task;
> -
> -                       task = get_pid_task(ctx->pid, PIDTYPE_PID);
> -                       if (task) {
> -                               seq_printf(m, "(%s [%d]) ",
> -                                          task->comm, task->pid);
> -                               put_task_struct(task);
> -                       }
> -               } else if (IS_ERR(ctx->file_priv)) {
> -                       seq_puts(m, "(deleted) ");
> +
> +               if (I915_SELFTEST_ONLY(!ctx->client)) {
> +                       seq_puts(m, "([kernel]) ");
>                 } else {
> -                       seq_puts(m, "(kernel) ");
> +                       rcu_read_lock();
> +                       seq_printf(m, "(%s [%d]) %s",
> +                                  rcu_dereference(ctx->client->name),
> +                                  pid_nr(rcu_dereference(ctx->client->pid)),
> +                                  ctx->client->closed ? "(closed) " : "");
> +                       rcu_read_unlock();
>                 }

debugfs is not available during selftests, so we don't need to worry.
-Chris


More information about the Intel-gfx mailing list