[Intel-gfx] [PATCH] drm/i915: Shrink the inactive bo-cache under memory pressure

Jesse Barnes jbarnes at virtuousgeek.org
Fri Jun 19 03:19:20 CEST 2009


On Fri, 19 Jun 2009 00:14:55 +0100
Chris Wilson <chris at chris-wilson.co.uk> wrote:

> Register a shrinker that evicts inactive objects when under memory
> pressure.  In order to discard unused pages directly we introduce a
> madvise style ioctl for userspace to mark unneeded objects. This ioctl
> also provides a facility by which userspace can query whether a
> buffer was discarded and so may then take remedial action. (This can
> be, for instance, used to implement APPLE_purgeable_object. However,
> in the first instance it is used by libdrm to clear discarded buffers
> from its own bo-cache.)

Nice, we've needed this for awhile.

> @@ -441,10 +450,7 @@ struct drm_i915_gem_object {
>  	 * This is the same as gtt_space->start
>  	 */
>  	uint32_t gtt_offset;
> -	/**
> -	 * Required alignment for the object
> -	 */
> -	uint32_t gtt_alignment;
> +
>  	/**
>  	 * Fake offset for use by mmap(2)
>  	 */
> @@ -457,9 +463,6 @@ struct drm_i915_gem_object {
>  	 */
>  	int fence_reg;
>  
> -	/** Boolean whether this object has a valid gtt offset. */
> -	int gtt_bound;
> -
>  	/** How many users have pinned this object in GTT space */
>  	int pin_count;
>  
> @@ -494,6 +497,11 @@ struct drm_i915_gem_object {
>  	 * in an execbuffer object list.
>  	 */
>  	int in_execbuffer;
> +
> +	/**
> +	 * Advice: are the backing pages purgeable?
> +	 */
> +	int madv;
>  };

Strictly speaking, the removals probably shouldn't be part of this
patch, but look like good cleanups.

> +static LIST_HEAD(shrink_list);
> +static DEFINE_SPINLOCK(shrink_list_lock);

Should these be in the dev_priv instead (so we can keep pretending we
support multiple instances? :)

Is there any way to split this logically?  It's a pretty big patch to
digest all at once...  Nothing jumped out at me in a quick scan
though.

-- 
Jesse Barnes, Intel Open Source Technology Center



More information about the Intel-gfx mailing list