[PATCH 6/6] make_shrinkable
Matthew Auld
matthew.auld at intel.com
Fri Aug 20 17:49:56 UTC 2021
---
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 1 -
drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 17 +++++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
index ea5811f38e0d..b849b65868b7 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
@@ -475,7 +475,6 @@ static void __i915_gem_object_make_shrinkable(struct drm_i915_gem_object *obj,
struct drm_i915_private *i915 = obj_to_i915(obj);
unsigned long flags;
- GEM_BUG_ON(!i915_gem_object_has_pages(obj));
if (!i915_gem_object_is_shrinkable(obj))
return;
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
index 5155090cf697..9206a47eb46e 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c
@@ -201,7 +201,16 @@ static int i915_ttm_tt_shmem_populate(struct ttm_device *bdev,
if (ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)
ttm->page_flags &= ~TTM_PAGE_FLAG_SWAPPED;
-+
+
+ /*
+ * Even if we lack mm.pages for this object(which will be the case when
+ * something is evicted to system memory by TTM), we still want to make
+ * this object visible to the shrinker, since the underlying ttm_tt
+ * still has the real shmem pages. When unpopulating the tt(possibly due
+ * to shrinking) we hide it again from the shrinker.
+ */
+ i915_gem_object_make_shrinkable(obj);
+
i915_tt->cached_st = st;
return 0;
@@ -224,6 +233,8 @@ static void i915_ttm_tt_shmem_unpopulate(struct ttm_tt *ttm)
ttm->page_flags |= TTM_PAGE_FLAG_SWAPPED;
else
shmem_truncate_range(file_inode(i915_tt->filp), 0, (loff_t)-1);
+
+ i915_gem_object_make_unshrinkable(obj);
}
static int i915_ttm_tt_shmem_create(struct ttm_buffer_object *bo,
@@ -425,6 +436,9 @@ static void i915_ttm_adjust_gem_after_move(struct drm_i915_gem_object *obj)
obj->mem_flags |= cpu_maps_iomem(bo->resource) ? I915_BO_FLAG_IOMEM :
I915_BO_FLAG_STRUCT_PAGE;
+ if (bo->ttm && bo->ttm->caching == ttm_cached)
+ obj->mem_flags |= I915_BO_FLAG_SHRINKABLE;
+
cache_level = i915_ttm_cache_level(to_i915(bo->base.dev), bo->resource,
bo->ttm);
i915_gem_object_set_cache_coherency(obj, cache_level);
@@ -1049,7 +1063,6 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem,
drm_gem_private_object_init(&i915->drm, &obj->base, size);
i915_gem_object_init(obj, &i915_gem_ttm_obj_ops, &lock_class, flags);
i915_gem_object_init_memory_region(obj, mem);
- i915_gem_object_make_unshrinkable(obj);
INIT_RADIX_TREE(&obj->ttm.get_io_page.radix, GFP_KERNEL | __GFP_NOWARN);
mutex_init(&obj->ttm.get_io_page.lock);
bo_type = (obj->flags & I915_BO_ALLOC_USER) ? ttm_bo_type_device :
--
2.26.3
More information about the Intel-gfx-trybot
mailing list