]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/gem: Consider GEM object reclaimable if shrinking fails
authorBoris Brezillon <boris.brezillon@collabora.com>
Wed, 1 Apr 2026 13:48:45 +0000 (15:48 +0200)
committerBoris Brezillon <boris.brezillon@collabora.com>
Fri, 3 Apr 2026 11:23:27 +0000 (13:23 +0200)
If the object wasn't moved to a different LRU after the shrink callback
returns, it means the buffer is still reclaimable. Update the remaining
counter to reflect that.

v2:
- Collect R-b

v3:
- Collect R-b

v4:
- No changes

v5:
- No changes

v6:
- No changes

v7:
- No changes

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Link: https://patch.msgid.link/20260401134854.2275433-2-boris.brezillon@collabora.com
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
drivers/gpu/drm/drm_gem.c

index 0377a5fd402d07faccca3408a57eac52fd2c45d8..3a309aeaaee5ffa487296a2e3d6083d8e4dc8973 100644 (file)
@@ -1700,6 +1700,16 @@ drm_gem_lru_scan(struct drm_gem_lru *lru,
                         */
                        WARN_ON(obj->lru == &still_in_lru);
                        WARN_ON(obj->lru == lru);
+               } else if (obj->lru == &still_in_lru) {
+                       /*
+                        * If the object wasn't moved and wasn't shrunk either,
+                        * it's still remaining as reclaimable. Note that
+                        * obj->lru is supposed to be checked with the LRU lock
+                        * held for an accurate result, but we don't care about
+                        * accuracy here. Worst thing that could happen is an
+                        * extra scan.
+                        */
+                       *remaining += obj->size >> PAGE_SHIFT;
                }
 
                dma_resv_unlock(obj->resv);