Skip to content

Commit

Permalink
mm/mmap: move anon_vma setting in __vma_adjust()
Browse files Browse the repository at this point in the history
Move the anon_vma setting & warn_no up the function.  This is done to
clear up the locking later.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Liam R. Howlett <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
howlett authored and akpm00 committed Feb 10, 2023
1 parent 6b73cff commit e3d73f8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,14 @@ int __vma_adjust(struct vma_iterator *vmi, struct vm_area_struct *vma,
if (vma_iter_prealloc(vmi))
return -ENOMEM;

anon_vma = vma->anon_vma;
if (!anon_vma && adjust_next)
anon_vma = next->anon_vma;

if (anon_vma)
VM_WARN_ON(adjust_next && next->anon_vma &&
anon_vma != next->anon_vma);

vma_adjust_trans_huge(orig_vma, start, end, adjust_next);
if (file) {
mapping = file->f_mapping;
Expand All @@ -703,12 +711,7 @@ int __vma_adjust(struct vma_iterator *vmi, struct vm_area_struct *vma,
}
}

anon_vma = vma->anon_vma;
if (!anon_vma && adjust_next)
anon_vma = next->anon_vma;
if (anon_vma) {
VM_WARN_ON(adjust_next && next->anon_vma &&
anon_vma != next->anon_vma);
anon_vma_lock_write(anon_vma);
anon_vma_interval_tree_pre_update_vma(vma);
if (adjust_next)
Expand Down

0 comments on commit e3d73f8

Please sign in to comment.