Skip to contentSkip to conversation

drm/i915: Unbind objects in shrinker only if device is runtime active

PATCH In review Praveen Paneri 3 participants 5 messages May 2, 2016 – May 3, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/i915: Unbind objects in shrinker only if device is runtime active

When the system is running low on memory, gem shrinker is invoked. In this process objects will be unbounded from GTT and unbinding process will require access to GTT(GTTADR) and also to fence register potentially. That requires a resume of gfx device, if suspended, in the shrinker path. Considering the power leakage due to intermediate resume, perform unbinding operation only if device is already runtime active.

v2: Use newly implemented intel_runtime_pm_get_if_in_use (Chris)

---
 drivers/gpu/drm/i915/i915_gem_shrinker.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/gpu/drm/i915/i915_gem_shrinker.c +12 -0
index 2643d18..9a24415 100644
@@ -134,6 +134,15 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
 	i915_gem_retire_requests(dev_priv->dev);
 
 	/*
+	 * Unbinding of objects will require HW access; Let us not wake the
+	 * device just to recover a little memory. If absolutely necessary,
+	 * we will force the wake during oom-notifier.
+	 */
+	if ((flags & I915_SHRINK_BOUND) &&
+	    !intel_runtime_pm_get_if_in_use(dev_priv))
+		flags &= ~I915_SHRINK_BOUND;
+
+	/*
 	 * As we may completely rewrite the (un)bound list whilst unbinding
 	 * (due to retiring requests) we have to strictly process only
 	 * one element of the list at the time, and recheck the list
@@ -197,6 +206,9 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
 		list_splice(&still_in_list, phase->list);
 	}
 
+	if (flags & I915_SHRINK_BOUND)
+		intel_runtime_pm_put(dev_priv);
+
 	i915_gem_retire_requests(dev_priv->dev);
 
 	return count;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 drm/i915: Add rpm get/put in oom and vmap notifier

i915_gem_shrink() will scan the bound list only if device is not suspended but in OOM failure scenario it becomes absolutely necessary to release as much memory as possible. Also in allocation failure from vmap address space, it is incumbent on the Driver to reap all its vmaps. So, adding rpm get/put in i915_gem_shrinker_oom() and i915_gem_shrinker_vmap() to ensure shrinking of bound objects as well.

---
 drivers/gpu/drm/i915/i915_gem_shrinker.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_gem_shrinker.c +4 -0
index 9a24415..79004f3 100644
@@ -357,7 +357,9 @@ i915_gem_shrinker_oom(struct notifier_block *nb, unsigned long event, void *ptr)
 	if (!i915_gem_shrinker_lock_uninterruptible(dev_priv, &slu, 5000))
 		return NOTIFY_DONE;
 
+	intel_runtime_pm_get(dev_priv);
 	freed_pages = i915_gem_shrink_all(dev_priv);
+	intel_runtime_pm_put(dev_priv);
 
 	/* Because we may be allocating inside our own driver, we cannot
 	 * assert that there are no objects with pinned pages that are not
@@ -410,11 +412,13 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
 	if (ret)
 		goto out;
 
+	intel_runtime_pm_get(dev_priv);
 	freed_pages += i915_gem_shrink(dev_priv, -1UL,
 				       I915_SHRINK_BOUND |
 				       I915_SHRINK_UNBOUND |
 				       I915_SHRINK_ACTIVE |
 				       I915_SHRINK_VMAPS);
+	intel_runtime_pm_put(dev_priv);
 
 	/* We also want to clear any cached iomaps as they wrap vmap */
 	list_for_each_entry_safe(vma, next,
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH 2/2] drm/i915: Add rpm get/put in oom and vmap notifier

Quoted 9 lines · Praveen Paneri

i915_gem_shrink() will scan the bound list only if device is not suspended but in OOM failure scenario it becomes absolutely necessary to release as much memory as possible. Also in allocation failure from vmap address space, it is incumbent on the Driver to reap all its vmaps. So, adding rpm get/put in i915_gem_shrinker_oom() and i915_gem_shrinker_vmap() to ensure shrinking of bound objects as well.

Please do mention when you made changed. I skipped over this series when I only saw the 2 patches because I thought to myself you hadn't added the third patch for the new vmap path.

Nevertheless applied, thanks.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH 2/2] drm/i915: Add rpm get/put in oom and vmap notifier

Quoted 8 lines · Chris Wilson
Quoted 7 lines · Praveen Paneri

i915_gem_shrink() will scan the bound list only if device is not suspended but in OOM failure scenario it becomes absolutely necessary to release as much memory as possible. Also in allocation failure from vmap address space, it is incumbent on the Driver to reap all its vmaps. So, adding rpm get/put in i915_gem_shrinker_oom() and i915_gem_shrinker_vmap() to ensure shrinking of bound objects as well.

Quoted 6 lines
Quoted 2 lines

Please do mention when you made changed. I skipped over this series when I only saw the 2 patches because I thought to myself you hadn't added the third patch for the new vmap path.

Will take care of this going forward.

Thanks,
Praveen

Quoted 4 lines

Nevertheless applied, thanks.
-Chris

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Unbind objects in shrinker only if device is runtime active

In reply to Praveen Paneri
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915: Unbind objects in shrinker only if device is runtime active
URL : https://patchwork.freedesktop.org/series/6598/
State : success

== Summary ==

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

Test gem_exec_flush:

        Subgroup basic-uc-pro-default:
                fail       -> PASS       (bsw-nuc-2)
        Subgroup basic-uc-prw-default:
                fail       -> PASS       (bsw-nuc-2)
bdw-nuci7-2      total:209  pass:197  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultra        total:209  pass:184  dwarn:0   dfail:0   fail:0   skip:25 
bsw-nuc-2        total:208  pass:166  dwarn:0   dfail:0   fail:1   skip:41 
byt-nuc          total:208  pass:164  dwarn:0   dfail:0   fail:3   skip:41 
hsw-brixbox      total:209  pass:183  dwarn:0   dfail:0   fail:0   skip:26 
hsw-gt2          total:209  pass:187  dwarn:0   dfail:0   fail:1   skip:21 
ilk-hp8440p      total:209  pass:145  dwarn:0   dfail:0   fail:3   skip:61 
ivb-t430s        total:209  pass:178  dwarn:0   dfail:0   fail:0   skip:31 
skl-i7k-2        total:209  pass:182  dwarn:0   dfail:0   fail:0   skip:27 
skl-nuci5        total:209  pass:198  dwarn:0   dfail:0   fail:0   skip:11 
snb-dellxps      total:209  pass:167  dwarn:0   dfail:0   fail:0   skip:42 
snb-x220t        total:209  pass:167  dwarn:0   dfail:0   fail:1   skip:41 

Results at /archive/results/CI_IGT_test/Patchwork_2122/

5256d5ce241debab2267faf6dc2d5ad9eaca9554 drm-intel-nightly: 2016y-05m-02d-07h-51m-16s UTC integration manifest 480ca2e drm/i915: Add rpm get/put in oom and vmap notifier
3d9875d drm/i915: Unbind objects in shrinker only if device is runtime active

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx