ttm_backup_backup_folio() unconditionally called folio_mark_accessed()
on the freshly populated shmem folio before copying the BO's data into
it. This path is only reached from a shrinker, i.e. precisely when the
system has already decided it needs memory back, and the whole point
of backing a page up into shmem is to let core mm reclaim it through
the normal swap/writeback path instead of keeping it pinned as TTM
memory.

Marking the folio accessed works against that: it sets the referenced
bit / promotes the folio on the LRU, so a later reclaim scan gives it
a second chance (or skips it) instead of reclaiming it on sight. This
is actively counter-productive even when the writeback backup flag is
set to synchronously flush the folio's content via shmem_write_folio():
writeback only clears the dirty bit, it does not free the page, so an
accessed folio just sits there, clean and resident, protected from the
very reclaim pass it was written back for.

Drop the folio_mark_accessed() call so these folios decay through
normal LRU aging and become immediate reclaim candidates once written
back (or once picked up by the system's own asynchronous laundering),
instead of being artificially kept warm.

Signed-off-by: Thomas Hellström <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_backup.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_backup.c b/drivers/gpu/drm/ttm/ttm_backup.c
index 0c2d53a13b2a..9589067ad8cf 100644
--- a/drivers/gpu/drm/ttm/ttm_backup.c
+++ b/drivers/gpu/drm/ttm/ttm_backup.c
@@ -149,7 +149,6 @@ ttm_backup_backup_folio(struct file *backup, struct folio 
*folio,
                to_nr = min_t(int, nr_pages - i,
                              folio_next_index(to_folio) - (idx + i));
 
-               folio_mark_accessed(to_folio);
                folio_lock(to_folio);
                folio_mark_dirty(to_folio);
 
-- 
2.56.0

Reply via email to