Re: [PATCH] mm: swap: check for xa_zero_entry() on vma in swapoff path

From: David Hildenbrand
Date: Mon Aug 11 2025 - 09:20:08 EST



When registering vmas for uprobe, skip the vmas in an mm that is marked
unstable. Modifying a vma in an unstable mm may cause issues if the mm
isn't fully initialised.__

Is there anything preventing us from just leaving a proper tree that
reflects reality in place before we drop the write lock?

When you mean proper tree, is this about the your previous question? --
Shouldn't we just remove anything from the tree here that was not copied
immediately?

Commit d24062914837 (" fork: use __mt_dup() to duplicate maple tree in
dup_mmap()") did this for efficiency, so it'd be a regression to do this.

We're talking about the case where fork *fails*. That cannot possibly be
relevant for performance, can it? :)

I think it optimises the overall operation, but as a product of that, has to
handle this edge case, and that necessitated this rather horrble stuff.

Obviously we don't need to optimise a 'we are about to die' case :)

Right, so my original question was whether we could just drop all stale stuff from the tree before we lift the mmap write lock, leaving only the VMAs in there that we actually processed successfully.

--
Cheers,

David / dhildenb