diff options
author | Liam R. Howlett <Liam.Howlett@Oracle.com> | 2023-01-20 11:26:40 -0500 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2023-02-09 16:51:37 -0800 |
commit | e3d73f848e5f2e9da46646c97fb127dfc6868767 (patch) | |
tree | acb7ecb58dab645431d2b945ef6bd49f1e148e86 | |
parent | 6b73cff239e52fd43949c40eaabb369298c11aae (diff) | |
download | linux-stable-e3d73f848e5f2e9da46646c97fb127dfc6868767.tar.gz linux-stable-e3d73f848e5f2e9da46646c97fb127dfc6868767.tar.bz2 linux-stable-e3d73f848e5f2e9da46646c97fb127dfc6868767.zip |
mm/mmap: move anon_vma setting in __vma_adjust()
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/20230120162650.984577-40-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | mm/mmap.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/mm/mmap.c b/mm/mmap.c index 29ffd58d4091..12545ec9cdeb 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -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; @@ -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) |