Re: [PATCH v3 0/3] mm/hugetlb_vmemmap: Fix HVO races and deadlock

From: Andrew Morton

Date: Thu Nov 19 2026 - 12:00:57 EST


On Sat, 14 Nov 2026 19:25:20 +0800 Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote:

> This series fixes three HVO issues reported by Sashiko.
>
> The first patch serializes HWPoison updates and removal against HVO
> remapping so raw_hwp_page state cannot be lost or freed while a
> replacement vmemmap head page is being installed. The second patch uses
> an HVO-private rwsem to prevent deferred PMD splits from racing with PTE
> remapping before the TLB flush. The last patch switches the vmemmap walk
> to the lockless walker so a PMD split allocation cannot recurse into
> init_mm.mmap_lock through reclaim.
>

Thanks, tested in a VM. The series did everything it claimed to do and
the LLM couldn't fid a way to break it.

Tested-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>


: I tested the three patches in x86-64 QEMU guests. A had the series
: removed; B had it applied. Both used the same kernel configuration and
: fresh boots. The main tests used four CPUs, two NUMA nodes, 8 GiB RAM
: and 2 MiB HugeTLB pages. I added the same temporary delays and log
: messages to A and B, guarded by the test processes' current->comm, so
: other processes did not take those delays.
:
: [1/3] mm/hugetlb_vmemmap: fix HWPoison state races during optimization
:
: I put a three-second pause immediately after HVO copied the vmemmap
: head, then poisoned a tail page during that pause. On A, the HWPoison
: state was lost and the huge page remained in the free pool; B kept it
: out. Poisoning the last 4 KiB tail page gave the same result. For the
: reverse race, I also paused before the copy to poison the page, then
: unpoisoned it during the post-copy pause. A left stale HWPoison flags
: on the head and tail; B cleared them.
:
: [2/3] mm/hugetlb_vmemmap: fix PMD split TLB flush race
:
: I put a three-second pause immediately before the deferred
: flush_tlb_all(), after the split PMDs had been published. During that
: pause, separate processes allocated huge pages in the affected range.
: Temporary log messages recorded the old and new backing PFNs at each
: remap. A changed PTE mappings before the flush; B did not. Four
: simultaneous allocations repeated the early remapping on A across
: both split PMD ranges. I did not observe a processor using a stale
: TLB entry.
:
: [3/3] mm/hugetlb_vmemmap: fix deadlock during PMD split
:
: This test used a separate four-CPU, one-node, 4 GiB QEMU guest. An
: emulated QXL device initialized TTM. Because QXL's own pages were
: cached, a small test module used TTM's page-pool interfaces to return
: 512 write-combined pages to its pool. A process held about 2.5 GiB
: of guest memory.
:
: I created an init_mm.mmap_lock writer before HVO entered the PMD
: split. At the split, I released that writer, paused for 300 ms to let
: it wait on the lock, then called TTM's actual shrinker from the HVO
: task. A reached set_pages_wb() and blocked trying to take
: init_mm.mmap_lock; the huge-page allocation did not finish. On B,
: the writer completed, the shrinker freed the pool pages, and the
: allocation finished. The shrinker call was forced at this point.
: This tests TTM's page-freeing path and the lock order, but does not
: show that ordinary reclaim would select TTM at that instant.