[PATCH] drm/i915: Mark pages mapped into the GTT as unevictable
From: Chris Wilson
Date: Sun Sep 26 2010 - 05:11:53 EST
If the GPU is currently reading and writing to pages, we need to prevent
the VM from swapping those out to disk...
Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
drivers/gpu/drm/i915/i915_gem.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 9f547ab..5fa6227 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1532,6 +1532,23 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
return 0;
}
+static void
+i915_gem_object_lock_pages(struct drm_i915_gem_object *obj, bool lock)
+{
+ struct address_space *mapping;
+ struct inode *inode;
+
+ inode = obj->base.filp->f_path.dentry->d_inode;
+ mapping = inode->i_mapping;
+
+ if (lock) {
+ mapping_set_unevictable(mapping);
+ } else {
+ mapping_clear_unevictable(mapping);
+ scan_mapping_unevictable_pages(mapping);
+ }
+}
+
void
i915_gem_object_put_pages(struct drm_gem_object *obj)
{
@@ -2150,6 +2167,7 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
list_del_init(&obj_priv->list);
+ i915_gem_object_lock_pages(obj_priv, false);
if (i915_gem_object_is_purgeable(obj_priv))
i915_gem_object_truncate(obj);
@@ -2751,6 +2769,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj,
obj_priv->mappable =
obj_priv->gtt_offset + obj->size <= dev_priv->mm.gtt_mappable_end;
+ i915_gem_object_lock_pages(obj_priv, true);
return 0;
}
--
1.7.1
--
Chris Wilson, Intel Open Source Technology Centre
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/