drm/i915: Extract i915_gem_shrinker.c
Subsystems (3)
PATCH 1/2 drm/i915: Extract i915_gem_shrinker.c
Two code changes:
- Extract i915_gem_shrinker_init.
- Inline i915_gem_object_is_purgeable since we open-code it everywhere else too.
This already has the benefit of pulling all the shrinker code together, next patch adds a bit of kerneldoc.
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.h | 17 +- drivers/gpu/drm/i915/i915_gem.c | 274 +---------------------------- drivers/gpu/drm/i915/i915_gem_shrinker.c | 291 +++++++++++++++++++++++++++++++ 4 files changed, 306 insertions(+), 277 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_shrinker.c
drivers/gpu/drm/i915/Makefile +1 -0
@@ -28,6 +28,7 @@ i915-y += i915_cmd_parser.o \ i915_gem_execbuffer.o \ i915_gem_gtt.o \ i915_gem.o \ + i915_gem_shrinker.o \ i915_gem_stolen.o \ i915_gem_tiling.o \ i915_gem_userptr.o \
drivers/gpu/drm/i915/i915_drv.h +11 -6
@@ -2601,12 +2601,6 @@ int i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,int i915_gem_wait_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv);void i915_gem_load (struct drm_device *dev); -unsigned long i915_gem_shrink (struct drm_i915_private *dev_priv, -long target, -unsigned flags); -#define I915_SHRINK_PURGEABLE 0x1 -#define I915_SHRINK_UNBOUND 0x2 -#define I915_SHRINK_BOUND 0x4void *i915_gem_object_alloc (struct drm_device *dev);void i915_gem_object_free (struct drm_i915_gem_object *obj); void i915_gem_object_init(struct drm_i915_gem_object *obj,
@@ -2954,6 +2948,17 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,u32 gtt_offset, u32 size); +/* i915_gem_shrinker.c */ +unsigned long i915_gem_shrink (struct drm_i915_private *dev_priv, +long target, +unsigned flags); +#define I915_SHRINK_PURGEABLE 0x1 +#define I915_SHRINK_UNBOUND 0x2 +#define I915_SHRINK_BOUND 0x4 +unsigned long i915_gem_shrink_all (struct drm_i915_private *dev_priv); +void i915_gem_shrinker_init (struct drm_i915_private *dev_priv); + +/* i915_gem_tiling.c */ static inline bool i915_gem_object_needs_bit17_swizzle (struct drm_i915_gem_object *obj) {
drivers/gpu/drm/i915/i915_gem.c +3 -271
326 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_shrinker.c new file +291 -0
291 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915: kerneldoc for i915_gem_shrinker.c
And remove one bogus * from i915_gem_gtt.c since that's not a kerneldoc there.
--- Documentation/DocBook/drm.tmpl | 13 +++++++++++- drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 34 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-)
Documentation/DocBook/drm.tmpl +12 -1
@@ -4184,7 +4184,7 @@ int num_ioctls;</synopsis> <sect2> <title>Buffer Object Eviction</title> <para> - This section documents the interface function for evicting buffer + This section documents the interface functions for evicting buffer objects to make space available in the virtual gpu address spaces. Note that this is mostly orthogonal to shrinking buffer objects caches, which has the goal to make main memory (shared with the gpu
@@ -4192,6 +4192,17 @@ int num_ioctls;</synopsis> </para> !Idrivers/gpu/drm/i915/i915_gem_evict.c </sect2> + <sect2> + <title>Buffer Object Memory Shrinking</title> + <para> + This section documents the interface function for shrinking memory + usage of buffer object caches. Shrinking is used to make main memory + available. Note that this is mostly orthogonal to evicting buffer + objects, which has the goal to make space in gpu virtual address + spaces. + </para> +!Idrivers/gpu/drm/i915/i915_gem_shrinker.c + </sect2> </sect1> <sect1>
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -698,7 +698,7 @@ static int gen8_ppgtt_setup_page_tables(struct i915_hw_ppgtt *ppgtt,return 0 ; } -/** +/* * GEN8 legacy ppgtt programming is accomplished through a max 4 PDP registers * with a net effect resembling a 2-level page table in normal x86 terms. Each * PDP represents 1GB of memory 4 * 512 * 512 * 4096 = 4GB legacy 32b address
drivers/gpu/drm/i915/i915_gem_shrinker.c +34 -0
@@ -47,6 +47,20 @@ 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: memory space 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. +* +* 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 +132,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 +307,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;
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: kerneldoc for i915_gem_shrinker.c
Quoted 4 lines · Daniel Vetter
+/**
+ *i915_gem_shrink- Shrink buffer object caches
+ * @dev_priv: i915 device
+ * @target: memory space to make available, in pages
Not memory space, too similar to VM address space. @target: Amount of memory to make available, in pages
Quoted 4 lines
+ * @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 memory backing storage from buffer objects.
Mention unpinned? Certainly we should try to explain part of the interaction between pin_pages and pin here. (Though nowadays we have clarified that slightly by pin explicitly doing a pin_pages.) We should also mention that not everything we release here will generate freed pages. (Hmm, though maybe we could change how we count to ensure target free pages are generated? It still wouldn't help get_pages_gtt as there is no guarantee that the pages we free will be given back to us...) -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: kerneldoc for i915_gem_shrinker.c
In reply to Daniel VetterAnd 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.
--- Documentation/DocBook/drm.tmpl | 13 +++++++++- drivers/gpu/drm/i915/i915_gem_evict.c | 4 +++ drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- drivers/gpu/drm/i915/i915_gem_shrinker.c | 44 ++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-)
Documentation/DocBook/drm.tmpl +12 -1
@@ -4184,7 +4184,7 @@ int num_ioctls;</synopsis> <sect2> <title>Buffer Object Eviction</title> <para> - This section documents the interface function for evicting buffer + This section documents the interface functions for evicting buffer objects to make space available in the virtual gpu address spaces. Note that this is mostly orthogonal to shrinking buffer objects caches, which has the goal to make main memory (shared with the gpu
@@ -4192,6 +4192,17 @@ int num_ioctls;</synopsis> </para> !Idrivers/gpu/drm/i915/i915_gem_evict.c </sect2> + <sect2> + <title>Buffer Object Memory Shrinking</title> + <para> + This section documents the interface function for shrinking memory + usage of buffer object caches. Shrinking is used to make main memory + available. Note that this is mostly orthogonal to evicting buffer + objects, which has the goal to make space in gpu virtual address + spaces. + </para> +!Idrivers/gpu/drm/i915/i915_gem_shrinker.c + </sect2> </sect1> <sect1>
drivers/gpu/drm/i915/i915_gem_evict.c +4 -0
@@ -63,6 +63,10 @@ mark_free(struct i915_vma *vma, struct list_head *unwind)* * This function is used by the object/vma binding code. * +* Since this function is only used to free up virtual address space it only +* ignores pinned vmas, and not object where the backing storage itself is +* pinned. Hence obj->pages_pin_count does not protect against eviction. +* * To clarify: This is for freeing up virtual address space, not for freeing * memory in e.g. the shrinker. */
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -698,7 +698,7 @@ static int gen8_ppgtt_setup_page_tables(struct i915_hw_ppgtt *ppgtt,return 0 ; } -/** +/* * GEN8 legacy ppgtt programming is accomplished through a max 4 PDP registers * with a net effect resembling a 2-level page table in normal x86 terms. Each * PDP represents 1GB of memory 4 * 512 * 512 * 4096 = 4GB legacy 32b address
drivers/gpu/drm/i915/i915_gem_shrinker.c +44 -0
62 lines not on this page · raw message
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm/i915: kerneldoc for i915_gem_shrinker.c
Task id: 5995 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
PNV -1 272/272 271/272
ILK 301/301 301/301 SNB 303/303 303/303 IVB 342/342 342/342 BYT 287/287 287/287 HSW 362/362 362/362 BDW 308/308 308/308
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*PNV igt_gem_userptr_blits_coherency-unsync PASS(1) CRASH(1)PASS(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Daniel Vetter
Two code changes:
- Extracti915_gem_shrinker_init.
- Inlinei915_gem_object_is_purgeablesince we open-code it everywhere else too.This already has the benefit of pulling all the shrinker code together, next patch adds a bit of kerneldoc.
Signed-off-by Daniel Vetter <[email protected]>
Worth it just for i915_gem_shrinker_init().
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx