aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2015-03-18 09:47:59 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-03-20 06:48:16 -0400
commiteb0b44adc08c0be01a027eb009e9cdadc31e65a2 (patch)
treecbc1c91f7793bb266eb99c13a2b432687d4f28ad
parentbe6a03769504753696033b7595d4dcbc4a16d088 (diff)
drm/i915: kerneldoc for i915_gem_shrinker.c
And remove one bogus * from i915_gem_gtt.c since that's not a kerneldoc there. v2: Review from Chris: - Clarify memory space to better distinguish from address space. - Add note that shrink doesn't guarantee the freed memory and that users must fall back to shrink_all. - Explain how pinning ties in with eviction/shrinker. Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--Documentation/DocBook/drm.tmpl13
-rw-r--r--drivers/gpu/drm/i915/i915_gem_evict.c4
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_shrinker.c44
4 files changed, 61 insertions, 2 deletions
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 7a45775518f6..f4976cd7b32b 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -4184,7 +4184,7 @@ int num_ioctls;</synopsis>
4184 <sect2> 4184 <sect2>
4185 <title>Buffer Object Eviction</title> 4185 <title>Buffer Object Eviction</title>
4186 <para> 4186 <para>
4187 This section documents the interface function for evicting buffer 4187 This section documents the interface functions for evicting buffer
4188 objects to make space available in the virtual gpu address spaces. 4188 objects to make space available in the virtual gpu address spaces.
4189 Note that this is mostly orthogonal to shrinking buffer objects 4189 Note that this is mostly orthogonal to shrinking buffer objects
4190 caches, which has the goal to make main memory (shared with the gpu 4190 caches, which has the goal to make main memory (shared with the gpu
@@ -4192,6 +4192,17 @@ int num_ioctls;</synopsis>
4192 </para> 4192 </para>
4193!Idrivers/gpu/drm/i915/i915_gem_evict.c 4193!Idrivers/gpu/drm/i915/i915_gem_evict.c
4194 </sect2> 4194 </sect2>
4195 <sect2>
4196 <title>Buffer Object Memory Shrinking</title>
4197 <para>
4198 This section documents the interface function for shrinking memory
4199 usage of buffer object caches. Shrinking is used to make main memory
4200 available. Note that this is mostly orthogonal to evicting buffer
4201 objects, which has the goal to make space in gpu virtual address
4202 spaces.
4203 </para>
4204!Idrivers/gpu/drm/i915/i915_gem_shrinker.c
4205 </sect2>
4195 </sect1> 4206 </sect1>
4196 4207
4197 <sect1> 4208 <sect1>
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index e3a49d94da3a..d09e35ed9c9a 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -63,6 +63,10 @@ mark_free(struct i915_vma *vma, struct list_head *unwind)
63 * 63 *
64 * This function is used by the object/vma binding code. 64 * This function is used by the object/vma binding code.
65 * 65 *
66 * Since this function is only used to free up virtual address space it only
67 * ignores pinned vmas, and not object where the backing storage itself is
68 * pinned. Hence obj->pages_pin_count does not protect against eviction.
69 *
66 * To clarify: This is for freeing up virtual address space, not for freeing 70 * To clarify: This is for freeing up virtual address space, not for freeing
67 * memory in e.g. the shrinker. 71 * memory in e.g. the shrinker.
68 */ 72 */
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index cbf013fd6b98..d8ff1a8e9d43 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -698,7 +698,7 @@ static int gen8_ppgtt_setup_page_tables(struct i915_hw_ppgtt *ppgtt,
698 return 0; 698 return 0;
699} 699}
700 700
701/** 701/*
702 * GEN8 legacy ppgtt programming is accomplished through a max 4 PDP registers 702 * GEN8 legacy ppgtt programming is accomplished through a max 4 PDP registers
703 * with a net effect resembling a 2-level page table in normal x86 terms. Each 703 * with a net effect resembling a 2-level page table in normal x86 terms. Each
704 * PDP represents 1GB of memory 4 * 512 * 512 * 4096 = 4GB legacy 32b address 704 * PDP represents 1GB of memory 4 * 512 * 512 * 4096 = 4GB legacy 32b address
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index 9ac78b3d6899..f7929e769250 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -47,6 +47,30 @@ static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task)
47#endif 47#endif
48} 48}
49 49
50/**
51 * i915_gem_shrink - Shrink buffer object caches
52 * @dev_priv: i915 device
53 * @target: amount of memory to make available, in pages
54 * @flags: control flags for selecting cache types
55 *
56 * This function is the main interface to the shrinker. It will try to release
57 * up to @target pages of main memory backing storage from buffer objects.
58 * Selection of the specific caches can be done with @flags. This is e.g. useful
59 * when purgeable objects should be removed from caches preferentially.
60 *
61 * Note that it's not guaranteed that released amount is actually available as
62 * free system memory - the pages might still be in-used to due to other reasons
63 * (like cpu mmaps) or the mm core has reused them before we could grab them.
64 * Therefore code that needs to explicitly shrink buffer objects caches (e.g. to
65 * avoid deadlocks in memory reclaim) must fall back to i915_gem_shrink_all().
66 *
67 * Also note that any kind of pinning (both per-vma address space pins and
68 * backing storage pins at the buffer object level) result in the shrinker code
69 * having to skip the object.
70 *
71 * Returns:
72 * The number of pages of backing storage actually released.
73 */
50unsigned long 74unsigned long
51i915_gem_shrink(struct drm_i915_private *dev_priv, 75i915_gem_shrink(struct drm_i915_private *dev_priv,
52 long target, unsigned flags) 76 long target, unsigned flags)
@@ -118,6 +142,20 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
118 return count; 142 return count;
119} 143}
120 144
145/**
146 * i915_gem_shrink - Shrink buffer object caches completely
147 * @dev_priv: i915 device
148 *
149 * This is a simple wraper around i915_gem_shrink() to aggressively shrink all
150 * caches completely. It also first waits for and retires all outstanding
151 * requests to also be able to release backing storage for active objects.
152 *
153 * This should only be used in code to intentionally quiescent the gpu or as a
154 * last-ditch effort when memory seems to have run out.
155 *
156 * Returns:
157 * The number of pages of backing storage actually released.
158 */
121unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv) 159unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv)
122{ 160{
123 i915_gem_evict_everything(dev_priv->dev); 161 i915_gem_evict_everything(dev_priv->dev);
@@ -279,6 +317,12 @@ i915_gem_shrinker_oom(struct notifier_block *nb, unsigned long event, void *ptr)
279 return NOTIFY_DONE; 317 return NOTIFY_DONE;
280} 318}
281 319
320/**
321 * i915_gem_shrinker_init - Initialize i915 shrinker
322 * @dev_priv: i915 device
323 *
324 * This function registers and sets up the i915 shrinker and OOM handler.
325 */
282void i915_gem_shrinker_init(struct drm_i915_private *dev_priv) 326void i915_gem_shrinker_init(struct drm_i915_private *dev_priv)
283{ 327{
284 dev_priv->mm.shrinker.scan_objects = i915_gem_shrinker_scan; 328 dev_priv->mm.shrinker.scan_objects = i915_gem_shrinker_scan;