All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked
@ 2017-04-07 10:25 Chris Wilson
  2017-04-07 10:25 ` [PATCH 2/4] drm/i915: Drain any freed objects prior to hibernation Chris Wilson
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Chris Wilson @ 2017-04-07 10:25 UTC (permalink / raw)
  To: intel-gfx

The shrinker is prepared to be called unlock (and with struct_mutex held
for DIRECT_RECLAIM) so we can skip acquiring the struct_mutex prior to
calling the shrinking during freeze. This improves our ability to shrink
as we can be more aggressive when we know the caller isn't holding
struct_mutex.

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

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 52b403b4f8c2..13cad69df20e 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4886,9 +4886,10 @@ void i915_gem_load_cleanup(struct drm_i915_private *dev_priv)
 
 int i915_gem_freeze(struct drm_i915_private *dev_priv)
 {
-	mutex_lock(&dev_priv->drm.struct_mutex);
+	/* Discard all purgeable objects, let userspace recover those as
+	 * required after resuming.
+	 */
 	i915_gem_shrink_all(dev_priv);
-	mutex_unlock(&dev_priv->drm.struct_mutex);
 
 	return 0;
 }
@@ -4913,12 +4914,12 @@ int i915_gem_freeze_late(struct drm_i915_private *dev_priv)
 	 * we update that state just before writing out the image.
 	 *
 	 * To try and reduce the hibernation image, we manually shrink
-	 * the objects as well.
+	 * the objects as well, see i915_gem_freeze()
 	 */
 
-	mutex_lock(&dev_priv->drm.struct_mutex);
 	i915_gem_shrink(dev_priv, -1UL, I915_SHRINK_UNBOUND);
 
+	mutex_lock(&dev_priv->drm.struct_mutex);
 	for (p = phases; *p; p++) {
 		list_for_each_entry(obj, *p, global_link) {
 			obj->base.read_domains = I915_GEM_DOMAIN_CPU;
-- 
2.11.0

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] drm/i915: Drain any freed objects prior to hibernation
  2017-04-07 10:25 [PATCH 1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Chris Wilson
@ 2017-04-07 10:25 ` Chris Wilson
  2017-04-07 11:22   ` Joonas Lahtinen
  2017-04-07 10:25 ` [PATCH 3/4] drm/i915: Break up long runs of freeing objects Chris Wilson
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Chris Wilson @ 2017-04-07 10:25 UTC (permalink / raw)
  To: intel-gfx

As we call into the shrinker during freeze, we may have freed more
object since we idled during i915_gem_suspend. Make sure we flush the
i915_gem_free_objects worker prior to saving the unwanted pages into the
hibernation image.

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

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 13cad69df20e..a28ca268a51c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4918,6 +4918,7 @@ int i915_gem_freeze_late(struct drm_i915_private *dev_priv)
 	 */
 
 	i915_gem_shrink(dev_priv, -1UL, I915_SHRINK_UNBOUND);
+	i915_gem_drain_freed_objects(dev_priv);
 
 	mutex_lock(&dev_priv->drm.struct_mutex);
 	for (p = phases; *p; p++) {
-- 
2.11.0

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] drm/i915: Break up long runs of freeing objects
  2017-04-07 10:25 [PATCH 1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Chris Wilson
  2017-04-07 10:25 ` [PATCH 2/4] drm/i915: Drain any freed objects prior to hibernation Chris Wilson
@ 2017-04-07 10:25 ` Chris Wilson
  2017-04-07 11:22   ` Joonas Lahtinen
  2017-04-07 10:25 ` [PATCH 4/4] drm/i915: Insert cond_resched() into i915_gem_free_objects Chris Wilson
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Chris Wilson @ 2017-04-07 10:25 UTC (permalink / raw)
  To: intel-gfx

Before freeing the next batch of objects from the worker, check if the
worker's timeslice has expired and if so, defer the next batch to the
next invocation of the worker.

Suggested-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index a28ca268a51c..d81cdd4b0edc 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4382,8 +4382,11 @@ static void __i915_gem_free_work(struct work_struct *work)
 	 * unbound now.
 	 */
 
-	while ((freed = llist_del_all(&i915->mm.free_list)))
+	while ((freed = llist_del_all(&i915->mm.free_list))) {
 		__i915_gem_free_objects(i915, freed);
+		if (need_resched())
+			break;
+	}
 }
 
 static void __i915_gem_free_object_rcu(struct rcu_head *head)
-- 
2.11.0

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] drm/i915: Insert cond_resched() into i915_gem_free_objects
  2017-04-07 10:25 [PATCH 1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Chris Wilson
  2017-04-07 10:25 ` [PATCH 2/4] drm/i915: Drain any freed objects prior to hibernation Chris Wilson
  2017-04-07 10:25 ` [PATCH 3/4] drm/i915: Break up long runs of freeing objects Chris Wilson
@ 2017-04-07 10:25 ` Chris Wilson
  2017-04-07 11:23   ` Joonas Lahtinen
  2017-04-07 10:44 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Patchwork
  2017-04-07 11:21 ` [PATCH 1/4] " Joonas Lahtinen
  4 siblings, 1 reply; 11+ messages in thread
From: Chris Wilson @ 2017-04-07 10:25 UTC (permalink / raw)
  To: intel-gfx

As we may have very many objects to free, check to see if the task needs
to be rescheduled whilst freeing them.

Suggested-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index d81cdd4b0edc..d0a363966487 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4335,6 +4335,8 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 	intel_runtime_pm_put(i915);
 	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));
-- 
2.11.0

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked
  2017-04-07 10:25 [PATCH 1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Chris Wilson
                   ` (2 preceding siblings ...)
  2017-04-07 10:25 ` [PATCH 4/4] drm/i915: Insert cond_resched() into i915_gem_free_objects Chris Wilson
@ 2017-04-07 10:44 ` Patchwork
  2017-04-07 11:21 ` [PATCH 1/4] " Joonas Lahtinen
  4 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2017-04-07 10:44 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked
URL   : https://patchwork.freedesktop.org/series/22650/
State : success

== Summary ==

Series 22650v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/22650/revisions/1/mbox/

Test gem_exec_flush:
        Subgroup basic-batch-kernel-default-uc:
                pass       -> FAIL       (fi-snb-2600) fdo#100007
Test gem_exec_suspend:
        Subgroup basic-s4-devices:
                dmesg-warn -> PASS       (fi-kbl-7560u) fdo#100125

fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007
fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125

fi-bdw-5557u     total:278  pass:266  dwarn:0   dfail:0   fail:1   skip:11  time: 433s
fi-bdw-gvtdvm    total:278  pass:255  dwarn:8   dfail:0   fail:1   skip:14  time: 430s
fi-bsw-n3050     total:278  pass:241  dwarn:0   dfail:0   fail:1   skip:36  time: 587s
fi-bxt-j4205     total:278  pass:258  dwarn:0   dfail:0   fail:1   skip:19  time: 504s
fi-byt-j1900     total:278  pass:253  dwarn:0   dfail:0   fail:1   skip:24  time: 486s
fi-byt-n2820     total:278  pass:249  dwarn:0   dfail:0   fail:1   skip:28  time: 479s
fi-hsw-4770      total:278  pass:261  dwarn:0   dfail:0   fail:1   skip:16  time: 410s
fi-hsw-4770r     total:278  pass:261  dwarn:0   dfail:0   fail:1   skip:16  time: 406s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:1   skip:49  time: 425s
fi-ivb-3520m     total:278  pass:259  dwarn:0   dfail:0   fail:1   skip:18  time: 496s
fi-ivb-3770      total:278  pass:259  dwarn:0   dfail:0   fail:1   skip:18  time: 469s
fi-kbl-7500u     total:278  pass:259  dwarn:0   dfail:0   fail:1   skip:18  time: 451s
fi-kbl-7560u     total:278  pass:267  dwarn:0   dfail:0   fail:1   skip:10  time: 563s
fi-skl-6260u     total:278  pass:267  dwarn:0   dfail:0   fail:1   skip:10  time: 449s
fi-skl-6700hq    total:278  pass:260  dwarn:0   dfail:0   fail:1   skip:17  time: 574s
fi-skl-6700k     total:278  pass:255  dwarn:4   dfail:0   fail:1   skip:18  time: 465s
fi-skl-6770hq    total:278  pass:267  dwarn:0   dfail:0   fail:1   skip:10  time: 487s
fi-skl-gvtdvm    total:278  pass:264  dwarn:0   dfail:0   fail:1   skip:13  time: 430s
fi-snb-2520m     total:278  pass:249  dwarn:0   dfail:0   fail:1   skip:28  time: 536s
fi-snb-2600      total:278  pass:247  dwarn:0   dfail:0   fail:2   skip:29  time: 399s

5aa5296d0b577748312afc42e0b4ed3680da7288 drm-tip: 2017y-04m-07d-09h-15m-15s UTC integration manifest
09f75b3 drm/i915: Insert cond_resched() into i915_gem_free_objects
d915ca7 drm/i915: Break up long runs of freeing objects
9026deb drm/i915: Drain any freed objects prior to hibernation
32452d3 drm/i915: The shrinker already acquires struct_mutex, so call it unlocked

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4438/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked
  2017-04-07 10:25 [PATCH 1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Chris Wilson
                   ` (3 preceding siblings ...)
  2017-04-07 10:44 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Patchwork
@ 2017-04-07 11:21 ` Joonas Lahtinen
  4 siblings, 0 replies; 11+ messages in thread
From: Joonas Lahtinen @ 2017-04-07 11:21 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

On pe, 2017-04-07 at 11:25 +0100, Chris Wilson wrote:
> The shrinker is prepared to be called unlock (and with struct_mutex held
> for DIRECT_RECLAIM) so we can skip acquiring the struct_mutex prior to
> calling the shrinking during freeze. This improves our ability to shrink
> as we can be more aggressive when we know the caller isn't holding
> struct_mutex.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] drm/i915: Drain any freed objects prior to hibernation
  2017-04-07 10:25 ` [PATCH 2/4] drm/i915: Drain any freed objects prior to hibernation Chris Wilson
@ 2017-04-07 11:22   ` Joonas Lahtinen
  2017-04-07 11:28     ` Chris Wilson
  0 siblings, 1 reply; 11+ messages in thread
From: Joonas Lahtinen @ 2017-04-07 11:22 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

On pe, 2017-04-07 at 11:25 +0100, Chris Wilson wrote:
> As we call into the shrinker during freeze, we may have freed more
> object since we idled during i915_gem_suspend. Make sure we flush the
> i915_gem_free_objects worker prior to saving the unwanted pages into the
> hibernation image.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] drm/i915: Break up long runs of freeing objects
  2017-04-07 10:25 ` [PATCH 3/4] drm/i915: Break up long runs of freeing objects Chris Wilson
@ 2017-04-07 11:22   ` Joonas Lahtinen
  0 siblings, 0 replies; 11+ messages in thread
From: Joonas Lahtinen @ 2017-04-07 11:22 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

On pe, 2017-04-07 at 11:25 +0100, Chris Wilson wrote:
> Before freeing the next batch of objects from the worker, check if the
> worker's timeslice has expired and if so, defer the next batch to the
> next invocation of the worker.
> 
> Suggested-by: Andrea Arcangeli <aarcange@redhat.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] drm/i915: Insert cond_resched() into i915_gem_free_objects
  2017-04-07 10:25 ` [PATCH 4/4] drm/i915: Insert cond_resched() into i915_gem_free_objects Chris Wilson
@ 2017-04-07 11:23   ` Joonas Lahtinen
  2017-04-07 12:40     ` Chris Wilson
  0 siblings, 1 reply; 11+ messages in thread
From: Joonas Lahtinen @ 2017-04-07 11:23 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

On pe, 2017-04-07 at 11:25 +0100, Chris Wilson wrote:
> As we may have very many objects to free, check to see if the task needs
> to be rescheduled whilst freeing them.
> 
> Suggested-by: Andrea Arcangeli <aarcange@redhat.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] drm/i915: Drain any freed objects prior to hibernation
  2017-04-07 11:22   ` Joonas Lahtinen
@ 2017-04-07 11:28     ` Chris Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Wilson @ 2017-04-07 11:28 UTC (permalink / raw)
  To: Joonas Lahtinen; +Cc: intel-gfx

On Fri, Apr 07, 2017 at 02:22:00PM +0300, Joonas Lahtinen wrote:
> On pe, 2017-04-07 at 11:25 +0100, Chris Wilson wrote:
> > As we call into the shrinker during freeze, we may have freed more
> > object since we idled during i915_gem_suspend. Make sure we flush the
> > i915_gem_free_objects worker prior to saving the unwanted pages into the
> > hibernation image.
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> 
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Applied the first two just to kick start CI. Thanks,
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] drm/i915: Insert cond_resched() into i915_gem_free_objects
  2017-04-07 11:23   ` Joonas Lahtinen
@ 2017-04-07 12:40     ` Chris Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Wilson @ 2017-04-07 12:40 UTC (permalink / raw)
  To: Joonas Lahtinen; +Cc: intel-gfx

On Fri, Apr 07, 2017 at 02:23:58PM +0300, Joonas Lahtinen wrote:
> On pe, 2017-04-07 at 11:25 +0100, Chris Wilson wrote:
> > As we may have very many objects to free, check to see if the task needs
> > to be rescheduled whilst freeing them.
> > 
> > Suggested-by: Andrea Arcangeli <aarcange@redhat.com>
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> 
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

And picked up the last pair, thanks.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-04-07 12:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-07 10:25 [PATCH 1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Chris Wilson
2017-04-07 10:25 ` [PATCH 2/4] drm/i915: Drain any freed objects prior to hibernation Chris Wilson
2017-04-07 11:22   ` Joonas Lahtinen
2017-04-07 11:28     ` Chris Wilson
2017-04-07 10:25 ` [PATCH 3/4] drm/i915: Break up long runs of freeing objects Chris Wilson
2017-04-07 11:22   ` Joonas Lahtinen
2017-04-07 10:25 ` [PATCH 4/4] drm/i915: Insert cond_resched() into i915_gem_free_objects Chris Wilson
2017-04-07 11:23   ` Joonas Lahtinen
2017-04-07 12:40     ` Chris Wilson
2017-04-07 10:44 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: The shrinker already acquires struct_mutex, so call it unlocked Patchwork
2017-04-07 11:21 ` [PATCH 1/4] " Joonas Lahtinen

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.