Re: [PATCH] mm/mglru: Use folio_mark_accessed to replace folio_set_active in PF
From: Barry Song
Date: Tue Apr 28 2026 - 18:50:50 EST
On Wed, Apr 29, 2026 at 6:26 AM Barry Song <baohua@xxxxxxxxxx> wrote:
[...]
>
> BTW, it seems we can also fix set_pte_range(). The prefault check
> feels quite useless to me—just let folio_referenced do one extra
> scan.
>
> diff --git a/mm/memory.c b/mm/memory.c
> index ea6568571131..bee58a8fee0a 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -5593,13 +5593,12 @@ void set_pte_range(struct vm_fault *vmf,
> struct folio *folio,
> {
> struct vm_area_struct *vma = vmf->vma;
> bool write = vmf->flags & FAULT_FLAG_WRITE;
> - bool prefault = !in_range(vmf->address, addr, nr * PAGE_SIZE);
> pte_t entry;
>
> flush_icache_pages(vma, page, nr);
> entry = mk_pte(page, vma->vm_page_prot);
>
> - if (prefault && arch_wants_old_prefaulted_pte())
> + if (arch_wants_old_prefaulted_pte())
> entry = pte_mkold(entry);
> else
> entry = pte_sw_mkyoung(entry);
>
>
Please ignore this part.
I had a bit of a brain fart there. If it’s not prefault,
it’s a real fault and we are actually accessing it, so it
shouldn’t be considered old.
Thanks
Barry