[Intel-gfx] [PATCH 1/3] drm/i915: During shrink_all we only need to idle the GPU
Chris Wilson
chris at chris-wilson.co.uk
Wed Aug 26 01:52:10 PDT 2015
We can forgo an evict-everything here as the shrinker operation itself
will unbind any vma as required. If we explicitly idle the GPU through a
switch to the default context, we not only create a request in an
illegal context (e.g. whilst shrinking during execbuf with a request
already allocated), but switching to the default context will not free
up the memory backing the active contexts - unless in the unlikely
situation that context had already been closed (and just kept arrive by
being the current context). The saving is near zero and the danger real.
Note that the double flush used here to protect against retire_requests
being a transitive cache of small data structures.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem_shrinker.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index f6ecbda2c604..33e90e8a2e8a 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -158,9 +158,16 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
*/
unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv)
{
- i915_gem_evict_everything(dev_priv->dev);
- return i915_gem_shrink(dev_priv, LONG_MAX,
- I915_SHRINK_BOUND | I915_SHRINK_UNBOUND);
+ unsigned long count;
+
+ count = i915_gem_shrink(dev_priv, LONG_MAX,
+ I915_SHRINK_BOUND | I915_SHRINK_UNBOUND);
+
+ /* Use a double call to retire to flush any staged frees */
+ i915_gem_retire_requests(dev_priv->dev);
+ i915_gem_retire_requests(dev_priv->dev);
+
+ return count;
}
static bool i915_gem_shrinker_lock(struct drm_device *dev, bool *unlock)
--
2.5.0
More information about the Intel-gfx
mailing list