Skip to content

Commit

Permalink
mm/mmap: check on file instead of the rb_root_cached of its address_s…
Browse files Browse the repository at this point in the history
…pace

In __vma_adjust(), we do the check on *root* to decide whether to adjust
the address_space.  It seems to be more meaningful to do the check on
*file* itself.  This means we are adjusting some data because it is a file
backed vma.

Since we seem to assume the address_space is valid if it is a file backed
vma, let's just replace *root* with *file* here.

Signed-off-by: Wei Yang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
weiyang-linux authored and torvalds committed Oct 14, 2020
1 parent 808fbdb commit 0fc48a6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
anon_vma_interval_tree_pre_update_vma(next);
}

if (root) {
if (file) {
flush_dcache_mmap_lock(mapping);
vma_interval_tree_remove(vma, root);
if (adjust_next)
Expand All @@ -844,7 +844,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
next->vm_pgoff += adjust_next >> PAGE_SHIFT;
}

if (root) {
if (file) {
if (adjust_next)
vma_interval_tree_insert(next, root);
vma_interval_tree_insert(vma, root);
Expand Down Expand Up @@ -896,7 +896,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
anon_vma_unlock_write(anon_vma);
}

if (root) {
if (file) {
i_mmap_unlock_write(mapping);
uprobe_mmap(vma);

Expand Down

0 comments on commit 0fc48a6

Please sign in to comment.