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

From: Baolin Wang

Date: Wed Jul 15 2026 - 05:00:39 EST




On 7/15/26 3:57 PM, Barry Song wrote:
On Wed, Jul 15, 2026 at 3:54 PM Barry Song <baohua@xxxxxxxxxx> wrote:
[...]

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);

Sure. But I don't think it's very relevant to this point. MGLRU doesn't
protect normally accessed mmaped exec file folios well enough. Anyway,
I'll test it on x86.

My point is that even mmaped executable folios that have never been
accessed might still get promoted because they already have the accessed
bit set. :-)

Second thought: we don't do much readahead for VM_EXEC since it is
considered random access. So maybe I am being over-cautious here.
The data will tell us :-)

Yes. Besides, even if an exec folio gets promoted incorrectly at first, it can still be reclaimed as it ages without further accesses. This is the same logic as the classical LRU.

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