All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 12/20] drm/i915: Trim struct_mutex hold duration for i915_gem_free_objects
Date: Wed, 23 Aug 2017 10:15:06 +0100	[thread overview]
Message-ID: <20170823091514.29354-13-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20170823091514.29354-1-chris@chris-wilson.co.uk>

We free objects in bulk after they wait for their RCU grace period.
Currently, we take struct_mutex and unbind all the objects. This can lead
to a long lock duration during which time those objects have their pages
unfreeable (i.e. the shrinker is prevented from reaping those pages). If
we only process a single object under the struct_mutex and then free the
pages, the number of objects locked away from the shrinker is minimal
and we allow regular clients better access to struct_mutex if they need
it.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 96be7969b3bd..88b52f23ee7a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4409,13 +4409,14 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 {
 	struct drm_i915_gem_object *obj, *on;
 
-	mutex_lock(&i915->drm.struct_mutex);
 	intel_runtime_pm_get(i915);
-	llist_for_each_entry(obj, freed, freed) {
+	llist_for_each_entry_safe(obj, on, freed, freed) {
 		struct i915_vma *vma, *vn;
 
 		trace_i915_gem_object_destroy(obj);
 
+		mutex_lock(&i915->drm.struct_mutex);
+
 		GEM_BUG_ON(i915_gem_object_is_active(obj));
 		list_for_each_entry_safe(vma, vn,
 					 &obj->vma_list, obj_link) {
@@ -4438,13 +4439,8 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 			spin_unlock(&i915->mm.obj_lock);
 		}
 
-	}
-	intel_runtime_pm_put(i915);
-	mutex_unlock(&i915->drm.struct_mutex);
+		mutex_unlock(&i915->drm.struct_mutex);
 
-	cond_resched();
-
-	llist_for_each_entry_safe(obj, on, freed, freed) {
 		GEM_BUG_ON(obj->bind_count);
 		GEM_BUG_ON(atomic_read(&obj->frontbuffer_bits));
 		GEM_BUG_ON(!list_empty(&obj->lut_list));
@@ -4466,7 +4462,11 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 
 		kfree(obj->bit_17);
 		i915_gem_object_free(obj);
+
+		if (on)
+			cond_resched();
 	}
+	intel_runtime_pm_put(i915);
 }
 
 static void i915_gem_flush_free_objects(struct drm_i915_private *i915)
-- 
2.14.1

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

  parent reply	other threads:[~2017-08-23  9:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23  9:14 The bunch of mm patches in the queue, mostly for shard testing Chris Wilson
2017-08-23  9:14 ` [PATCH 01/20] drm/i915: "Race-to-idle" on switching to the kernel context Chris Wilson
2017-08-23  9:14 ` [PATCH 02/20] drm/i915: Assert the context is not closed on object-close Chris Wilson
2017-08-23 16:50   ` Michał Winiarski
2017-08-23 16:57     ` Chris Wilson
2017-08-23  9:14 ` [PATCH 03/20] drm/i915: Assert that the handle->vma lut is empty on object close Chris Wilson
2017-08-23 16:54   ` Michał Winiarski
2017-08-23  9:14 ` [PATCH 04/20] drm/i915: Ignore duplicate VMA stored within the per-object handle LUT Chris Wilson
2017-08-23 17:40   ` Michał Winiarski
2017-08-23  9:14 ` [PATCH 05/20] drm/i915: Prevent overflow of execbuf.buffer_count and num_cliprects Chris Wilson
2017-08-23  9:15 ` [PATCH 06/20] drm/i915: Refactor testing obj->mm.pages Chris Wilson
2017-08-23  9:15 ` [PATCH 07/20] drm/i915: Rename obj->pin_display to obj->pin_global Chris Wilson
2017-08-23  9:15 ` [PATCH 08/20] drm/i915: Drop debugfs/i915_gem_pin_display Chris Wilson
2017-08-23  9:15 ` [PATCH 09/20] drm/i915: Remove walk over obj->vma_list for the shrinker Chris Wilson
2017-08-23  9:15 ` [PATCH 10/20] drm/i915: Move dev_priv->mm.[un]bound_list to its own lock Chris Wilson
2017-08-23  9:15 ` [PATCH 11/20] drm/i915: Set our shrinker->batch to 4096 (~16MiB) Chris Wilson
2017-08-23  9:15 ` Chris Wilson [this message]
2017-08-23  9:15 ` [PATCH 13/20] drm/i915: Start writeback from the shrinker Chris Wilson
2017-08-23  9:15 ` [PATCH 14/20] drm/i915: Discard VMA lut handles upon purging the object Chris Wilson
2017-08-23  9:15 ` [PATCH 15/20] drm/i915: Only free the oldest stale object before a fresh allocation Chris Wilson
2017-08-23  9:15 ` [PATCH 16/20] mm: Track actual nr_scanned during shrink_slab() Chris Wilson
2017-08-23  9:15 ` [PATCH 17/20] drm/i915: Wire up shrinkctl->nr_scanned Chris Wilson
2017-08-23  9:15 ` [PATCH 18/20] mm, drm/i915: Mark pinned shmemfs pages as unevictable Chris Wilson
2017-08-23  9:15 ` [PATCH 19/20] shmem: Support for registration of driver/file owner specific ops Chris Wilson
2017-08-23  9:15 ` [PATCH 20/20] drm/i915: Make GPU pages movable Chris Wilson
2017-08-23  9:36 ` ✗ Fi.CI.BAT: failure for series starting with [01/20] drm/i915: "Race-to-idle" on switching to the kernel context Patchwork
2017-08-25 10:41 ` 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=20170823091514.29354-13-chris@chris-wilson.co.uk \
    --to=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.