Thread (4 messages) 4 messages, 3 authors, 2025-09-23

Re: [RFC PATCH v0] mm/vmscan: Add readahead LRU to improve readahead file page reclamation efficiency

From: zhongjinji <hidden>
Date: 2025-09-23 08:03:39
Also in: linux-fsdevel, linux-mm, lkml
Subsystem: memory management, memory management - mglru (multi-gen lru), memory management - swap, the rest · Maintainers: Andrew Morton, Chris Li, Kairui Song, Linus Torvalds

1. Problem Background
In Android systems, a significant challenge arises during application 
startup when a large number of private application files are read.
Approximately 90% of these file pages are loaded into memory via readahead.
However, about 85% of these pre-read pages are reclaimed without ever being
accessed, which means only around 15% of the pre-read pages are effectively
utilized. This results in wasted memory, as unaccessed file pages consume
valuable memory space, leading to memory thrashing and unnecessary I/O 
reads.
 
2. Solution Proposal
Introduce a Readahead LRU to track pages brought in via readahead. During
memory reclamation, prioritize scanning this LRU to reclaim pages that
have not been accessed recently. For pages in the Readahead LRU that are
accessed, move them back to the inactive_file LRU to await subsequent
reclamation.
 
3. Benefits Data
In tests involving the cold start of 30 applications:
  Memory Reclamation Efficiency: The slowpath process saw a reduction of
  over 30%.
Did you enable MGLRU? If you did, I guess "do not active page" and a separate
LRU would have the same effect, but I didn't find any benefits.
diff --git a/mm/swap.c b/mm/swap.c
index 3632dd061beb..9e87996abbc9 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -504,7 +504,8 @@ void folio_add_lru(struct folio *folio)

        /* see the comment in lru_gen_folio_seq() */
        if (lru_gen_enabled() && !folio_test_unevictable(folio) &&
-           lru_gen_in_fault() && !(current->flags & PF_MEMALLOC))
+           lru_gen_in_fault() && !(current->flags & PF_MEMALLOC) &&
+               !folio_test_readahead_lru(folio))
                folio_set_active(folio);

        folio_batch_add_and_move(folio, lru_add, false);
4. Current Issues
The refault metric for file pages has significantly degraded, increasing
by about 100%. This is primarily because pages are reclaimed too quickly,
without sufficient aging.
 
5. Next Steps
When calculating reclamation propensity, adjust the intensity of
reclamation from the Readahead LRU. This ensures aging and reclamation
efficiency while allowing adequate aging time.

Signed-off-by: Lei Liu <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help