Re: [PATCH] mm: mglru: promote mapped executable folios after first usage
From: Baolin Wang
Date: Thu Jul 16 2026 - 00:06:46 EST
On 7/16/26 3:44 AM, Andrew Morton wrote:
On Wed, 15 Jul 2026 17:00:19 +0800 Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> wrote:
I did a quick test with the same test case on my x86 machine, and I
still see an improvement in sys time.
base patched
1152.249s 993.235s
Nice. Sashiko asked a thing:
https://sashiko.dev/#/patchset/4b921ed528c483e13c9e22d1ae44ba58b4a15b0b.1784096432.git.baolin.wang@xxxxxxxxxxxxxxxxx
Thanks.
Forward Sashiko's comments:
"
This is a pre-existing issue, but does this miss promoting mapped
executable file folios during direct reclaim?
......
This means current->reclaim_state->mm_walk is NULL. When shrink_folio_list() calls folio_referenced(), it invokes lru_gen_look_around() which calls walk_update_folio() with a NULL walk. Since walk is NULL, we fall back to lru_gen_set_refs() here, which bypasses the newly patched folio_update_gen():
mm/vmscan.c:lru_gen_set_refs() {
if (!folio_test_referenced(folio) && !folio_test_workingset(folio)) {
set_mask_bits(&folio->flags.f, LRU_REFS_MASK, BIT(PG_referenced));
return false;
}
...
}
Because lru_gen_set_refs() lacks the new VMA_EXEC_BIT promotion logic, it merely sets PG_referenced without updating the folio's generation. When those adjacent folios are subsequently isolated by shrink_folio_list(), their PTE young bits have already been cleared, causing folio_check_references() to return FOLIOREF_RECLAIM and evict them. Will we need a similar fix for lru_gen_set_refs() to handle direct reclaim paths?
"
During aging, MGLRU always sets up a valid mm_walk to walk the page table access flags in try_to_inc_max_seq().
When aging is not needed, it is indeed possible to fall into lru_gen_set_refs() and miss promoting mapped exec folios after first usage. Although I think the impact is limited, because after the current patch, accessed mapped exec folios rarely get a chance to enter the eviction path. Anyway, I'll add promotion logic for lru_gen_set_refs().