aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorLiam R. Howlett <Liam.Howlett@Oracle.com>2022-09-06 19:49:06 +0000
committerAndrew Morton <akpm@linux-foundation.org>2022-09-26 19:46:27 -0700
commitc154124fe925a451e471233aa7d1ab9a91f0a5ad (patch)
tree2bcca60033b63b850acbb0baae876f610ba178a5 /mm/mmap.c
parentmm/mmap: drop range_has_overlap() function (diff)
downloadlinux-dev-c154124fe925a451e471233aa7d1ab9a91f0a5ad.tar.xz
linux-dev-c154124fe925a451e471233aa7d1ab9a91f0a5ad.zip
mm/mmap.c: pass in mapping to __vma_link_file()
__vma_link_file() resolves the mapping from the file, if there is one. Pass through the mapping and check the vm_file externally since most places already have the required information and check of vm_file. Link: https://lkml.kernel.org/r/20220906194824.2110408-71-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> Tested-by: Yu Zhao <yuzhao@google.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: David Hildenbrand <david@redhat.com> Cc: David Howells <dhowells@redhat.com> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org> Cc: SeongJae Park <sj@kernel.org> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 5070af64b99d..fbe8b52a90a3 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -407,21 +407,15 @@ static unsigned long count_vma_pages_range(struct mm_struct *mm,
return nr_pages;
}
-static void __vma_link_file(struct vm_area_struct *vma)
+static void __vma_link_file(struct vm_area_struct *vma,
+ struct address_space *mapping)
{
- struct file *file;
-
- file = vma->vm_file;
- if (file) {
- struct address_space *mapping = file->f_mapping;
-
- if (vma->vm_flags & VM_SHARED)
- mapping_allow_writable(mapping);
+ if (vma->vm_flags & VM_SHARED)
+ mapping_allow_writable(mapping);
- flush_dcache_mmap_lock(mapping);
- vma_interval_tree_insert(vma, &mapping->i_mmap);
- flush_dcache_mmap_unlock(mapping);
- }
+ flush_dcache_mmap_lock(mapping);
+ vma_interval_tree_insert(vma, &mapping->i_mmap);
+ flush_dcache_mmap_unlock(mapping);
}
/*
@@ -488,10 +482,11 @@ static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma)
}
vma_mas_store(vma, &mas);
- __vma_link_file(vma);
- if (mapping)
+ if (mapping) {
+ __vma_link_file(vma, mapping);
i_mmap_unlock_write(mapping);
+ }
mm->map_count++;
validate_mm(mm);
@@ -730,14 +725,14 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
uprobe_munmap(next, next->vm_start, next->vm_end);
i_mmap_lock_write(mapping);
- if (insert) {
+ if (insert && insert->vm_file) {
/*
* Put into interval tree now, so instantiated pages
* are visible to arm/parisc __flush_dcache_page
* throughout; but we cannot insert into address
* space until vma start or end is updated.
*/
- __vma_link_file(insert);
+ __vma_link_file(insert, insert->vm_file->f_mapping);
}
}