@@ -282,6 +282,9 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
if (dev->driver->gem_close_object)
dev->driver->gem_close_object(obj, filp);
+
+ atomic_long_sub(obj->size >> PAGE_SHIFT, &filp->filp->f_oom_badness);
+
drm_gem_object_handle_unreference_unlocked(obj);
return 0;
@@ -358,6 +361,9 @@ drm_gem_handle_create_tail(struct drm_file *file_priv,
}
}
+ atomic_long_add(obj->size >> PAGE_SHIFT,
+ &file_priv->filp->f_oom_badness);
+
return 0;
}
@@ -717,6 +723,9 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
if (dev->driver->gem_close_object)
dev->driver->gem_close_object(obj, file_priv);
+ atomic_long_sub(obj->size >> PAGE_SHIFT,
+ &file_priv->filp->f_oom_badness);
+
drm_gem_object_handle_unreference_unlocked(obj);
return 0;