Skip to content

VMA tree type safety and remove __vma_adjust()

Liam R. Howlett damon linux-mm linux-s390 lkml 4 versions – Applied

Status from this message: [merged mm-stable] vma_merge-set-vma-iterator-to-correct-position.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest49 patches 9 repliesApplied 49/49
  2. v348 patches 6 repliesSuperseded
  3. v244 patches 18 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v143 patches3 repliesSuperseded

Changes in v4 from the cover letter

- Rebased patches on mm-unstable
- Updated damon patches as per SeongJae Park comments
- Added extra patch to convert the new call of vma_adjust() in mremap()

Patches in v4 All 49 applied

#Subject and filesSizeRepliesApplied
1/49maple_tree: Add mas_init() functioninclude/linux/maple_tree.h+11 -00 repliesApplied
2/49maple_tree: Fix potential rcu issuelib/maple_tree.c+1 -10 repliesApplied
3/49maple_tree: Reduce user error potentiallib/maple_tree.c+10 -00 repliesApplied
4/49test_maple_tree: Test modifications while iteratinglib/test_maple_tree.c+72 -00 repliesApplied
5/49maple_tree: Fix handle of invalidated state in mas_wr_store_setup()lib/maple_tree.c+3 -00 repliesApplied
6/49maple_tree: Fix mas_prev() and mas_find() state handlinglib/maple_tree.c+5 -10 repliesApplied
7/49mm: Expand vma iterator interfaceinclude/linux/mm.h include/linux/mm_types.h mm/internal.h +1 more+125 -70 repliesApplied
8/49mm/mmap: convert brk to use vma iteratormm/mmap.c+23 -250 repliesApplied
9/49kernel/fork: Convert forking to using the vmi iteratorkernel/fork.c+8 -110 repliesApplied
10/49mmap: Convert vma_link() vma iteratormm/mmap.c+3 -30 repliesApplied
11/49mm/mmap: Remove preallocation from do_mas_align_munmap()mm/mmap.c+6 -80 repliesApplied
12/49mmap: Change do_mas_munmap and do_mas_aligned_munmap() to use vma iteratorinclude/linux/mm.h mm/mmap.c mm/mremap.c+39 -460 repliesApplied
13/49mmap: Convert vma_expand() to use vma iteratormm/mmap.c+4 -50 repliesApplied
14/49mm: Add temporary vma iterator versions of vma_merge(), split_vma(), and __split_vma()include/linux/mm.h mm/mmap.c+54 -10 repliesApplied
15/49ipc/shm: Use the vma iterator for munmap callsipc/shm.c+5 -62 repliesApplied
16/49userfaultfd: Use vma iteratorfs/userfaultfd.c+33 -540 repliesApplied
17/49mm: Change mprotect_fixup to vma iteratorfs/exec.c include/linux/mm.h mm/mprotect.c+29 -290 repliesApplied
18/49mlock: Convert mlock to vma iteratormm/mlock.c+28 -294 repliesApplied
19/49coredump: Convert to vma iteratorfs/coredump.c+4 -40 repliesApplied
20/49mempolicy: Convert to vma iteratormm/mempolicy.c+8 -170 repliesApplied
21/49task_mmu: Convert to vma iteratorfs/proc/task_mmu.c+13 -140 repliesApplied
22/49sched: Convert to vma iteratorkernel/sched/fair.c+7 -70 repliesApplied
23/49madvise: Use vmi iterator for __split_vma() and vma_merge()mm/madvise.c+5 -40 repliesApplied
24/49mmap: Pass through vmi iterator to __split_vma()mm/mmap.c+2 -20 repliesApplied
25/49mmap: Use vmi version of vma_merge()mm/mmap.c+5 -30 repliesApplied
26/49mm/mremap: Use vmi version of vma_merge()mm/mremap.c+7 -40 repliesApplied
27/49nommu: Convert nommu to using the vma iteratormm/nommu.c+31 -480 repliesApplied
28/49nommu: Pass through vma iterator to shrink_vma()mm/nommu.c+17 -460 repliesApplied
29/49mm: Switch vma_merge(), split_vma(), and __split_vma to vma iteratorfs/userfaultfd.c include/linux/mm.h mm/madvise.c +6 more+55 -980 repliesApplied
30/49mm/damon/vaddr-test.h: Stop using vma_mas_store() for maple tree storemm/damon/vaddr-test.h+14 -61 replyApplied
31/49mmap: Convert __vma_adjust() to use vma iteratorinclude/linux/mm.h mm/mmap.c+13 -650 repliesApplied
32/49mm: Pass through vma iterator to __vma_adjust()include/linux/mm.h mm/mmap.c+19 -180 repliesApplied
33/49madvise: Use split_vma() instead of __split_vma()mm/madvise.c+2 -60 repliesApplied
34/49mm: Remove unnecessary write to vma iterator in __vma_adjust()mm/mmap.c+6 -40 repliesApplied
35/49mm: Pass vma iterator through to __vma_adjust()mm/mmap.c+14 -80 repliesApplied
36/49mm: Add vma iterator to vma_adjust() argumentsfs/exec.c include/linux/mm.h mm/mmap.c +1 more+15 -190 repliesApplied
37/49mmap: Clean up mmap_region() unrollingmm/mmap.c+18 -270 repliesApplied
38/49mm: Change munmap splitting order and move_vma()mm/mmap.c mm/mremap.c+18 -270 repliesApplied
39/49mm/mmap: move anon_vma setting in __vma_adjust()mm/mmap.c+8 -50 repliesApplied
40/49mm/mmap: Refactor locking out of __vma_adjust()mm/internal.h mm/mmap.c+150 -950 repliesApplied
41/49mm/mmap: Use vma_prepare() and vma_complete() in vma_expand()mm/mmap.c+72 -1160 repliesApplied
42/49mm/mmap: Introduce init_vma_prep() and init_multi_vma_prep()mm/mmap.c+61 -470 repliesApplied
43/49mm: Don't use __vma_adjust() in __split_vma()fs/exec.c include/linux/mm.h mm/mmap.c +1 more+61 -700 repliesApplied
44/49mm/mremap: Convert vma_adjust() to vma_expand()include/linux/mm.h mm/mmap.c mm/mremap.c+8 -50 repliesApplied
45/49mm/mmap: Don't use __vma_adjust() in shift_arg_pages()fs/exec.c include/linux/mm.h mm/mmap.c+47 -190 repliesApplied
46/49mm/mmap: Introduce dup_vma_anon() helpermm/mmap.c+40 -340 repliesApplied
47/49mm/mmap: Convert do_brk_flags() to use vma_prepare() and vma_complete()mm/mmap.c+4 -80 repliesApplied
48/49mm/mmap: Remove __vma_adjust()kernel/events/uprobes.c mm/filemap.c mm/mmap.c +1 more+107 -1622 repliesApplied
49/49vma_merge: Set vma iterator to correct position.mm/mmap.c+1 -30 repliesApplied

Reviews trailers per patch

2 of 49 patches have a Reviewed-by or Acked-by.

PatchSeongJae ParkLiam R. Howlett
1/49
2/49
3/49
4/49
5/49
6/49
7/49
8/49
9/49
10/49
11/49
12/49
13/49
14/49
15/49
16/49
17/49
18/49
19/49
20/49
21/49
22/49
23/49
24/49
25/49
26/49
27/49
28/49
29/49
30/49R-b
31/49
32/49
33/49
34/49
35/49
36/49
37/49
38/49
39/49
40/49
41/49
42/49
43/49
44/49
45/49
46/49
47/49
48/49R-b
49/49

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 00/49] VMA tree type safety and remove __vma_adjust()

Andrew,

This patch set does two things: 1. Clean up, including removal of __vma_adjust() and 2. Extends the VMA iterator API to provide type safety to the VMA operations using the maple tree, as requested by Linus [1].

It also addresses another issue of usability brought up by Linus about needing to modify the maple state within the loops. The maple state has been replaced by the VMA iterator and the iterator is now modified within the MM code so the caller should not need to worry about doing the work themselves when tree modifications occur.

This brought up a potential inconsistency of the iterator state and what the user expects, so the inconsistency is addressed to keep the VMA iterator safe for use after the looping over a VMA range. This is addressed in patch 3 ("maple_tree: Reduce user error potential") and 4 ("test_maple_tree: Test modifications while iterating").

While cleaning up the state, the duplicate locking code in mm/mmap.c introduced by the maple tree has been address by abstracting it to two
functions: vma_prepare() and vma_complete(). These abstractions allowed for a much simpler __vma_adjust(), which eventually leads to the removal of the __vma_adjust() function by placing the logic into the vma_merge() function itself.

1. https://lore.kernel.org/linux-mm/CAHk-=wg9WQXBGkNdKD2bqocnN73rDswuWsavBB7T-tekykEn_A@mail.gmail.com/

Changes since v3:
- Rebased patches on mm-unstable
- Updated damon patches as per SeongJae Park comments
- Added extra patch to convert the new call of vma_adjust() in mremap()

v3: https://lore.kernel.org/linux-mm/[email protected]/
v2: https://lore.kernel.org/linux-mm/[email protected]/
v1: https://lore.kernel.org/linux-mm/[email protected]/

Liam R. Howlett (49):
maple_tree: Add mas_init() function
maple_tree: Fix potential rcu issue
maple_tree: Reduce user error potential
test_maple_tree: Test modifications while iterating
maple_tree: Fix handle of invalidated state in mas_wr_store_setup()
maple_tree: Fix mas_prev() and mas_find() state handling
mm: Expand vma iterator interface
mm/mmap: convert brk to use vma iterator
kernel/fork: Convert forking to using the vmi iterator
mmap: Convert vma_link() vma iterator
mm/mmap: Remove preallocation from do_mas_align_munmap()
mmap: Change do_mas_munmap and do_mas_aligned_munmap() to use vma
iterator
mmap: Convert vma_expand() to use vma iterator
mm: Add temporary vma iterator versions of vma_merge(), split_vma(),

    and __split_vma()

ipc/shm: Use the vma iterator for munmap calls
userfaultfd: Use vma iterator
mm: Change mprotect_fixup to vma iterator
mlock: Convert mlock to vma iterator
coredump: Convert to vma iterator
mempolicy: Convert to vma iterator
task_mmu: Convert to vma iterator
sched: Convert to vma iterator
madvise: Use vmi iterator for __split_vma() and vma_merge()
mmap: Pass through vmi iterator to __split_vma()
mmap: Use vmi version of vma_merge()
mm/mremap: Use vmi version of vma_merge()
nommu: Convert nommu to using the vma iterator
nommu: Pass through vma iterator to shrink_vma()
mm: Switch vma_merge(), split_vma(), and __split_vma to vma iterator mm/damon/vaddr-test.h: Stop using vma_mas_store() for maple tree store
mmap: Convert __vma_adjust() to use vma iterator
mm: Pass through vma iterator to __vma_adjust()
madvise: Use split_vma() instead of __split_vma()
mm: Remove unnecessary write to vma iterator in __vma_adjust()
mm: Pass vma iterator through to __vma_adjust()
mm: Add vma iterator to vma_adjust() arguments
mmap: Clean up mmap_region() unrolling
mm: Change munmap splitting order and move_vma()
mm/mmap: move anon_vma setting in __vma_adjust()
mm/mmap: Refactor locking out of __vma_adjust()
mm/mmap: Use vma_prepare() and vma_complete() in vma_expand() mm/mmap: Introduce init_vma_prep() and init_multi_vma_prep()
mm: Don't use __vma_adjust() in __split_vma()
mm/mremap: Convert vma_adjust() to vma_expand()
mm/mmap: Don't use __vma_adjust() in shift_arg_pages() mm/mmap: Introduce dup_vma_anon() helper
mm/mmap: Convert do_brk_flags() to use vma_prepare() and
vma_complete()
mm/mmap: Remove __vma_adjust()
vma_merge: Set vma iterator to correct position.

 fs/coredump.c              |    8 +-
 fs/exec.c                  |   16 +-
 fs/proc/task_mmu.c         |   27 +-
 fs/userfaultfd.c           |   87 ++-
 include/linux/maple_tree.h |   11 +
 include/linux/mm.h         |   87 ++-
 include/linux/mm_types.h   |    4 +-
 ipc/shm.c                  |   11 +-
 kernel/events/uprobes.c    |    2 +-
 kernel/fork.c              |   19 +-
 kernel/sched/fair.c        |   14 +-
 lib/maple_tree.c           |   19 +-
 lib/test_maple_tree.c      |   72 +++
 mm/damon/vaddr-test.h      |   20 +-
 mm/filemap.c               |    2 +-
 mm/internal.h              |   78 +++
 mm/madvise.c               |   13 +-
 mm/mempolicy.c             |   25 +-
 mm/mlock.c                 |   57 +-
 mm/mmap.c                  | 1022 +++++++++++++++++-------------------
 mm/mprotect.c              |   47 +-
 mm/mremap.c                |   44 +-
 mm/nommu.c                 |  124 ++---
 mm/rmap.c                  |   15 +-
 24 files changed, 949 insertions(+), 875 deletions(-)
Signature · 1 line
2.35.1