If the object wasn't moved to a different LRU after the shrink callback
is called, it means the buffer is still reclaimable. Update the remaining
counter to reflect that.

Signed-off-by: Boris Brezillon <[email protected]>
---
 drivers/gpu/drm/drm_gem.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index f7cbf6e8d1e0..442853511106 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1671,6 +1671,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);
-- 
2.52.0

Reply via email to