@ -47,6 +47,30 @@ static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task)
# endif
}
/**
* i915_gem_shrink - Shrink buffer object caches
* @ dev_priv : i915 device
* @ target : amount of memory to make available , in pages
* @ flags : control flags for selecting cache types
*
* This function is the main interface to the shrinker . It will try to release
* up to @ target pages of main memory backing storage from buffer objects .
* Selection of the specific caches can be done with @ flags . This is e . g . useful
* when purgeable objects should be removed from caches preferentially .
*
* Note that it ' s not guaranteed that released amount is actually available as
* free system memory - the pages might still be in - used to due to other reasons
* ( like cpu mmaps ) or the mm core has reused them before we could grab them .
* Therefore code that needs to explicitly shrink buffer objects caches ( e . g . to
* avoid deadlocks in memory reclaim ) must fall back to i915_gem_shrink_all ( ) .
*
* Also note that any kind of pinning ( both per - vma address space pins and
* backing storage pins at the buffer object level ) result in the shrinker code
* having to skip the object .
*
* Returns :
* The number of pages of backing storage actually released .
*/
unsigned long
i915_gem_shrink ( struct drm_i915_private * dev_priv ,
long target , unsigned flags )
@ -118,6 +142,20 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
return count ;
}
/**
* i915_gem_shrink - Shrink buffer object caches completely
* @ dev_priv : i915 device
*
* This is a simple wraper around i915_gem_shrink ( ) to aggressively shrink all
* caches completely . It also first waits for and retires all outstanding
* requests to also be able to release backing storage for active objects .
*
* This should only be used in code to intentionally quiescent the gpu or as a
* last - ditch effort when memory seems to have run out .
*
* Returns :
* The number of pages of backing storage actually released .
*/
unsigned long i915_gem_shrink_all ( struct drm_i915_private * dev_priv )
{
i915_gem_evict_everything ( dev_priv - > dev ) ;
@ -279,6 +317,12 @@ i915_gem_shrinker_oom(struct notifier_block *nb, unsigned long event, void *ptr)
return NOTIFY_DONE ;
}
/**
* i915_gem_shrinker_init - Initialize i915 shrinker
* @ dev_priv : i915 device
*
* This function registers and sets up the i915 shrinker and OOM handler .
*/
void i915_gem_shrinker_init ( struct drm_i915_private * dev_priv )
{
dev_priv - > mm . shrinker . scan_objects = i915_gem_shrinker_scan ;