Re: [PATCH] mm/rmap: flush the TLB once per mapping in page_vma_mkclean_one()
From: Qiliang Yuan
Date: Mon Nov 23 2026 - 07:05:33 EST
On Mon, Nov 23, 2026 at 11:53:50AM +0000, Lorenzo Stoakes wrote:
> You are flooding the kernel with patches, 6 series across 4
> subsystems over 19 hrs:
[...]
> Given the volume both recently and in the past I assume you are using an LLM to
> do this, so could you confirm your understanding of the problem (as well as
> those of patches sent to other subsystems) and what real-world task you were
> doing to identify this issue?
Yes, I use an AI assistant. What it changed for me is mostly breadth: I
used to work in depth on one area of the kernel, and with the assistant
I can bring the same kind of algorithmic work to other paths and measure
it there. The patches stay small, a few to a few dozen lines each. I
test every change myself, with before/after measurements and the
relevant selftests, and debug kernels where it touches locking or
memory ordering, and I review the code line by line before sending it.
I don't send anything I don't understand, and I can explain every one
of them.
For this one, I was looking at how AI training jobs save checkpoints.
Writing a checkpoint through a shared mapping was 3-4x slower than
write(), and perf showed the writer spending about half of its time in
IPIs. Counting the callers of flush_tlb_mm_range() showed writeback's
folio_mkclean() flushing once per PTE in page_vma_mkclean_one(), so a
large folio mapped by PTEs costs one flush per page. The patch
write-protects the PTEs the way change_protection() does and flushes
the range once, before folio_mkclean() returns: stores through a stale
TLB entry land before writeback reads the folio, and later stores fault
and redirty it. Besides the timings in the changelog, I checked this
with writers storing through the mapping while another thread loops
fsync(), then compared the file with memory, on xfs and ext4 with 1 to
16 writers and on a KASAN/lockdep/DEBUG_VM kernel: no mismatch and no
warning.
I'd like to understand the concern better: is it the review load from
the number of postings, or something in these patches you think I may
have missed? If it is the former, I can space them out.
Thanks,
Qiliang