All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Protect i915_active iterators from the shrinker
@ 2019-02-08 13:47 Chris Wilson
  2019-02-08 14:50 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chris Wilson @ 2019-02-08 13:47 UTC (permalink / raw)
  To: intel-gfx

If we allocate while iterating the rbtree of active nodes, we may hit
the shrinker and so retire the i915_active reap the rbtree. Modifying
the rbtree as we iterate is not good behaviour, so acquire the
i915_active first to keep the tree intact whenever we allocate.

Fixes: a42375af0a30 ("drm/i915: Release the active tracker tree upon idling")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_active.c | 36 +++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index 215b6ff8aa73..db7bb5bd5add 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -163,17 +163,25 @@ int i915_active_ref(struct i915_active *ref,
 		    struct i915_request *rq)
 {
 	struct i915_active_request *active;
+	int err = 0;
+
+	/* Prevent reaping in case we malloc/wait while building the tree */
+	i915_active_acquire(ref);
 
 	active = active_instance(ref, timeline);
-	if (IS_ERR(active))
-		return PTR_ERR(active);
+	if (IS_ERR(active)) {
+		err = PTR_ERR(active);
+		goto out;
+	}
 
 	if (!i915_active_request_isset(active))
 		ref->count++;
 	__i915_active_request_set(active, rq);
 
 	GEM_BUG_ON(!ref->count);
-	return 0;
+out:
+	i915_active_release(ref);
+	return err;
 }
 
 bool i915_active_acquire(struct i915_active *ref)
@@ -223,19 +231,25 @@ int i915_request_await_active_request(struct i915_request *rq,
 int i915_request_await_active(struct i915_request *rq, struct i915_active *ref)
 {
 	struct active_node *it, *n;
-	int ret;
+	int err = 0;
 
-	ret = i915_request_await_active_request(rq, &ref->last);
-	if (ret)
-		return ret;
+	/* await allocates and so we need to avoid hitting the shrinker */
+	if (i915_active_acquire(ref))
+		goto out; /* was idle */
+
+	err = i915_request_await_active_request(rq, &ref->last);
+	if (err)
+		goto out;
 
 	rbtree_postorder_for_each_entry_safe(it, n, &ref->tree, node) {
-		ret = i915_request_await_active_request(rq, &it->base);
-		if (ret)
-			return ret;
+		err = i915_request_await_active_request(rq, &it->base);
+		if (err)
+			goto out;
 	}
 
-	return 0;
+out:
+	i915_active_release(ref);
+	return err;
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
-- 
2.20.1

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

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

* ✓ Fi.CI.BAT: success for drm/i915: Protect i915_active iterators from the shrinker
  2019-02-08 13:47 [PATCH] drm/i915: Protect i915_active iterators from the shrinker Chris Wilson
@ 2019-02-08 14:50 ` Patchwork
  2019-02-08 16:51 ` ✓ Fi.CI.IGT: " Patchwork
  2019-02-11 11:13 ` [PATCH] " Tvrtko Ursulin
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2019-02-08 14:50 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Protect i915_active iterators from the shrinker
URL   : https://patchwork.freedesktop.org/series/56401/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5567 -> Patchwork_12176
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

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

Known issues
------------

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

### IGT changes ###

#### Issues hit ####

  * igt@i915_module_load@reload:
    - fi-blb-e6850:       PASS -> INCOMPLETE [fdo#107718]

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-kbl-7500u:       PASS -> FAIL [fdo#109485]

  * igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b:
    - fi-byt-clapper:     PASS -> FAIL [fdo#107362]

  * igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b-frame-sequence:
    - fi-byt-clapper:     PASS -> FAIL [fdo#103191] / [fdo#107362] +1

  * igt@pm_rpm@basic-rte:
    - fi-bsw-kefka:       PASS -> FAIL [fdo#108800]

  
#### Possible fixes ####

  * igt@i915_selftest@live_execlists:
    - fi-apl-guc:         INCOMPLETE [fdo#103927] -> PASS

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
    - fi-byt-clapper:     FAIL [fdo#103191] / [fdo#107362] -> PASS

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
  [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
  [fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#108800]: https://bugs.freedesktop.org/show_bug.cgi?id=108800
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485


Participating hosts (49 -> 45)
------------------------------

  Missing    (4): fi-kbl-soraka fi-ilk-m540 fi-byt-squawks fi-bsw-cyan 


Build changes
-------------

    * Linux: CI_DRM_5567 -> Patchwork_12176

  CI_DRM_5567: 5725867972123d46f4a4d382ed5fa2eb0348b00c @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4815: 947301563259726b65ce47d3a3fe37931ed42efe @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_12176: 181afb7298dc8711773c304572ab39cd75fff5f6 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

181afb7298dc drm/i915: Protect i915_active iterators from the shrinker

== Logs ==

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

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

* ✓ Fi.CI.IGT: success for drm/i915: Protect i915_active iterators from the shrinker
  2019-02-08 13:47 [PATCH] drm/i915: Protect i915_active iterators from the shrinker Chris Wilson
  2019-02-08 14:50 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2019-02-08 16:51 ` Patchwork
  2019-02-11 11:13 ` [PATCH] " Tvrtko Ursulin
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2019-02-08 16:51 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Protect i915_active iterators from the shrinker
URL   : https://patchwork.freedesktop.org/series/56401/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5567_full -> Patchwork_12176_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Known issues
------------

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

### IGT changes ###

#### Issues hit ####

  * igt@kms_cursor_crc@cursor-128x128-random:
    - shard-apl:          PASS -> FAIL [fdo#103232]

  * igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
    - shard-hsw:          PASS -> FAIL [fdo#105767]

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-blt:
    - shard-glk:          PASS -> FAIL [fdo#103167] +2

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-render:
    - shard-apl:          PASS -> FAIL [fdo#103167] +1

  * igt@kms_plane_alpha_blend@pipe-b-alpha-opaque-fb:
    - shard-glk:          PASS -> FAIL [fdo#108145]

  * igt@kms_plane_multiple@atomic-pipe-c-tiling-none:
    - shard-apl:          PASS -> FAIL [fdo#103166] +1

  * igt@kms_universal_plane@universal-plane-pipe-c-functional:
    - shard-glk:          PASS -> FAIL [fdo#103166] +1

  
#### Possible fixes ####

  * igt@kms_cursor_crc@cursor-64x64-suspend:
    - shard-apl:          FAIL [fdo#103191] / [fdo#103232] -> PASS

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-mmap-cpu:
    - shard-apl:          FAIL [fdo#103167] -> PASS +1

  * igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-mmap-cpu:
    - shard-glk:          FAIL [fdo#103167] -> PASS +3

  * igt@kms_plane@pixel-format-pipe-b-planes-source-clamping:
    - shard-apl:          FAIL [fdo#108948] -> PASS +1

  * igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb:
    - shard-apl:          FAIL [fdo#108145] -> PASS

  
#### Warnings ####

  * igt@kms_frontbuffer_tracking@fbc-farfromfence:
    - shard-snb:          DMESG-FAIL [fdo#107469] -> INCOMPLETE [fdo#105411]

  
  [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
  [fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
  [fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
  [fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
  [fdo#107469]: https://bugs.freedesktop.org/show_bug.cgi?id=107469
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#108948]: https://bugs.freedesktop.org/show_bug.cgi?id=108948


Participating hosts (7 -> 5)
------------------------------

  Missing    (2): shard-skl shard-iclb 


Build changes
-------------

    * Linux: CI_DRM_5567 -> Patchwork_12176

  CI_DRM_5567: 5725867972123d46f4a4d382ed5fa2eb0348b00c @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4815: 947301563259726b65ce47d3a3fe37931ed42efe @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_12176: 181afb7298dc8711773c304572ab39cd75fff5f6 @ 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_12176/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Protect i915_active iterators from the shrinker
  2019-02-08 13:47 [PATCH] drm/i915: Protect i915_active iterators from the shrinker Chris Wilson
  2019-02-08 14:50 ` ✓ Fi.CI.BAT: success for " Patchwork
  2019-02-08 16:51 ` ✓ Fi.CI.IGT: " Patchwork
@ 2019-02-11 11:13 ` Tvrtko Ursulin
  2019-02-11 12:50   ` Chris Wilson
  2 siblings, 1 reply; 5+ messages in thread
From: Tvrtko Ursulin @ 2019-02-11 11:13 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx


On 08/02/2019 13:47, Chris Wilson wrote:
> If we allocate while iterating the rbtree of active nodes, we may hit
> the shrinker and so retire the i915_active reap the rbtree. Modifying
> the rbtree as we iterate is not good behaviour, so acquire the
> i915_active first to keep the tree intact whenever we allocate.
> 
> Fixes: a42375af0a30 ("drm/i915: Release the active tracker tree upon idling")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
>   drivers/gpu/drm/i915/i915_active.c | 36 +++++++++++++++++++++---------
>   1 file changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> index 215b6ff8aa73..db7bb5bd5add 100644
> --- a/drivers/gpu/drm/i915/i915_active.c
> +++ b/drivers/gpu/drm/i915/i915_active.c
> @@ -163,17 +163,25 @@ int i915_active_ref(struct i915_active *ref,
>   		    struct i915_request *rq)
>   {
>   	struct i915_active_request *active;
> +	int err = 0;
> +
> +	/* Prevent reaping in case we malloc/wait while building the tree */
> +	i915_active_acquire(ref);
>   
>   	active = active_instance(ref, timeline);
> -	if (IS_ERR(active))
> -		return PTR_ERR(active);
> +	if (IS_ERR(active)) {
> +		err = PTR_ERR(active);
> +		goto out;
> +	}
>   
>   	if (!i915_active_request_isset(active))
>   		ref->count++;
>   	__i915_active_request_set(active, rq);
>   
>   	GEM_BUG_ON(!ref->count);
> -	return 0;
> +out:
> +	i915_active_release(ref);
> +	return err;
>   }
>   
>   bool i915_active_acquire(struct i915_active *ref)
> @@ -223,19 +231,25 @@ int i915_request_await_active_request(struct i915_request *rq,
>   int i915_request_await_active(struct i915_request *rq, struct i915_active *ref)
>   {
>   	struct active_node *it, *n;
> -	int ret;
> +	int err = 0;
>   
> -	ret = i915_request_await_active_request(rq, &ref->last);
> -	if (ret)
> -		return ret;
> +	/* await allocates and so we need to avoid hitting the shrinker */
> +	if (i915_active_acquire(ref))
> +		goto out; /* was idle */
> +
> +	err = i915_request_await_active_request(rq, &ref->last);
> +	if (err)
> +		goto out;
>   
>   	rbtree_postorder_for_each_entry_safe(it, n, &ref->tree, node) {
> -		ret = i915_request_await_active_request(rq, &it->base);
> -		if (ret)
> -			return ret;
> +		err = i915_request_await_active_request(rq, &it->base);
> +		if (err)
> +			goto out;
>   	}
>   
> -	return 0;
> +out:
> +	i915_active_release(ref);
> +	return err;
>   }
>   
>   #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)
> 

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

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

* Re: [PATCH] drm/i915: Protect i915_active iterators from the shrinker
  2019-02-11 11:13 ` [PATCH] " Tvrtko Ursulin
@ 2019-02-11 12:50   ` Chris Wilson
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2019-02-11 12:50 UTC (permalink / raw)
  To: Tvrtko Ursulin, intel-gfx

Quoting Tvrtko Ursulin (2019-02-11 11:13:12)
> 
> On 08/02/2019 13:47, Chris Wilson wrote:
> > If we allocate while iterating the rbtree of active nodes, we may hit
> > the shrinker and so retire the i915_active reap the rbtree. Modifying
> > the rbtree as we iterate is not good behaviour, so acquire the
> > i915_active first to keep the tree intact whenever we allocate.

Bleugh, better grammar included.

> > Fixes: a42375af0a30 ("drm/i915: Release the active tracker tree upon idling")
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

And pushed, thanks.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2019-02-11 12:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08 13:47 [PATCH] drm/i915: Protect i915_active iterators from the shrinker Chris Wilson
2019-02-08 14:50 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-02-08 16:51 ` ✓ Fi.CI.IGT: " Patchwork
2019-02-11 11:13 ` [PATCH] " Tvrtko Ursulin
2019-02-11 12:50   ` Chris Wilson

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.