From: Boris Brezillon Date: Wed, 1 Apr 2026 13:48:45 +0000 (+0200) Subject: drm/gem: Consider GEM object reclaimable if shrinking fails X-Git-Tag: v7.2-rc1~141^2~26^2~171 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=71c8224a18825102ee1e5e70498f96f6c2d2a81d;p=thirdparty%2Flinux.git drm/gem: Consider GEM object reclaimable if shrinking fails 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 Reviewed-by: Steven Price Link: https://patch.msgid.link/20260401134854.2275433-2-boris.brezillon@collabora.com Signed-off-by: Boris Brezillon --- diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 0377a5fd402d0..3a309aeaaee5f 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -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);