All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Recover batch pool caches from shrinker
@ 2018-09-15 16:40 Chris Wilson
  2018-09-15 17:09 ` ✗ Fi.CI.BAT: failure for " Patchwork
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Chris Wilson @ 2018-09-15 16:40 UTC (permalink / raw)
  To: intel-gfx

Discard all of our batch pools under mempressure to make their pages
available to the shrinker. We will quickly reacquire them when necessary
for more GPU relocations or for the command parser.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107936
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_batch_pool.c |  7 +++++--
 drivers/gpu/drm/i915/i915_gem_shrinker.c   | 11 +++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_batch_pool.c b/drivers/gpu/drm/i915/i915_gem_batch_pool.c
index f3890b664e3f..b7727a404b46 100644
--- a/drivers/gpu/drm/i915/i915_gem_batch_pool.c
+++ b/drivers/gpu/drm/i915/i915_gem_batch_pool.c
@@ -131,10 +131,13 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
 		return obj;
 
 found:
+	list_del(&obj->batch_pool_link);
 	ret = i915_gem_object_pin_pages(obj);
-	if (ret)
+	if (ret) {
+		i915_gem_object_put(obj);
 		return ERR_PTR(ret);
+	}
 
-	list_move_tail(&obj->batch_pool_link, list);
+	list_add_tail(&obj->batch_pool_link, list);
 	return obj;
 }
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index ea90d3a0d511..610a78e2f0b1 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -117,6 +117,15 @@ static bool unsafe_drop_pages(struct drm_i915_gem_object *obj)
 	return !i915_gem_object_has_pages(obj);
 }
 
+static void shrink_caches(struct drm_i915_private *i915)
+{
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+
+	for_each_engine(engine, i915, id)
+		i915_gem_batch_pool_fini(&engine->batch_pool);
+}
+
 /**
  * i915_gem_shrink - Shrink buffer object caches
  * @i915: i915 device
@@ -180,6 +189,8 @@ i915_gem_shrink(struct drm_i915_private *i915,
 	trace_i915_gem_shrink(i915, target, flags);
 	i915_retire_requests(i915);
 
+	shrink_caches(i915);
+
 	/*
 	 * Unbinding of objects will require HW access; Let us not wake the
 	 * device just to recover a little memory. If absolutely necessary,
-- 
2.19.0

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

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

* ✗ Fi.CI.BAT: failure for drm/i915: Recover batch pool caches from shrinker
  2018-09-15 16:40 [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
@ 2018-09-15 17:09 ` Patchwork
  2018-09-16 20:57 ` [PATCH v2] " Chris Wilson
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-09-15 17:09 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Recover batch pool caches from shrinker
URL   : https://patchwork.freedesktop.org/series/49757/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4832 -> Patchwork_10197 =

== Summary - FAILURE ==

  Serious unknown changes coming with Patchwork_10197 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_10197, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/49757/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in Patchwork_10197:

  === IGT changes ===

    ==== Possible regressions ====

    igt@drv_selftest@mock_vma:
      fi-cfl-8700k:       PASS -> INCOMPLETE
      fi-bsw-kefka:       PASS -> INCOMPLETE
      fi-bsw-n3050:       PASS -> INCOMPLETE
      fi-ilk-650:         PASS -> INCOMPLETE
      fi-skl-6260u:       PASS -> INCOMPLETE
      fi-hsw-4770:        PASS -> INCOMPLETE
      fi-ivb-3520m:       PASS -> INCOMPLETE
      fi-skl-6770hq:      PASS -> INCOMPLETE
      fi-snb-2600:        PASS -> INCOMPLETE
      fi-kbl-7567u:       PASS -> INCOMPLETE
      fi-icl-u:           PASS -> INCOMPLETE
      fi-skl-6600u:       PASS -> INCOMPLETE
      fi-skl-6700k2:      PASS -> INCOMPLETE
      fi-kbl-7500u:       PASS -> INCOMPLETE

    
    ==== Warnings ====

    igt@drv_selftest@live_dmabuf:
      fi-byt-n2820:       PASS -> SKIP +18

    igt@drv_selftest@live_gem:
      fi-skl-6600u:       PASS -> SKIP +18

    igt@drv_selftest@live_gtt:
      fi-kbl-7500u:       PASS -> SKIP +18

    igt@drv_selftest@live_guc:
      fi-icl-u:           PASS -> SKIP +18

    igt@drv_selftest@live_hugepages:
      fi-glk-dsi:         PASS -> SKIP +18

    igt@drv_selftest@live_objects:
      fi-snb-2600:        PASS -> SKIP +18
      fi-skl-6770hq:      PASS -> SKIP +18
      fi-skl-6700k2:      PASS -> SKIP +18
      fi-hsw-4770:        PASS -> SKIP +18
      fi-bxt-dsi:         PASS -> SKIP +18
      fi-skl-6260u:       PASS -> SKIP +18

    igt@drv_selftest@live_requests:
      fi-ivb-3520m:       PASS -> SKIP +18
      fi-bxt-j4205:       PASS -> SKIP +18
      fi-cfl-guc:         PASS -> SKIP +17

    igt@drv_selftest@live_sanitycheck:
      fi-ilk-650:         PASS -> SKIP +18
      fi-bsw-n3050:       PASS -> SKIP +18

    igt@drv_selftest@live_workarounds:
      fi-cfl-8700k:       PASS -> SKIP +18

    igt@drv_selftest@mock_evict:
      fi-byt-j1900:       PASS -> SKIP +18

    igt@drv_selftest@mock_hugepages:
      fi-kbl-7567u:       PASS -> SKIP +18
      fi-bsw-kefka:       PASS -> SKIP +18

    
== Known issues ==

  Here are the changes found in Patchwork_10197 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@mock_hugepages:
      fi-bwr-2160:        PASS -> DMESG-FAIL (fdo#107930)

    igt@drv_selftest@mock_vma:
      fi-glk-dsi:         PASS -> INCOMPLETE (fdo#103359, k.org#198133)
      fi-cfl-guc:         PASS -> INCOMPLETE (fdo#106693)
      fi-bxt-j4205:       PASS -> INCOMPLETE (fdo#103927)
      fi-bxt-dsi:         PASS -> INCOMPLETE (fdo#103927)
      fi-byt-n2820:       PASS -> INCOMPLETE (fdo#102657)
      fi-byt-j1900:       PASS -> INCOMPLETE (fdo#102657)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-byt-clapper:     NOTRUN -> FAIL (fdo#107362, fdo#103191)

    igt@kms_psr@primary_page_flip:
      fi-icl-u:           PASS -> FAIL (fdo#107336)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_guc:
      fi-cfl-guc:         DMESG-WARN (fdo#107258) -> SKIP

    igt@gem_exec_suspend@basic-s3:
      fi-byt-clapper:     INCOMPLETE (fdo#102657) -> PASS

    
  fdo#102657 https://bugs.freedesktop.org/show_bug.cgi?id=102657
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#106693 https://bugs.freedesktop.org/show_bug.cgi?id=106693
  fdo#107258 https://bugs.freedesktop.org/show_bug.cgi?id=107258
  fdo#107336 https://bugs.freedesktop.org/show_bug.cgi?id=107336
  fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
  fdo#107930 https://bugs.freedesktop.org/show_bug.cgi?id=107930
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


== Participating hosts (45 -> 41) ==

  Missing    (4): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


== Build changes ==

    * Linux: CI_DRM_4832 -> Patchwork_10197

  CI_DRM_4832: c6d215f9bdb60b485ca3c2195e793f5bf0c22acb @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4644: 0b59bb3231ab481959528c5c7b3a98762772e1b0 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10197: 88f04f56cf443aa702bacdc28e392046db11437a @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

88f04f56cf44 drm/i915: Recover batch pool caches from shrinker

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10197/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH v2] drm/i915: Recover batch pool caches from shrinker
  2018-09-15 16:40 [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
  2018-09-15 17:09 ` ✗ Fi.CI.BAT: failure for " Patchwork
@ 2018-09-16 20:57 ` Chris Wilson
  2018-09-19 18:34   ` Matthew Auld
  2018-09-16 21:56 ` ✓ Fi.CI.BAT: success for drm/i915: Recover batch pool caches from shrinker (rev2) Patchwork
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Chris Wilson @ 2018-09-16 20:57 UTC (permalink / raw)
  To: intel-gfx

Discard all of our batch pools under mempressure to make their pages
available to the shrinker. We will quickly reacquire them when necessary
for more GPU relocations or for the command parser.

v2: Init the lists for mock_engine

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107936
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_batch_pool.c   |  7 +++++--
 drivers/gpu/drm/i915/i915_gem_shrinker.c     | 11 +++++++++++
 drivers/gpu/drm/i915/selftests/mock_engine.c |  2 ++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_batch_pool.c b/drivers/gpu/drm/i915/i915_gem_batch_pool.c
index f3890b664e3f..b7727a404b46 100644
--- a/drivers/gpu/drm/i915/i915_gem_batch_pool.c
+++ b/drivers/gpu/drm/i915/i915_gem_batch_pool.c
@@ -131,10 +131,13 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
 		return obj;
 
 found:
+	list_del(&obj->batch_pool_link);
 	ret = i915_gem_object_pin_pages(obj);
-	if (ret)
+	if (ret) {
+		i915_gem_object_put(obj);
 		return ERR_PTR(ret);
+	}
 
-	list_move_tail(&obj->batch_pool_link, list);
+	list_add_tail(&obj->batch_pool_link, list);
 	return obj;
 }
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index ea90d3a0d511..610a78e2f0b1 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -117,6 +117,15 @@ static bool unsafe_drop_pages(struct drm_i915_gem_object *obj)
 	return !i915_gem_object_has_pages(obj);
 }
 
+static void shrink_caches(struct drm_i915_private *i915)
+{
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+
+	for_each_engine(engine, i915, id)
+		i915_gem_batch_pool_fini(&engine->batch_pool);
+}
+
 /**
  * i915_gem_shrink - Shrink buffer object caches
  * @i915: i915 device
@@ -180,6 +189,8 @@ i915_gem_shrink(struct drm_i915_private *i915,
 	trace_i915_gem_shrink(i915, target, flags);
 	i915_retire_requests(i915);
 
+	shrink_caches(i915);
+
 	/*
 	 * Unbinding of objects will require HW access; Let us not wake the
 	 * device just to recover a little memory. If absolutely necessary,
diff --git a/drivers/gpu/drm/i915/selftests/mock_engine.c b/drivers/gpu/drm/i915/selftests/mock_engine.c
index 22a73da45ad5..8fc511eb3f13 100644
--- a/drivers/gpu/drm/i915/selftests/mock_engine.c
+++ b/drivers/gpu/drm/i915/selftests/mock_engine.c
@@ -205,6 +205,8 @@ struct intel_engine_cs *mock_engine(struct drm_i915_private *i915,
 	intel_engine_init_breadcrumbs(&engine->base);
 	engine->base.breadcrumbs.mock = true; /* prevent touching HW for irqs */
 
+	intel_engine_init_batch_pool(&engine->base);
+
 	/* fake hw queue */
 	spin_lock_init(&engine->hw_lock);
 	timer_setup(&engine->hw_delay, hw_delay_complete, 0);
-- 
2.19.0

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

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

* ✓ Fi.CI.BAT: success for drm/i915: Recover batch pool caches from shrinker (rev2)
  2018-09-15 16:40 [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
  2018-09-15 17:09 ` ✗ Fi.CI.BAT: failure for " Patchwork
  2018-09-16 20:57 ` [PATCH v2] " Chris Wilson
@ 2018-09-16 21:56 ` Patchwork
  2018-09-16 22:56 ` ✗ Fi.CI.IGT: failure " Patchwork
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-09-16 21:56 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Recover batch pool caches from shrinker (rev2)
URL   : https://patchwork.freedesktop.org/series/49757/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4833 -> Patchwork_10200 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/49757/revisions/2/mbox/

== Known issues ==

  Here are the changes found in Patchwork_10200 that come from known issues:

  === IGT changes ===

    ==== Possible fixes ====

    igt@drv_module_reload@basic-reload:
      fi-blb-e6850:       INCOMPLETE (fdo#107718) -> PASS

    igt@drv_selftest@live_hangcheck:
      fi-glk-j4005:       INCOMPLETE (k.org#198133, fdo#103359) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      fi-icl-u:           INCOMPLETE (fdo#107713) -> PASS

    igt@kms_psr@primary_page_flip:
      fi-kbl-r:           FAIL (fdo#107336) -> PASS

    
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  fdo#107336 https://bugs.freedesktop.org/show_bug.cgi?id=107336
  fdo#107713 https://bugs.freedesktop.org/show_bug.cgi?id=107713
  fdo#107718 https://bugs.freedesktop.org/show_bug.cgi?id=107718
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


== Participating hosts (46 -> 40) ==

  Missing    (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-snb-2520m fi-hsw-4770 


== Build changes ==

    * Linux: CI_DRM_4833 -> Patchwork_10200

  CI_DRM_4833: 75bb460b367a614d10b0fba220143bee42657d7e @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4644: 0b59bb3231ab481959528c5c7b3a98762772e1b0 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10200: 2d2cbadfbca81b815b38ef1d5c8cc6c21207aace @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

2d2cbadfbca8 drm/i915: Recover batch pool caches from shrinker

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10200/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.IGT: failure for drm/i915: Recover batch pool caches from shrinker (rev2)
  2018-09-15 16:40 [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
                   ` (2 preceding siblings ...)
  2018-09-16 21:56 ` ✓ Fi.CI.BAT: success for drm/i915: Recover batch pool caches from shrinker (rev2) Patchwork
@ 2018-09-16 22:56 ` Patchwork
  2018-09-19 19:49 ` [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-09-16 22:56 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Recover batch pool caches from shrinker (rev2)
URL   : https://patchwork.freedesktop.org/series/49757/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4833_full -> Patchwork_10200_full =

== Summary - FAILURE ==

  Serious unknown changes coming with Patchwork_10200_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_10200_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

== Possible new issues ==

  Here are the unknown changes that may have been introduced in Patchwork_10200_full:

  === IGT changes ===

    ==== Possible regressions ====

    igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
      shard-apl:          PASS -> DMESG-WARN

    
== Known issues ==

  Here are the changes found in Patchwork_10200_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_await@wide-contexts:
      shard-kbl:          PASS -> FAIL (fdo#106680)

    igt@kms_flip@dpms-vs-vblank-race:
      shard-apl:          PASS -> FAIL (fdo#103060)

    
    ==== Possible fixes ====

    igt@kms_frontbuffer_tracking@fbc-stridechange:
      shard-glk:          FAIL (fdo#103167) -> PASS

    igt@kms_setmode@basic:
      shard-apl:          FAIL (fdo#99912) -> PASS

    
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#106680 https://bugs.freedesktop.org/show_bug.cgi?id=106680
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * Linux: CI_DRM_4833 -> Patchwork_10200

  CI_DRM_4833: 75bb460b367a614d10b0fba220143bee42657d7e @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4644: 0b59bb3231ab481959528c5c7b3a98762772e1b0 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10200: 2d2cbadfbca81b815b38ef1d5c8cc6c21207aace @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10200/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v2] drm/i915: Recover batch pool caches from shrinker
  2018-09-16 20:57 ` [PATCH v2] " Chris Wilson
@ 2018-09-19 18:34   ` Matthew Auld
  2018-09-19 19:39     ` Chris Wilson
  0 siblings, 1 reply; 12+ messages in thread
From: Matthew Auld @ 2018-09-19 18:34 UTC (permalink / raw)
  To: Chris Wilson; +Cc: Intel Graphics Development

On Sun, 16 Sep 2018 at 21:59, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Discard all of our batch pools under mempressure to make their pages
> available to the shrinker. We will quickly reacquire them when necessary
> for more GPU relocations or for the command parser.
>
> v2: Init the lists for mock_engine
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107936
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

What stops shrink_caches being called while we have a batch pool
object with its pages still pinned, like in the middle of
__reloc_gpu_alloc? Maybe I'm missing something...
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v2] drm/i915: Recover batch pool caches from shrinker
  2018-09-19 18:34   ` Matthew Auld
@ 2018-09-19 19:39     ` Chris Wilson
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-09-19 19:39 UTC (permalink / raw)
  To: Matthew Auld; +Cc: Intel Graphics Development

Quoting Matthew Auld (2018-09-19 19:34:47)
> On Sun, 16 Sep 2018 at 21:59, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> >
> > Discard all of our batch pools under mempressure to make their pages
> > available to the shrinker. We will quickly reacquire them when necessary
> > for more GPU relocations or for the command parser.
> >
> > v2: Init the lists for mock_engine
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107936
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> What stops shrink_caches being called while we have a batch pool
> object with its pages still pinned, like in the middle of
> __reloc_gpu_alloc? Maybe I'm missing something...

Once it is pinned for use, it is fine, it cannot be shrunk underneath
us. The problem lies in the zombie reference as we may find ourselves
without an active reference. The only way to be certain would be to
return a strong ref. That just felt like more upheaval than it was
worth (or rather I was hoping that the active-ref would be earlier).
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH] drm/i915: Recover batch pool caches from shrinker
  2018-09-15 16:40 [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
                   ` (3 preceding siblings ...)
  2018-09-16 22:56 ` ✗ Fi.CI.IGT: failure " Patchwork
@ 2018-09-19 19:49 ` Chris Wilson
  2018-09-20  9:57   ` Matthew Auld
  2018-09-19 20:36 ` ✓ Fi.CI.BAT: success for drm/i915: Recover batch pool caches from shrinker (rev3) Patchwork
  2018-09-19 21:30 ` ✓ Fi.CI.IGT: " Patchwork
  6 siblings, 1 reply; 12+ messages in thread
From: Chris Wilson @ 2018-09-19 19:49 UTC (permalink / raw)
  To: intel-gfx

Discard all of our batch pools under mempressure to make their pages
available to the shrinker. We will quickly reacquire them when necessary
for more GPU relocations or for the command parser.

v2: Init the lists for mock_engine
v3: Return a strong ref from i915_gem_batch_pool_get() and convert it
into an active reference to protect ourselves against all allocations
while the object is in play.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107936
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.william.auld@gmail.com>
---
 drivers/gpu/drm/i915/i915_gem_batch_pool.c   |  9 ++++++---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   | 15 +++++++++++----
 drivers/gpu/drm/i915/i915_gem_object.h       |  1 +
 drivers/gpu/drm/i915/i915_gem_shrinker.c     | 11 +++++++++++
 drivers/gpu/drm/i915/selftests/mock_engine.c |  2 ++
 5 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_batch_pool.c b/drivers/gpu/drm/i915/i915_gem_batch_pool.c
index f3890b664e3f..b560350cc138 100644
--- a/drivers/gpu/drm/i915/i915_gem_batch_pool.c
+++ b/drivers/gpu/drm/i915/i915_gem_batch_pool.c
@@ -131,10 +131,13 @@ i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,
 		return obj;
 
 found:
+	list_del(&obj->batch_pool_link);
 	ret = i915_gem_object_pin_pages(obj);
-	if (ret)
+	if (ret) {
+		i915_gem_object_put(obj);
 		return ERR_PTR(ret);
+	}
 
-	list_move_tail(&obj->batch_pool_link, list);
-	return obj;
+	list_add_tail(&obj->batch_pool_link, list);
+	return i915_gem_object_get(obj);
 }
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 7f70188809b0..9a565d6f2864 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1150,8 +1150,10 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
 				      I915_MAP_FORCE_WB :
 				      I915_MAP_FORCE_WC);
 	i915_gem_object_unpin_pages(obj);
-	if (IS_ERR(cmd))
-		return PTR_ERR(cmd);
+	if (IS_ERR(cmd)) {
+		err = PTR_ERR(cmd);
+		goto err_put;
+	}
 
 	err = i915_gem_object_set_to_wc_domain(obj, false);
 	if (err)
@@ -1194,6 +1196,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
 
 	rq->batch = batch;
 	i915_vma_unpin(batch);
+	i915_gem_object_set_active_reference(obj);
 
 	cache->rq = rq;
 	cache->rq_cmd = cmd;
@@ -1210,6 +1213,8 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
 	i915_vma_unpin(batch);
 err_unmap:
 	i915_gem_object_unpin_map(obj);
+err_put:
+	i915_gem_object_put(obj);
 	return err;
 }
 
@@ -1943,13 +1948,15 @@ static struct i915_vma *eb_parse(struct i915_execbuffer *eb, bool is_master)
 		goto out;
 
 	eb->vma[eb->buffer_count] = i915_vma_get(vma);
-	eb->flags[eb->buffer_count] =
-		__EXEC_OBJECT_HAS_PIN | __EXEC_OBJECT_HAS_REF;
+	eb->flags[eb->buffer_count] = __EXEC_OBJECT_HAS_PIN;
 	vma->exec_flags = &eb->flags[eb->buffer_count];
 	eb->buffer_count++;
 
+	i915_gem_object_set_active_reference(shadow_batch_obj);
+
 out:
 	i915_gem_object_unpin_pages(shadow_batch_obj);
+	i915_gem_object_put(shadow_batch_obj);
 	return vma;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_gem_object.h b/drivers/gpu/drm/i915/i915_gem_object.h
index a6dd7c46de0d..e756b55190b7 100644
--- a/drivers/gpu/drm/i915/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/i915_gem_object.h
@@ -402,6 +402,7 @@ static inline void
 i915_gem_object_set_active_reference(struct drm_i915_gem_object *obj)
 {
 	lockdep_assert_held(&obj->base.dev->struct_mutex);
+	GEM_BUG_ON(test_bit(I915_BO_ACTIVE_REF, &obj->flags));
 	__set_bit(I915_BO_ACTIVE_REF, &obj->flags);
 }
 
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index 681226992705..6036fe8495d4 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -117,6 +117,15 @@ static bool unsafe_drop_pages(struct drm_i915_gem_object *obj)
 	return !i915_gem_object_has_pages(obj);
 }
 
+static void shrink_caches(struct drm_i915_private *i915)
+{
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+
+	for_each_engine(engine, i915, id)
+		i915_gem_batch_pool_fini(&engine->batch_pool);
+}
+
 /**
  * i915_gem_shrink - Shrink buffer object caches
  * @i915: i915 device
@@ -181,6 +190,8 @@ i915_gem_shrink(struct drm_i915_private *i915,
 	trace_i915_gem_shrink(i915, target, flags);
 	i915_retire_requests(i915);
 
+	shrink_caches(i915);
+
 	/*
 	 * Unbinding of objects will require HW access; Let us not wake the
 	 * device just to recover a little memory. If absolutely necessary,
diff --git a/drivers/gpu/drm/i915/selftests/mock_engine.c b/drivers/gpu/drm/i915/selftests/mock_engine.c
index 22a73da45ad5..8fc511eb3f13 100644
--- a/drivers/gpu/drm/i915/selftests/mock_engine.c
+++ b/drivers/gpu/drm/i915/selftests/mock_engine.c
@@ -205,6 +205,8 @@ struct intel_engine_cs *mock_engine(struct drm_i915_private *i915,
 	intel_engine_init_breadcrumbs(&engine->base);
 	engine->base.breadcrumbs.mock = true; /* prevent touching HW for irqs */
 
+	intel_engine_init_batch_pool(&engine->base);
+
 	/* fake hw queue */
 	spin_lock_init(&engine->hw_lock);
 	timer_setup(&engine->hw_delay, hw_delay_complete, 0);
-- 
2.19.0

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

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

* ✓ Fi.CI.BAT: success for drm/i915: Recover batch pool caches from shrinker (rev3)
  2018-09-15 16:40 [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
                   ` (4 preceding siblings ...)
  2018-09-19 19:49 ` [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
@ 2018-09-19 20:36 ` Patchwork
  2018-09-19 21:30 ` ✓ Fi.CI.IGT: " Patchwork
  6 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-09-19 20:36 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Recover batch pool caches from shrinker (rev3)
URL   : https://patchwork.freedesktop.org/series/49757/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4844 -> Patchwork_10227 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/49757/revisions/3/mbox/

== Known issues ==

  Here are the changes found in Patchwork_10227 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_suspend@basic-s3:
      fi-bdw-samus:       PASS -> INCOMPLETE (fdo#107773)

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a:
      fi-ilk-650:         PASS -> DMESG-WARN (fdo#106387)
      fi-byt-clapper:     PASS -> FAIL (fdo#107362)

    igt@kms_pipe_crc_basic@read-crc-pipe-a-frame-sequence:
      fi-byt-clapper:     PASS -> FAIL (fdo#103191, fdo#107362)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-blb-e6850:       PASS -> INCOMPLETE (fdo#107718)

    igt@kms_psr@primary_page_flip:
      fi-icl-u:           PASS -> FAIL (fdo#107336)

    
    ==== Possible fixes ====

    igt@drv_module_reload@basic-reload:
      fi-glk-j4005:       DMESG-WARN (fdo#106248, fdo#106725) -> PASS

    igt@drv_selftest@mock_hugepages:
      fi-bwr-2160:        DMESG-FAIL (fdo#107930) -> PASS

    igt@kms_flip@basic-flip-vs-modeset:
      fi-glk-j4005:       DMESG-WARN (fdo#106000) -> PASS

    igt@pm_rpm@module-reload:
      fi-glk-j4005:       DMESG-WARN (fdo#107726) -> PASS

    
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
  fdo#106387 https://bugs.freedesktop.org/show_bug.cgi?id=106387
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
  fdo#107336 https://bugs.freedesktop.org/show_bug.cgi?id=107336
  fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
  fdo#107718 https://bugs.freedesktop.org/show_bug.cgi?id=107718
  fdo#107726 https://bugs.freedesktop.org/show_bug.cgi?id=107726
  fdo#107773 https://bugs.freedesktop.org/show_bug.cgi?id=107773
  fdo#107930 https://bugs.freedesktop.org/show_bug.cgi?id=107930


== Participating hosts (52 -> 45) ==

  Missing    (7): fi-hsw-4770r fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-skl-6700hq 


== Build changes ==

    * Linux: CI_DRM_4844 -> Patchwork_10227

  CI_DRM_4844: 73c0da2189956c18a0fff343bd84eb0493f81db1 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4646: d409cc6f234fbc0122c64be27ba85b5603658de5 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10227: 2b05c8b75b63a77e6c8a44449cf71c3b713a211f @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

2b05c8b75b63 drm/i915: Recover batch pool caches from shrinker

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10227/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✓ Fi.CI.IGT: success for drm/i915: Recover batch pool caches from shrinker (rev3)
  2018-09-15 16:40 [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
                   ` (5 preceding siblings ...)
  2018-09-19 20:36 ` ✓ Fi.CI.BAT: success for drm/i915: Recover batch pool caches from shrinker (rev3) Patchwork
@ 2018-09-19 21:30 ` Patchwork
  6 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2018-09-19 21:30 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Recover batch pool caches from shrinker (rev3)
URL   : https://patchwork.freedesktop.org/series/49757/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4844_full -> Patchwork_10227_full =

== Summary - SUCCESS ==

  No regressions found.

  

== Known issues ==

  Here are the changes found in Patchwork_10227_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_eio@in-flight-internal-10ms:
      shard-hsw:          SKIP -> INCOMPLETE (fdo#103540) +1

    igt@gem_linear_blits@interruptible:
      shard-hsw:          PASS -> INCOMPLETE (fdo#103540) +1

    igt@kms_flip@2x-plain-flip-ts-check-interruptible:
      shard-glk:          PASS -> FAIL (fdo#100368)

    igt@kms_flip@basic-flip-vs-dpms:
      shard-kbl:          PASS -> DMESG-WARN (fdo#103558)

    
    ==== Possible fixes ====

    igt@kms_busy@extended-pageflip-hang-newfb-render-c:
      shard-glk:          DMESG-WARN (fdo#107956) -> PASS

    igt@kms_chv_cursor_fail@pipe-a-64x64-bottom-edge:
      shard-glk:          FAIL (fdo#104671) -> PASS

    igt@kms_cursor_legacy@cursora-vs-flipa-toggle:
      shard-glk:          DMESG-WARN (fdo#105763, fdo#106538) -> PASS

    igt@kms_draw_crc@draw-method-xrgb2101010-mmap-gtt-xtiled:
      shard-glk:          FAIL (fdo#103184) -> PASS

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-glk:          FAIL (fdo#102887, fdo#105363) -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-cpu:
      shard-glk:          FAIL (fdo#103167) -> PASS

    igt@perf@blocking:
      shard-hsw:          FAIL (fdo#102252) -> PASS

    igt@syncobj_wait@multi-wait-all-for-submit-submitted:
      shard-snb:          DMESG-WARN (fdo#107469) -> PASS

    
    ==== Warnings ====

    igt@kms_frontbuffer_tracking@fbc-1p-indfb-fliptrack:
      shard-snb:          DMESG-FAIL (fdo#107988) -> INCOMPLETE (fdo#105411)

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
  fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103184 https://bugs.freedesktop.org/show_bug.cgi?id=103184
  fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
  fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
  fdo#104671 https://bugs.freedesktop.org/show_bug.cgi?id=104671
  fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#105763 https://bugs.freedesktop.org/show_bug.cgi?id=105763
  fdo#106538 https://bugs.freedesktop.org/show_bug.cgi?id=106538
  fdo#107469 https://bugs.freedesktop.org/show_bug.cgi?id=107469
  fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
  fdo#107988 https://bugs.freedesktop.org/show_bug.cgi?id=107988


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * Linux: CI_DRM_4844 -> Patchwork_10227

  CI_DRM_4844: 73c0da2189956c18a0fff343bd84eb0493f81db1 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4646: d409cc6f234fbc0122c64be27ba85b5603658de5 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10227: 2b05c8b75b63a77e6c8a44449cf71c3b713a211f @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10227/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Recover batch pool caches from shrinker
  2018-09-19 19:49 ` [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
@ 2018-09-20  9:57   ` Matthew Auld
  2018-09-20 10:02     ` Chris Wilson
  0 siblings, 1 reply; 12+ messages in thread
From: Matthew Auld @ 2018-09-20  9:57 UTC (permalink / raw)
  To: Chris Wilson; +Cc: Intel Graphics Development

On Wed, 19 Sep 2018 at 20:49, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Discard all of our batch pools under mempressure to make their pages
> available to the shrinker. We will quickly reacquire them when necessary
> for more GPU relocations or for the command parser.
>
> v2: Init the lists for mock_engine
> v3: Return a strong ref from i915_gem_batch_pool_get() and convert it
> into an active reference to protect ourselves against all allocations
> while the object is in play.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107936
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.william.auld@gmail.com>
Reviewed-by: Matthew Auld <matthew.william.auld@gmail.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Recover batch pool caches from shrinker
  2018-09-20  9:57   ` Matthew Auld
@ 2018-09-20 10:02     ` Chris Wilson
  0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2018-09-20 10:02 UTC (permalink / raw)
  To: Matthew Auld; +Cc: Intel Graphics Development

Quoting Matthew Auld (2018-09-20 10:57:34)
> On Wed, 19 Sep 2018 at 20:49, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> >
> > Discard all of our batch pools under mempressure to make their pages
> > available to the shrinker. We will quickly reacquire them when necessary
> > for more GPU relocations or for the command parser.
> >
> > v2: Init the lists for mock_engine
> > v3: Return a strong ref from i915_gem_batch_pool_get() and convert it
> > into an active reference to protect ourselves against all allocations
> > while the object is in play.
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107936
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Matthew Auld <matthew.william.auld@gmail.com>
> Reviewed-by: Matthew Auld <matthew.william.auld@gmail.com>

Sorry, still not quite right yet. Closer, but the conversion into an
active reference is not guaranteed (as the execbuf may be interrupted).
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2018-09-20 10:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-15 16:40 [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
2018-09-15 17:09 ` ✗ Fi.CI.BAT: failure for " Patchwork
2018-09-16 20:57 ` [PATCH v2] " Chris Wilson
2018-09-19 18:34   ` Matthew Auld
2018-09-19 19:39     ` Chris Wilson
2018-09-16 21:56 ` ✓ Fi.CI.BAT: success for drm/i915: Recover batch pool caches from shrinker (rev2) Patchwork
2018-09-16 22:56 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-09-19 19:49 ` [PATCH] drm/i915: Recover batch pool caches from shrinker Chris Wilson
2018-09-20  9:57   ` Matthew Auld
2018-09-20 10:02     ` Chris Wilson
2018-09-19 20:36 ` ✓ Fi.CI.BAT: success for drm/i915: Recover batch pool caches from shrinker (rev3) Patchwork
2018-09-19 21:30 ` ✓ Fi.CI.IGT: " Patchwork

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.