diff options
| author | Kiryl Shutsemau (Meta) <kas@kernel.org> | 2026-09-28 11:06:24 +0100 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-08 23:06:30 -0700 |
| commit | 71834eb407da405f44f98622f0bc7c718068900a (patch) | |
| tree | e46dc6f67be79ff76ba750af1d226eb915d119e0 /scripts/checkstack.pl | |
| parent | 527313a2384e80a49fdf3c1b87470df9f4331d26 (diff) | |
| download | linux-next-71834eb407da405f44f98622f0bc7c718068900a.tar.gz linux-next-71834eb407da405f44f98622f0bc7c718068900a.zip | |
mm/collapse: open-code collapse_single_pmd() in its two callers
A scan and a collapse want different things from mmap_lock. The scan
reads one PTE table under the lock the caller holds, refuses most of the
time, and the caller moves on to the next table without letting go. The
collapse allocates, may sleep in writeback and takes the lock for write
itself, so the lock it is handed is of no use to it.
collapse_single_pmd() kept that boundary inside itself. It dropped the
lock on some paths and not others, and reported which by way of a bool
its callers had to carry along and then act on. Both callers already
act on a drop, khugepaged by ending its walk and madvise_collapse() by
looking its VMA up again. The code that has to know is not the code
that does it.
Open-code it in the two callers. Each scans under the lock it already
holds and, when the scan found work, gives the lock up before running
the collapse. The scan then has one rule, called locked and returning
locked, and the run another, called unlocked. Nothing is left to
report, so khugepaged's lock_dropped and madvise_collapse()'s
mmap_unlocked both go. The engine never touches a lock it did not
take, and how a caller locks its scan is the caller's business alone.
khugepaged's walk carries on to the next table while the scan keeps
refusing, and ends once a collapse has taken the lock from under it.
madvise_collapse() re-finds its VMA after a collapse, which it did
before, and now uses a NULL vma to say that it has to. It still reports
the drop to its own caller, from the line that does it.
Preparation for moving madvise_collapse() out of khugepaged.c: what it
needs from the engine is then two calls with one lock rule each.
The lock is given up and taken again at the same points as before. No
functional change.
Link: https://lore.kernel.org/20260928100630.21870-11-kirill@shutemov.name
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Assisted-by: LLM
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Usama Arif <usama.arif@linux.dev>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
Diffstat (limited to 'scripts/checkstack.pl')
0 files changed, 0 insertions, 0 deletions
