Re: [PATCH] mm: mglru: promote mapped executable folios after first usage

From: Barry Song

Date: Wed Jul 15 2026 - 02:53:02 EST


On Wed, Jul 15, 2026 at 2:33 PM Baolin Wang
<baolin.wang@xxxxxxxxxxxxxxxxx> wrote:
>
> Classical LRU protects mapped executable file folios through commit
> 8cab4754d24a0 ("vmscan: make mapped executable pages the first class
> citizen") and commit c909e99364c8 ("vmscan: activate executable pages
> after first usage"), giving executable code a better chance to stay in
> memory, avoiding IO thrashing and improving workload performance.
>
> However, MGLRU's protection of mapped executable file folios is less
> reliable. Although shrink_folio_list() checks references, the access flag
> of mapped executable file folios may have already been checked and
> cleared by lru_gen_look_around() or walk_mm(). Additionally,
> folio_update_gen() only sets the 'PG_referenced' flag for mapped executable
> file folios, which causes shrink_folio_list() to ignore the first usage
> of these mapped executable file folios and reclaim them.
>
> Follow the classical LRU's logic, promoting mapped executable file folios
> after their first usage in folio_update_gen(), giving executable code a
> better chance to stay in memory.
>
> On my 32-core Arm machine, with the memcg limit set to 2G, running
> 'make -j32' to build kernel showed some improvement in sys time.

Hi Baolin,

Because ARM doesn't set the surrounding PTEs to young, while x86
may behave differently and mark the surrounding PTEs as young as
well. Could we also collect the data on x86?

void set_pte_range(struct vm_fault *vmf, struct folio *folio,
struct page *page, unsigned int nr, unsigned long addr)
{
...

if (prefault && arch_wants_old_prefaulted_pte())
entry = pte_mkold(entry);
else
entry = pte_sw_mkyoung(entry);

>
> base patched
> 9248.543s 7861.579s
>
> Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>

Thanks
Barry