From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 14/22] drm/i915: Allocate active tracking nodes from a slabcache
Date: Mon, 4 Feb 2019 18:22:07 +0000 [thread overview]
Message-ID: <23ad8388-e524-e1dd-8da9-69e54733580a@linux.intel.com> (raw)
In-Reply-To: <20190204132214.9459-15-chris@chris-wilson.co.uk>
On 04/02/2019 13:22, Chris Wilson wrote:
> Wrap the active tracking for a GPU references in a slabcache for faster
> allocations, and hopefully better fragmentation reduction.
>
> v3: Nothing device specific left, it's just a slabcache that we can
> make global.
> v4: Include i915_active.h and don't put the initfunc under DEBUG_GEM
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_active.c | 31 +++++++++++++++++++++++++++---
> drivers/gpu/drm/i915/i915_active.h | 3 +++
> drivers/gpu/drm/i915/i915_pci.c | 4 ++++
> 3 files changed, 35 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> index b1fefe98f9a6..64661c41532b 100644
> --- a/drivers/gpu/drm/i915/i915_active.c
> +++ b/drivers/gpu/drm/i915/i915_active.c
> @@ -9,6 +9,17 @@
>
> #define BKL(ref) (&(ref)->i915->drm.struct_mutex)
>
> +/*
> + * Active refs memory management
> + *
> + * To be more economical with memory, we reap all the i915_active trees as
> + * they idle (when we know the active requests are inactive) and allocate the
> + * nodes from a local slab cache to hopefully reduce the fragmentation.
> + */
> +static struct i915_global_active {
> + struct kmem_cache *slab_cache;
> +} global;
> +
> struct active_node {
> struct i915_gem_active base;
> struct i915_active *ref;
> @@ -23,7 +34,7 @@ __active_park(struct i915_active *ref)
>
> rbtree_postorder_for_each_entry_safe(it, n, &ref->tree, node) {
> GEM_BUG_ON(i915_gem_active_isset(&it->base));
> - kfree(it);
> + kmem_cache_free(global.slab_cache, it);
> }
> ref->tree = RB_ROOT;
> }
> @@ -96,11 +107,11 @@ active_instance(struct i915_active *ref, u64 idx)
> p = &parent->rb_left;
> }
>
> - node = kmalloc(sizeof(*node), GFP_KERNEL);
> + node = kmem_cache_alloc(global.slab_cache, GFP_KERNEL);
>
> /* kmalloc may retire the ref->last (thanks shrinker)! */
> if (unlikely(!i915_gem_active_raw(&ref->last, BKL(ref)))) {
> - kfree(node);
> + kmem_cache_free(global.slab_cache, node);
> goto out;
> }
>
> @@ -239,3 +250,17 @@ void i915_active_fini(struct i915_active *ref)
> #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
> #include "selftests/i915_active.c"
> #endif
> +
> +int __init i915_global_active_init(void)
> +{
> + global.slab_cache = KMEM_CACHE(active_node, SLAB_HWCACHE_ALIGN);
> + if (!global.slab_cache)
> + return -ENOMEM;
> +
> + return 0;
> +}
> +
> +void __exit i915_global_active_exit(void)
> +{
> + kmem_cache_destroy(global.slab_cache);
> +}
> diff --git a/drivers/gpu/drm/i915/i915_active.h b/drivers/gpu/drm/i915/i915_active.h
> index ec4b66efd9a7..179b47aeec33 100644
> --- a/drivers/gpu/drm/i915/i915_active.h
> +++ b/drivers/gpu/drm/i915/i915_active.h
> @@ -70,4 +70,7 @@ void i915_active_fini(struct i915_active *ref);
> static inline void i915_active_fini(struct i915_active *ref) { }
> #endif
>
> +int i915_global_active_init(void);
> +void i915_global_active_exit(void);
> +
> #endif /* _I915_ACTIVE_H_ */
> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> index 5d05572c9ff4..852b6b4e8ed8 100644
> --- a/drivers/gpu/drm/i915/i915_pci.c
> +++ b/drivers/gpu/drm/i915/i915_pci.c
> @@ -28,6 +28,7 @@
>
> #include <drm/drm_drv.h>
>
> +#include "i915_active.h"
> #include "i915_drv.h"
> #include "i915_selftest.h"
>
> @@ -800,6 +801,8 @@ static int __init i915_init(void)
> bool use_kms = true;
> int err;
>
> + i915_global_active_init();
> +
> err = i915_mock_selftests();
> if (err)
> return err > 0 ? 0 : err;
> @@ -831,6 +834,7 @@ static void __exit i915_exit(void)
> return;
>
> pci_unregister_driver(&i915_pci_driver);
> + i915_global_active_exit();
> }
>
> module_init(i915_init);
>
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:[~2019-02-04 18:22 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-04 13:21 Fleshing out the picture to Load Balancing^W^W HW semaphores Chris Wilson
2019-02-04 13:21 ` [PATCH 01/22] drm/i915/execlists: Suppress mere WAIT preemption Chris Wilson
2019-02-04 13:21 ` [PATCH 02/22] drm/i915/execlists: Suppress redundant preemption Chris Wilson
2019-02-04 13:21 ` [PATCH 03/22] drm/i915/selftests: Exercise some AB...BA preemption chains Chris Wilson
2019-02-04 13:21 ` [PATCH 04/22] drm/i915: Trim NEWCLIENT boosting Chris Wilson
2019-02-04 15:01 ` [PATCH] " Chris Wilson
2019-02-04 19:05 ` Tvrtko Ursulin
2019-02-04 13:21 ` [PATCH 05/22] drm/i915: Show support for accurate sw PMU busyness tracking Chris Wilson
2019-02-04 16:49 ` Chris Wilson
2019-02-04 13:21 ` [PATCH 06/22] drm/i915: Revoke mmaps and prevent access to fence registers across reset Chris Wilson
2019-02-04 13:21 ` [PATCH 07/22] drm/i915: Force the GPU reset upon wedging Chris Wilson
2019-02-04 13:22 ` [PATCH 08/22] drm/i915: Uninterruptibly drain the timelines on unwedging Chris Wilson
2019-02-04 13:22 ` [PATCH 09/22] drm/i915: Wait for old resets before applying debugfs/i915_wedged Chris Wilson
2019-02-04 13:22 ` [PATCH 10/22] drm/i915: Serialise resets with wedging Chris Wilson
2019-02-04 13:22 ` [PATCH 11/22] drm/i915: Don't claim an unstarted request was guilty Chris Wilson
2019-02-04 13:22 ` [PATCH 12/22] drm/i915: Generalise GPU activity tracking Chris Wilson
2019-02-05 8:51 ` Tvrtko Ursulin
2019-02-05 8:59 ` Chris Wilson
2019-02-04 13:22 ` [PATCH 13/22] drm/i915: Release the active tracker tree upon idling Chris Wilson
2019-02-04 13:22 ` [PATCH 14/22] drm/i915: Allocate active tracking nodes from a slabcache Chris Wilson
2019-02-04 18:22 ` Tvrtko Ursulin [this message]
2019-02-04 13:22 ` [PATCH 15/22] drm/i915: Make request allocation caches global Chris Wilson
2019-02-04 18:48 ` Tvrtko Ursulin
2019-02-04 21:26 ` Chris Wilson
2019-02-04 13:22 ` [PATCH 16/22] drm/i915: Add timeline barrier support Chris Wilson
2019-02-04 13:22 ` [PATCH 17/22] drm/i915: Pull i915_gem_active into the i915_active family Chris Wilson
2019-02-04 18:50 ` Tvrtko Ursulin
2019-02-04 13:22 ` [PATCH 18/22] drm/i915: Keep timeline HWSP allocated until idle across the system Chris Wilson
2019-02-04 18:57 ` Tvrtko Ursulin
2019-02-04 13:22 ` [PATCH 19/22] drm/i915/execlists: Refactor out can_merge_rq() Chris Wilson
2019-02-04 19:02 ` Tvrtko Ursulin
2019-02-04 13:22 ` [PATCH 20/22] drm/i915: Use HW semaphores for inter-engine synchronisation on gen8+ Chris Wilson
2019-02-05 9:24 ` Tvrtko Ursulin
2019-02-05 9:27 ` Chris Wilson
2019-02-04 13:22 ` [PATCH 21/22] drm/i915: Prioritise non-busywait semaphore workloads Chris Wilson
2019-02-04 13:22 ` [PATCH 22/22] semaphore-no-stats Chris Wilson
2019-02-05 10:03 ` Tvrtko Ursulin
2019-02-05 10:07 ` Chris Wilson
2019-02-04 13:58 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/22] drm/i915/execlists: Suppress mere WAIT preemption Patchwork
2019-02-04 14:07 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-02-04 14:45 ` ✓ Fi.CI.BAT: success " Patchwork
2019-02-04 15:22 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/22] drm/i915/execlists: Suppress mere WAIT preemption (rev2) Patchwork
2019-02-04 15:30 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-02-04 15:42 ` ✓ Fi.CI.BAT: success " Patchwork
2019-02-04 17:51 ` ✓ Fi.CI.IGT: " 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=23ad8388-e524-e1dd-8da9-69e54733580a@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 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.