[Intel-gfx] [PATCH 1/5] drm/i915: Release the mmap offset when purging a buffer

Chris Wilson chris at chris-wilson.co.uk
Fri Feb 24 22:13:38 CET 2012

If we discard a buffer due to memory pressure, also release its alloted
mmap address space. As it may be sometime before userspace wakes up
and notices that it has buffers to purge from its cache, we may waste
valuable address space on unusable objects for a period of time.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
 drivers/gpu/drm/i915/i915_gem.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 19a06c2..4733704 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1543,6 +1543,9 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj)
 	inode = obj->base.filp->f_path.dentry->d_inode;
 	shmem_truncate_range(inode, 0, (loff_t)-1);
+	if (obj->base.map_list.map)
+		drm_gem_free_mmap_offset(&obj->base);
 	obj->madv = __I915_MADV_PURGED;

More information about the Intel-gfx mailing list