提交 e2377fe0 编写于 作者: H Hugh Dickins 提交者: Linus Torvalds

drm/i915: use shmem_truncate_range

The interface to ->truncate_range is changing very slightly: once "tmpfs:
take control of its truncate_range" has been applied, this can be applied.
 For now there is only a slight inefficiency while this remains unapplied,
but it will soon become essential for managing shmem's use of swap.

Change i915_gem_object_truncate() to use shmem_truncate_range() directly:
which should also spare i915 later change if we switch from
inode_operations->truncate_range to file_operations->fallocate.
Signed-off-by: NHugh Dickins <hughd@google.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Keith Packard <keithp@keithp.com>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 5949eac4
...@@ -1696,13 +1696,10 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj) ...@@ -1696,13 +1696,10 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj)
/* Our goal here is to return as much of the memory as /* Our goal here is to return as much of the memory as
* is possible back to the system as we are called from OOM. * is possible back to the system as we are called from OOM.
* To do this we must instruct the shmfs to drop all of its * To do this we must instruct the shmfs to drop all of its
* backing pages, *now*. Here we mirror the actions taken * backing pages, *now*.
* when by shmem_delete_inode() to release the backing store.
*/ */
inode = obj->base.filp->f_path.dentry->d_inode; inode = obj->base.filp->f_path.dentry->d_inode;
truncate_inode_pages(inode->i_mapping, 0); shmem_truncate_range(inode, 0, (loff_t)-1);
if (inode->i_op->truncate_range)
inode->i_op->truncate_range(inode, 0, (loff_t)-1);
obj->madv = __I915_MADV_PURGED; obj->madv = __I915_MADV_PURGED;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册