Re: [PATCH mm-hotfixes v2 3/4] mm/ptdump: always stabilise against page table freeing using init_mm

From: Lorenzo Stoakes

Date: Tue Jul 14 2026 - 05:52:12 EST


On 2026-07-13 18:19 +0100, Kiryl Shutsemau wrote:
> On Sun, Jul 12, 2026 at 11:42:26AM +0100, Lorenzo Stoakes wrote:
> > x86 and arm64 invoke ptdump_walk_pgd() with non-init_mm mm whilst still
> > walking kernel page table ranges.
>
> The code looks good to me.

Thanks!

>
> Same comment as on patch 1 about the commit message structure, only
> more so: the race itself is never actually stated -- that these walks
> hold only the walked mm's lock, while the freeing exclusion built by
> patches 1 and 2 hangs off the init_mm lock. The fact that makes it
> possible (x86 shares kernel pgd entries with every mm) is hidden in a
> parenthesis. And the last three paragraphs read like v2 changelog
> rather than commit message material.

OK, will reword.

>
> > We take this after mmap write locking the non-init_mm mm. Nothing acquires
> > the init_mm lock first before locking an arbitrary mm, so no deadlock is
> > possible.
>
> Do we want to document this locking order somewhere?

I guess Documentation/mm/process_addrs.rst is the best place, I'll send that as
a follow-up separately. todo++; :)

>
> --
> Kiryl Shutsemau / Kirill A. Shutemov
>

Thanks, Lorenzo