dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: "Iddamsetty, Aravind" <aravind.iddamsetty@intel.com>,
	Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 4/5] drm/i915: Account ring buffer and context state storage
Date: Tue, 11 Jul 2023 10:44:27 +0100	[thread overview]
Message-ID: <7a41e871-bca8-116e-5adb-7e5f3e6da47a@linux.intel.com> (raw)
In-Reply-To: <488e77bf-c5f7-8dba-9f1a-7932b5e601d0@intel.com>


On 11/07/2023 10:29, Iddamsetty, Aravind wrote:
> 
> 
> On 07-07-2023 18:32, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Account ring buffers and logical context space against the owning client
>> memory usage stats.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> ---
>>   drivers/gpu/drm/i915/gt/intel_context.c | 13 +++++++++++++
>>   drivers/gpu/drm/i915/i915_drm_client.c  | 10 ++++++++++
>>   drivers/gpu/drm/i915/i915_drm_client.h  |  8 ++++++++
>>   3 files changed, 31 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
>> index a53b26178f0a..8a395b9201e9 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_context.c
>> +++ b/drivers/gpu/drm/i915/gt/intel_context.c
>> @@ -6,6 +6,7 @@
>>   #include "gem/i915_gem_context.h"
>>   #include "gem/i915_gem_pm.h"
>>   
>> +#include "i915_drm_client.h"
>>   #include "i915_drv.h"
>>   #include "i915_trace.h"
>>   
>> @@ -50,6 +51,7 @@ intel_context_create(struct intel_engine_cs *engine)
>>   
>>   int intel_context_alloc_state(struct intel_context *ce)
>>   {
>> +	struct i915_gem_context *ctx;
>>   	int err = 0;
>>   
>>   	if (mutex_lock_interruptible(&ce->pin_mutex))
>> @@ -66,6 +68,17 @@ int intel_context_alloc_state(struct intel_context *ce)
>>   			goto unlock;
>>   
>>   		set_bit(CONTEXT_ALLOC_BIT, &ce->flags);
>> +
>> +		rcu_read_lock();
>> +		ctx = rcu_dereference(ce->gem_context);
>> +		if (ctx && !kref_get_unless_zero(&ctx->ref))
>> +			ctx = NULL;
>> +		rcu_read_unlock();
>> +		if (ctx) {
>> +			if (ctx->client)
>> +				i915_drm_client_add_context(ctx->client, ce);
>> +			i915_gem_context_put(ctx);
>> +		}
>>   	}
>>   
>>   unlock:
>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.c b/drivers/gpu/drm/i915/i915_drm_client.c
>> index 2e5e69edc0f9..ffccb6239789 100644
>> --- a/drivers/gpu/drm/i915/i915_drm_client.c
>> +++ b/drivers/gpu/drm/i915/i915_drm_client.c
>> @@ -144,4 +144,14 @@ bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
>>   
>>   	return true;
>>   }
>> +
>> +void i915_drm_client_add_context(struct i915_drm_client *client,
>> +				 struct intel_context *ce)
> 
> do you think we can rename to i915_drm_client_add_context_objects?

I like it, will do, thanks!

Regards,

Tvrtko

> 
>> +{
>> +	if (ce->state)
>> +		i915_drm_client_add_object(client, ce->state->obj);
>> +
>> +	if (ce->ring != ce->engine->legacy.ring && ce->ring->vma)
>> +		i915_drm_client_add_object(client, ce->ring->vma->obj);
>> +}
>>   #endif
>> diff --git a/drivers/gpu/drm/i915/i915_drm_client.h b/drivers/gpu/drm/i915/i915_drm_client.h
>> index 5f58fdf7dcb8..39616b10a51f 100644
>> --- a/drivers/gpu/drm/i915/i915_drm_client.h
>> +++ b/drivers/gpu/drm/i915/i915_drm_client.h
>> @@ -14,6 +14,7 @@
>>   
>>   #include "i915_file_private.h"
>>   #include "gem/i915_gem_object_types.h"
>> +#include "gt/intel_context_types.h"
>>   
>>   #define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
>>   
>> @@ -70,6 +71,8 @@ void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file);
>>   void i915_drm_client_add_object(struct i915_drm_client *client,
>>   				struct drm_i915_gem_object *obj);
>>   bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj);
>> +void i915_drm_client_add_context(struct i915_drm_client *client,
>> +				 struct intel_context *ce);
>>   #else
>>   static inline void i915_drm_client_add_object(struct i915_drm_client *client,
>>   					      struct drm_i915_gem_object *obj)
>> @@ -79,6 +82,11 @@ static inline void i915_drm_client_add_object(struct i915_drm_client *client,
>>   static inline bool i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
>>   {
>>   }
>> +
>> +static inline void i915_drm_client_add_context(struct i915_drm_client *client,
>> +					       struct intel_context *ce)
>> +{
>> +}
>>   #endif
>>   
>>   #endif /* !__I915_DRM_CLIENT_H__ */
> 
> Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com>
> 
> Thanks,
> Aravind.

  reply	other threads:[~2023-07-11  9:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-07 13:02 [PATCH v5 0/5] fdinfo memory stats Tvrtko Ursulin
2023-07-07 13:02 ` [PATCH 1/5] drm/i915: Add ability for tracking buffer objects per client Tvrtko Ursulin
2023-07-10 10:44   ` [Intel-gfx] " Iddamsetty, Aravind
2023-07-10 13:20     ` Tvrtko Ursulin
2023-07-11  7:48       ` Iddamsetty, Aravind
2023-07-11  9:39         ` Tvrtko Ursulin
2023-07-07 13:02 ` [PATCH 2/5] drm/i915: Record which client owns a VM Tvrtko Ursulin
2023-07-11  9:08   ` Iddamsetty, Aravind
2023-07-07 13:02 ` [PATCH 3/5] drm/i915: Track page table backing store usage Tvrtko Ursulin
2023-07-11  9:08   ` [Intel-gfx] " Iddamsetty, Aravind
2023-07-07 13:02 ` [PATCH 4/5] drm/i915: Account ring buffer and context state storage Tvrtko Ursulin
2023-07-11  9:29   ` [Intel-gfx] " Iddamsetty, Aravind
2023-07-11  9:44     ` Tvrtko Ursulin [this message]
2023-07-07 13:02 ` [PATCH 5/5] drm/i915: Implement fdinfo memory stats printing Tvrtko Ursulin
2023-08-24 11:35   ` [Intel-gfx] " Upadhyay, Tejas
2023-09-20 14:22     ` Tvrtko Ursulin
2023-09-20 14:39       ` Rob Clark

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=7a41e871-bca8-116e-5adb-7e5f3e6da47a@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=aravind.iddamsetty@intel.com \
    --cc=dri-devel@lists.freedesktop.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