All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Intel-gfx@lists.freedesktop.org, Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [Intel-gfx] [PATCH 3/9] drm/i915: Make GEM contexts track DRM clients
Date: Fri, 11 Sep 2020 09:52:10 +0100	[thread overview]
Message-ID: <87f8514f-1cae-51a3-e6ad-caf87fb3ebf1@linux.intel.com> (raw)
In-Reply-To: <20200911064406.zkzlupalayyd3wp5@ldmartin-desk1>


On 11/09/2020 07:44, Lucas De Marchi wrote:
> On Fri, Sep 04, 2020 at 01:59:28PM +0100, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> If we make GEM contexts keep a reference to i915_drm_client for the whole
>> of their lifetime, we can consolidate the current task pid and name usage
>> by getting it from the client.
>>
>> v2:
>> * Don't bother supporting selftests contexts from debugfs. (Chris)
>>
>> v3:
>> * Trivial rebase.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>> ---
>> drivers/gpu/drm/i915/gem/i915_gem_context.c   | 19 +++++++++---
>> .../gpu/drm/i915/gem/i915_gem_context_types.h | 13 ++-------
>> drivers/gpu/drm/i915/i915_debugfs.c           | 29 +++++++------------
>> drivers/gpu/drm/i915/i915_gpu_error.c         | 22 ++++++++------
>> 4 files changed, 41 insertions(+), 42 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c 
>> b/drivers/gpu/drm/i915/gem/i915_gem_context.c
>> index 5919cc5f8348..ab8d25eda204 100644
>> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
>> @@ -336,8 +336,13 @@ static struct i915_gem_engines 
>> *default_engines(struct i915_gem_context *ctx)
>>
>> static void i915_gem_context_free(struct i915_gem_context *ctx)
>> {
>> +    struct i915_drm_client *client = ctx->client;
>> +
>>     GEM_BUG_ON(!i915_gem_context_is_closed(ctx));
>>
>> +    if (client)
>> +        i915_drm_client_put(client);
>> +
>>     spin_lock(&ctx->i915->gem.contexts.lock);
>>     list_del(&ctx->link);
>>     spin_unlock(&ctx->i915->gem.contexts.lock);
>> @@ -348,7 +353,6 @@ static void i915_gem_context_free(struct 
>> i915_gem_context *ctx)
>>     if (ctx->timeline)
>>         intel_timeline_put(ctx->timeline);
>>
>> -    put_pid(ctx->pid);
>>     mutex_destroy(&ctx->mutex);
>>
>>     kfree_rcu(ctx, rcu);
>> @@ -936,6 +940,7 @@ static int gem_context_register(struct 
>> i915_gem_context *ctx,
>>                 u32 *id)
>> {
>>     struct drm_i915_private *i915 = ctx->i915;
>> +    struct i915_drm_client *client;
>>     struct i915_address_space *vm;
>>     int ret;
>>
>> @@ -947,9 +952,13 @@ static int gem_context_register(struct 
>> i915_gem_context *ctx,
>>         WRITE_ONCE(vm->file, fpriv); /* XXX */
>>     mutex_unlock(&ctx->mutex);
>>
>> -    ctx->pid = get_task_pid(current, PIDTYPE_PID);
>> +    client = i915_drm_client_get(fpriv->client);
>> +
>> +    rcu_read_lock();
>>     snprintf(ctx->name, sizeof(ctx->name), "%s[%d]",
>> -         current->comm, pid_nr(ctx->pid));
>> +         rcu_dereference(client->name),
>> +         pid_nr(rcu_dereference(client->pid)));
>> +    rcu_read_unlock();
>>
>>     /* And finally expose ourselves to userspace via the idr */
>>     ret = xa_alloc(&fpriv->context_xa, id, ctx, xa_limit_32b, 
>> GFP_KERNEL);
>> @@ -960,10 +969,12 @@ static int gem_context_register(struct 
>> i915_gem_context *ctx,
>>     list_add_tail(&ctx->link, &i915->gem.contexts.list);
>>     spin_unlock(&i915->gem.contexts.lock);
>>
>> +    ctx->client = client;
> 
> as per 5f7cceabf104 ("drm/i915/gem: Delay tracking the GEM context until 
> it is registered")
> shouldn't you finish construct ctx before adding it to the list?

Looks like it, well spotted, thanks!

Regards,

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

  reply	other threads:[~2020-09-11  8:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 12:59 [Intel-gfx] [PATCH 0/9] Per client engine busyness Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 1/9] drm/i915: Expose list of clients in sysfs Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 2/9] drm/i915: Update client name on context create Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 3/9] drm/i915: Make GEM contexts track DRM clients Tvrtko Ursulin
2020-09-11  6:44   ` Lucas De Marchi
2020-09-11  8:52     ` Tvrtko Ursulin [this message]
2020-09-14 15:02     ` Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 4/9] drm/i915: Track runtime spent in unreachable intel_contexts Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 5/9] drm/i915: Track runtime spent in closed GEM contexts Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 6/9] drm/i915: Track all user contexts per client Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 7/9] drm/i915: Expose per-engine client busyness Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 8/9] drm/i915: Track context current active time Tvrtko Ursulin
2020-09-04 12:59 ` [Intel-gfx] [PATCH 9/9] drm/i915: Prefer software tracked context busyness Tvrtko Ursulin
2020-09-04 14:05 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Per client engine busyness Patchwork
2020-09-04 14:06 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2020-09-04 14:21 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-09-05  1:35 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2020-09-14 13:12 [Intel-gfx] [PATCH 0/9] " Tvrtko Ursulin
2020-09-14 13:12 ` [Intel-gfx] [PATCH 3/9] drm/i915: Make GEM contexts track DRM clients Tvrtko Ursulin
2020-04-15 10:11 [Intel-gfx] [PATCH 0/9] Per client engine busyness Tvrtko Ursulin
2020-04-15 10:11 ` [Intel-gfx] [PATCH 3/9] drm/i915: Make GEM contexts track DRM clients 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=87f8514f-1cae-51a3-e6ad-caf87fb3ebf1@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=lucas.demarchi@intel.com \
    /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.