diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-08-07 06:01:30 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-08-09 14:24:34 -0400 |
commit | ae9fed6b601821d70928797c56da0e2008ef840d (patch) | |
tree | 36342293eab3bb747e52a5d1ac4157b963400afb /drivers | |
parent | 20a0945951705246278f43641bb13611c030e112 (diff) |
drm/i915: Truncate the shmem backing pages on purge
shmfs doesn't actually implement i_ops->truncate() so we were not
immedatiately releasing the backing pages when shrinking the gfx cache
under OOM. Instead use a combination of truncate_inode_pages() and
i_ops->truncate_range() as is used by shmem_delete_inode().
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 8f3e0c10c080..41306217bd7a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -1505,9 +1505,16 @@ i915_gem_object_truncate(struct drm_gem_object *obj) | |||
1505 | struct drm_i915_gem_object *obj_priv = to_intel_bo(obj); | 1505 | struct drm_i915_gem_object *obj_priv = to_intel_bo(obj); |
1506 | struct inode *inode; | 1506 | struct inode *inode; |
1507 | 1507 | ||
1508 | /* Our goal here is to return as much of the memory as | ||
1509 | * is possible back to the system as we are called from OOM. | ||
1510 | * To do this we must instruct the shmfs to drop all of its | ||
1511 | * backing pages, *now*. Here we mirror the actions taken | ||
1512 | * when by shmem_delete_inode() to release the backing store. | ||
1513 | */ | ||
1508 | inode = obj->filp->f_path.dentry->d_inode; | 1514 | inode = obj->filp->f_path.dentry->d_inode; |
1509 | if (inode->i_op->truncate) | 1515 | truncate_inode_pages(inode->i_mapping, 0); |
1510 | inode->i_op->truncate (inode); | 1516 | if (inode->i_op->truncate_range) |
1517 | inode->i_op->truncate_range(inode, 0, (loff_t)-1); | ||
1511 | 1518 | ||
1512 | obj_priv->madv = __I915_MADV_PURGED; | 1519 | obj_priv->madv = __I915_MADV_PURGED; |
1513 | } | 1520 | } |