[Intel-gfx] [PATCH] intel: Mark cached bo as purgeable

Shaohua Li shaohua.li at intel.com
Fri Jun 19 03:50:54 CEST 2009


On Fri, Jun 19, 2009 at 07:16:45AM +0800, Chris Wilson wrote:
> Wrap the new DRM_I915_GEM_MADVISE ioctl that controls the purgeablity of
> the backing pages, i.e. we can use the ioctl to reclaim memory under swap
> pressure.
> ---
>  libdrm/intel/intel_bufmgr_gem.c |   55 +++++++++++++++++++++++++++++++++++++++
>  shared-core/i915_drm.h          |   16 +++++++++++
>  2 files changed, 71 insertions(+), 0 deletions(-)
> 
>  
> @@ -586,6 +635,8 @@ drm_intel_gem_bo_unreference_locked(drm_intel_bo *bo)
>  	      bucket->num_entries < bucket->max_entries)) &&
>  	    drm_intel_gem_bo_set_tiling(bo, &tiling_mode, 0) == 0)
>  	{
> +	    struct drm_i915_gem_madvise madv;
> +
>  	    bo_gem->name = NULL;
>  	    bo_gem->validate_index = -1;
>  	    bo_gem->relocs = NULL;
> @@ -594,6 +645,10 @@ drm_intel_gem_bo_unreference_locked(drm_intel_bo *bo)
>  
>  	    DRMLISTADDTAIL(&bo_gem->head, &bucket->head);
>  	    bucket->num_entries++;
> +
> +	    madv.handle = bo_gem->gem_handle;
> +	    madv.madv = I915_MADV_DONTNEED;
> +	    ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_MADVISE, &madv);
we need to unmap the object like my reference patch. Truncate page will
unmap the object. And if libdrm thinks the object->virtual is still valid,
then things will get wrong.

Thanks,
Shaohua



More information about the Intel-gfx mailing list