[Intel-gfx] [PATCH 09/10] drm/i915: Use madvise-style ioctl to mark purgeable pages.
Shaohua Li
shaohua.li at intel.com
Wed Jun 10 04:59:37 CEST 2009
On Sat, Jun 06, 2009 at 04:46:05PM +0800, Chris Wilson wrote:
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_dma.c | 1 +
> drivers/gpu/drm/i915/i915_drv.c | 3 +
> drivers/gpu/drm/i915/i915_drv.h | 10 ++
> drivers/gpu/drm/i915/i915_gem.c | 235 ++++++++++++++++++++++++++++++++++-----
> include/drm/i915_drm.h | 16 +++
> 5 files changed, 236 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 68e882c..7045afb 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1365,6 +1365,7 @@ struct drm_ioctl_desc i915_ioctls[] = {
> DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0),
> DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0),
> DRM_IOCTL_DEF(DRM_I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, 0),
> + DRM_IOCTL_DEF(DRM_I915_GEM_MADVISE, i915_gem_madvise_ioctl, 0),
> };
How bad just shrink the inactive list instead of adding new ioctl and new list?
If an object will be used, it will be soon moved to active list by gem_exec. So
shrinking the inactive list is good enough to me.
> +static int
> +i915_gem_shrink(int nr_to_scan, gfp_t gfp_mask)
> +{
> + struct drm_i915_gem_object *obj_priv, *next;
> + int cnt = 0;
> +
> + if (gfp_mask & GFP_ATOMIC)
__GFP_WAIT?
> + return -1;
> +
> + spin_lock(&shrink_list_lock);
> + list_for_each_entry_safe(obj_priv, next, &shrink_list, list) {
> + if (nr_to_scan > 0) {
> + struct drm_gem_object *obj = obj_priv->obj;
> + struct drm_device *dev = obj->dev;
> +
> + spin_unlock(&shrink_list_lock);
> +
> + if (mutex_trylock(&dev->struct_mutex)) {
> + i915_gem_object_unbind(obj);
> + nr_to_scan -= obj->size / 4096;
> + mutex_unlock(&dev->struct_mutex);
> + }
> +
> + spin_lock(&shrink_list_lock);
> + } else
> + cnt += obj_priv->obj->size / 4096;
> + }
> + spin_unlock(&shrink_list_lock);
> +
> + return (cnt / 100) * sysctl_vfs_cache_pressure;
> +}
Gem object page is in pagecache LRU list, so unbing gem object really shrinks
pagecache. When doing gem shrink, it doesn't count
current->reclaim_state->reclaimed_slab, this seems confuse page relcaim.
Thanks,
Shaohua
More information about the Intel-gfx
mailing list