Re: [PATCH] drm/i915: Do not invalidate obj->pages under mempressure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 14, 2015 at 08:34:31PM +0000, Chris Wilson wrote:
> This (partially) reverts
>
> commit 5537252b6b6d71fb1a8ed7395a8e5babf91953fd
> Author: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Date:   Tue Mar 25 13:23:06 2014 +0000
>
>     drm/i915: Invalidate our pages under memory pressure
>
> It appears given the right workload, that pages which are swapped out
> more than once are incorrectly invalidated and discarded. I had presumed
> that the swapin would mark the pages dirty again and so preserve them
> against the next cycle of invalidation - that appears to be false, and
> leads to memory corruption (even leak of stale pages to userspace).
>
> Reported-by: Sean V Kelley <sean.v.kelley@xxxxxxxxx>
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Sean V Kelley <sean.v.kelley@xxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx

Hm, scary. Do we have a testcase for this (might need a correctness
version for some of the swap thrashing tests maybe).
-Daniel

> ---
>  drivers/gpu/drm/i915/i915_gem.c | 23 ++---------------------
>  1 file changed, 2 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 4d453490596e..b06f051a73de 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1947,26 +1947,6 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj)
>   obj->madv = __I915_MADV_PURGED;
>  }
>
> -/* Try to discard unwanted pages */
> -static void
> -i915_gem_object_invalidate(struct drm_i915_gem_object *obj)
> -{
> - struct address_space *mapping;
> -
> - switch (obj->madv) {
> - case I915_MADV_DONTNEED:
> - i915_gem_object_truncate(obj);
> - case __I915_MADV_PURGED:
> - return;
> - }
> -
> - if (obj->base.filp == NULL)
> - return;
> -
> - mapping = file_inode(obj->base.filp)->i_mapping,
> - invalidate_mapping_pages(mapping, 0, (loff_t)-1);
> -}
> -
>  static void
>  i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj)
>  {
> @@ -2029,7 +2009,8 @@ i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
>   ops->put_pages(obj);
>   obj->pages = NULL;
>
> - i915_gem_object_invalidate(obj);
> + if (i915_gem_object_is_purgeable(obj))
> + i915_gem_object_truncate(obj);
>
>   return 0;
>  }
> --
> 2.1.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux