Commit 99c4f073 authored by Yu Zhao's avatar Yu Zhao Committed by Kalesh Singh
Browse files

BACKPORT: mm: multi-gen LRU: retry pages written back while isolated

The page reclaim isolates a batch of pages from the tail of one of the
LRU lists and works on those pages one by one.  For a suitable
swap-backed page, if the swap device is async, it queues that page for
writeback.  After the page reclaim finishes an entire batch, it puts back
the pages it queued for writeback to the head of the original LRU list.

In the meantime, the page writeback flushes the queued pages also by
batches.  Its batching logic is independent from that of the page reclaim.
For each of the pages it writes back, the page writeback calls
rotate_reclaimable_page() which tries to rotate a page to the tail.

rotate_reclaimable_page() only works for a page after the page reclaim
has put it back.  If an async swap device is fast enough, the page
writeback can finish with that page while the page reclaim is still
working on the rest of the batch containing it.  In this case, that page
will remain at the head and the page reclaim will not retry it before
reaching there.

This patch adds a retry to evict_pages().  After evict_pages() has
finished an entire batch and before it puts back pages it cannot free
immediately, it retries those that may have missed the rotation.

Before this patch, ~60% of pages swapped to an Intel Optane missed
rotate_reclaimable_page().  After this patch, ~99% of missed pages were
reclaimed upon retry.

This problem affects relatively slow async swap devices like Samsung 980
Pro much less and does not affect sync swap devices like zram or zswap at
all.

Link: https://lkml.kernel.org/r/20221116013808.3995280-1-yuzhao@google.com


Fixes: ac35a490 ("mm: multi-gen LRU: minimal implementation")
Signed-off-by: default avatarYu Zhao <yuzhao@google.com>
Cc: "Yin, Fengwei" <fengwei.yin@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Bug: 274865848
(cherry picked from commit 359a5e14)
[Yu: Resolve conflicts over absence of folios on 5.15]
Change-Id: Ife11b13e2612c84a2de1727781983f66a06141bb
Signed-off-by: default avatarT.J. Mercier <tjmercier@google.com>
Bug: 285020779
[ Kalesh Singh - Fix conflicts in mm/vmscan.c ]
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
parent 45b8bb88
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment