From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 09/12] drm/i915: Create a kmem_cache to allocate struct i915_priolist from
Date: Tue, 16 May 2017 08:57:28 +0100 [thread overview]
Message-ID: <c30de3ca-64ef-9b07-10ce-8a3d1364d859@linux.intel.com> (raw)
In-Reply-To: <20170511195922.15844-9-chris@chris-wilson.co.uk>
On 11/05/2017 20:59, Chris Wilson wrote:
> The i915_priolist are allocated within an atomic context on a path where
> we wish to minimise latency. If we use a dedicated kmem_cache, we have
> the advantage of a local freelist from which to service new requests
> that should keep the latency impact of an allocation small. Though
> currently we expect the majority of requests to be at default priority
> (and so hit the preallocate priolist), once userspace starts using
> priorities they are likely to use many fine grained policies improving
> the utilisation of a private slab.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 1 +
> drivers/gpu/drm/i915/i915_gem.c | 9 ++++++++-
> drivers/gpu/drm/i915/i915_guc_submission.c | 2 +-
> drivers/gpu/drm/i915/intel_lrc.c | 4 ++--
> 4 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index ff3574a56812..7f192efbe088 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2027,6 +2027,7 @@ struct drm_i915_private {
> struct kmem_cache *vmas;
> struct kmem_cache *requests;
> struct kmem_cache *dependencies;
> + struct kmem_cache *priorities;
>
> const struct intel_device_info info;
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 75d7575b81f4..f52d72b1a5b4 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4871,12 +4871,16 @@ i915_gem_load_init(struct drm_i915_private *dev_priv)
> if (!dev_priv->dependencies)
> goto err_requests;
>
> + dev_priv->priorities = KMEM_CACHE(i915_priolist, SLAB_HWCACHE_ALIGN);
> + if (!dev_priv->priorities)
> + goto err_dependencies;
> +
> mutex_lock(&dev_priv->drm.struct_mutex);
> INIT_LIST_HEAD(&dev_priv->gt.timelines);
> err = i915_gem_timeline_init__global(dev_priv);
> mutex_unlock(&dev_priv->drm.struct_mutex);
> if (err)
> - goto err_dependencies;
> + goto err_priorities;
>
> INIT_LIST_HEAD(&dev_priv->context_list);
> INIT_WORK(&dev_priv->mm.free_work, __i915_gem_free_work);
> @@ -4900,6 +4904,8 @@ i915_gem_load_init(struct drm_i915_private *dev_priv)
>
> return 0;
>
> +err_priorities:
> + kmem_cache_destroy(dev_priv->priorities);
> err_dependencies:
> kmem_cache_destroy(dev_priv->dependencies);
> err_requests:
> @@ -4923,6 +4929,7 @@ void i915_gem_load_cleanup(struct drm_i915_private *dev_priv)
> WARN_ON(!list_empty(&dev_priv->gt.timelines));
> mutex_unlock(&dev_priv->drm.struct_mutex);
>
> + kmem_cache_destroy(dev_priv->priorities);
> kmem_cache_destroy(dev_priv->dependencies);
> kmem_cache_destroy(dev_priv->requests);
> kmem_cache_destroy(dev_priv->vmas);
> diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
> index 440bab856cc2..53c022c47687 100644
> --- a/drivers/gpu/drm/i915/i915_guc_submission.c
> +++ b/drivers/gpu/drm/i915/i915_guc_submission.c
> @@ -704,7 +704,7 @@ static bool i915_guc_dequeue(struct intel_engine_cs *engine)
> rb_erase(&p->node, &engine->execlist_queue);
> INIT_LIST_HEAD(&p->requests);
> if (p->priority != I915_PRIORITY_NORMAL)
> - kfree(p);
> + kmem_cache_free(engine->i915->priorities, p);
> }
> done:
> engine->execlist_first = rb;
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index 849b35796de7..7e41529bd074 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -500,7 +500,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
> rb_erase(&p->node, &engine->execlist_queue);
> INIT_LIST_HEAD(&p->requests);
> if (p->priority != I915_PRIORITY_NORMAL)
> - kfree(p);
> + kmem_cache_free(engine->i915->priorities, p);
> }
> done:
> engine->execlist_first = rb;
> @@ -659,7 +659,7 @@ insert_request(struct intel_engine_cs *engine,
> if (prio == I915_PRIORITY_NORMAL) {
> p = &engine->default_priolist;
> } else {
> - p = kmalloc(sizeof(*p), GFP_ATOMIC);
> + p = kmem_cache_alloc(engine->i915->priorities, GFP_ATOMIC);
> /* Convert an allocation failure to a priority bump */
> if (unlikely(!p)) {
> prio = I915_PRIORITY_NORMAL; /* recurses just once */
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-05-16 7:57 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-11 19:59 [PATCH 01/12] drm/i915: Remove kref from i915_sw_fence Chris Wilson
2017-05-11 19:59 ` [PATCH 02/12] drm/i915: Import the kfence selftests for i915_sw_fence Chris Wilson
2017-05-15 10:52 ` [PATCH v2] " Chris Wilson
2017-05-16 8:55 ` Chris Wilson
2017-05-16 9:15 ` Mika Kuoppala
2017-05-16 14:49 ` Mika Kuoppala
2017-05-11 19:59 ` [PATCH 03/12] drm/i915: Make ptr_unpack_bits() more function-like Chris Wilson
2017-05-11 19:59 ` [PATCH 04/12] drm/i915: Redefine ptr_pack_bits() and friends Chris Wilson
2017-05-11 19:59 ` [PATCH 05/12] drm/i915/execlists: Pack the count into the low bits of the port.request Chris Wilson
2017-05-11 19:59 ` [PATCH 06/12] drm/i915: Don't mark an execlists context-switch when idle Chris Wilson
2017-05-11 19:59 ` [PATCH 07/12] drm/i915: Use a define for the default priority [0] Chris Wilson
2017-05-12 8:02 ` Mika Kuoppala
2017-05-11 19:59 ` [PATCH 08/12] drm/i915: Split execlist priority queue into rbtree + linked list Chris Wilson
2017-05-15 11:45 ` Tvrtko Ursulin
2017-05-15 12:26 ` Chris Wilson
2017-05-15 12:56 ` [PATCH v2] " Chris Wilson
2017-05-15 13:27 ` Chris Wilson
2017-05-15 13:29 ` [PATCH v3] " Chris Wilson
2017-05-15 14:51 ` Michał Winiarski
2017-05-16 7:55 ` Tvrtko Ursulin
2017-05-11 19:59 ` [PATCH 09/12] drm/i915: Create a kmem_cache to allocate struct i915_priolist from Chris Wilson
2017-05-16 7:57 ` Tvrtko Ursulin [this message]
2017-05-11 19:59 ` [PATCH 10/12] drm/i915/execlists: Reduce lock contention between schedule/submit_request Chris Wilson
2017-05-15 10:51 ` Tvrtko Ursulin
2017-05-15 10:55 ` Chris Wilson
2017-05-15 11:46 ` Tvrtko Ursulin
2017-05-11 19:59 ` [PATCH 11/12] drm/i915: Stop inlining the execlists IRQ handler Chris Wilson
2017-05-11 19:59 ` [PATCH 12/12] drm/i915: Don't force serialisation on marking up execlists irq posted Chris Wilson
2017-05-12 7:16 ` Mika Kuoppala
2017-05-15 10:33 ` Tvrtko Ursulin
2017-05-11 20:17 ` ✓ Fi.CI.BAT: success for series starting with [01/12] drm/i915: Remove kref from i915_sw_fence Patchwork
2017-05-12 7:43 ` [PATCH 01/12] " Mika Kuoppala
2017-05-12 8:19 ` Chris Wilson
2017-05-12 12:13 ` Mika Kuoppala
2017-05-15 11:47 ` ✓ Fi.CI.BAT: success for series starting with [01/12] drm/i915: Remove kref from i915_sw_fence (rev2) Patchwork
2017-05-15 14:01 ` ✓ Fi.CI.BAT: success for series starting with [01/12] drm/i915: Remove kref from i915_sw_fence (rev4) Patchwork
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=c30de3ca-64ef-9b07-10ce-8a3d1364d859@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@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