RFC Remove XA_ZERO from error recovery of
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest6 patches 28 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | mm/mmap: Move exit_mmap() trace pointmm/ | +1 | 2 replies | |
| 2/6 | mm/mmap: Abstract vma clean up from exit_mmap()mm/ | +24 | 3 replies | |
| 3/6 | mm/vma: Add limits to unmap_region() for vmasmm/ mm/ | +5 | 3 replies | |
| 4/6 | mm/memory: Add tree limit to free_pgtables()mm/ mm/ mm/ +1 more | +10 | 8 replies | |
| 5/6 | mm/vma: Add page table limit to unmap_region()mm/ mm/ | +4 | 1 reply | |
| 6/6 | mm: Change dup_mmap() recoverymm/ mm/ | +29 | 5 replies |
Reviews trailers per patch
3 of 6 patches have a Reviewed-by or Acked-by.
| Patch | Lorenzo Stoakes | Chris Li |
|---|---|---|
| 1/6 | R-b | A-b |
| 2/6 | R-b | |
| 3/6 | ||
| 4/6 | ||
| 5/6 | R-b | |
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [RFC PATCH 0/6] Remove XA_ZERO from error recovery of
Before you read on, please take a moment to acknowledge that David Hildenbrand asked for this, so I'm blaming mostly him :)
It is possible that the dup_mmap() call fails on allocating or setting up a vma after the maple tree of the oldmm is copied. Today, that failure point is marked by inserting an XA_ZERO entry over the failure point so that the exact location does not need to be communicated through to exit_mmap().
However, a race exists in the tear down process because the dup_mmap() drops the mmap lock before exit_mmap() can remove the partially set up vma tree. This means that other tasks may get to the mm tree and find the invalid vma pointer (since it's an XA_ZERO entry), even though the mm is marked as MMF_OOM_SKIP and MMF_UNSTABLE.
To remove the race fully, the tree must be cleaned up before dropping the lock. This is accomplished by extracting the vma cleanup in exit_mmap() and changing the required functions to pass through the vma search limit.
This does run the risk of increasing the possibility of finding no vmas (which is already possible!) in code this isn't careful.
The passing of so many limits and variables was such a mess when the dup_mmap() was introduced that it was avoided in favour of the XA_ZERO entry marker, but since the swap case was the second time we've hit cases of walking an almost-dead mm, here's the alternative to checking MMF_UNSTABLE before wandering into other mm structs.
[1]. https://lore.kernel.org/all/[email protected]/
Liam R. Howlett (6):
mm/mmap: Move exit_mmap() trace point
mm/mmap: Abstract vma clean up from exit_mmap()
mm/vma: Add limits to unmap_region() for vmas
mm/memory: Add tree limit to free_pgtables()
mm/vma: Add page table limit to unmap_region()
mm: Change dup_mmap() recovery
mm/internal.h | 4 ++- mm/memory.c | 13 ++++----- mm/mmap.c | 80 ++++++++++++++++++++++++++++++++++----------------- mm/vma.c | 10 +++++-- mm/vma.h | 1 + 5 files changed, 70 insertions(+), 38 deletions(-)
Signature · 1 line
2.47.2