Re: [PATCH] mm/memory: reuse the whole exclusive large folio on a write fault
From: Yuan-Hao Hsu
Date: Fri Sep 18 2026 - 14:40:27 EST
On Fri, 18 Sep 2026 14:14:11 +0200, David Hildenbrand (Arm) wrote:
> There were previous discussions on this, in particular around how much
> we should actually try operating around the target PTE.
Yes, Barry's RFC from 2024 and your replies to it, where you were fine
with contpte granularity and not convinced about anything bigger. That
is why the description has the numbers for both: capped to 16 PTEs, the
1M and 2M cases take 5.4 ms instead of 3.9 ms, and the only pattern where
the cap wins is one store per 2M. If you would rather start with the
contpte-sized version, that is a two-line change and I can send that
version instead.
> How did you use the LLM for coming up with this patch + description?
I did the initial investigation and made the design decisions myself.
Once I had a clear idea of the approach and the overall structure, I used
an LLM to help with parts of the implementation and the test
programs. I also used it to help with drafting the commit message.
Before sending the patch, I went through it line by line and checked the
test results and measurements to make sure they matched what the code was
actually doing and that there were no obvious issues.
Lorenzo, for your bot's question: the reuse decision in
wp_can_reuse_anon_folio() is per folio. The patch applies it to the other
PTEs of the folio within the same VMA and page table using the mprotect
helpers (can_change_pte_writable() and modify_prot_*_ptes()), so
soft-dirty, uffd-wp and NUMA hinting PTEs are handled the way mprotect()
handles them, and the PTE that faulted is finished by wp_page_reuse() as
before.
The part I spent most of the time on was the measurements, including the
cases where it does not help.
Yuan-Hao Hsu