Commit fa5e5876 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

fork: use VMA iterator

The VMA iterator is faster than the linked list and removing the linked
list will shrink the vm_area_struct.

Link: https://lkml.kernel.org/r/20220906194824.2110408-50-Liam.Howlett@oracle.comSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarLiam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
Reviewed-by: default avatarDavidlohr Bueso <dave@stgolabs.net>
Tested-by: default avatarYu Zhao <yuzhao@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: SeongJae Park <sj@kernel.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 0cd4d02c
...@@ -1301,13 +1301,16 @@ int replace_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file) ...@@ -1301,13 +1301,16 @@ int replace_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file)
/* Forbid mm->exe_file change if old file still mapped. */ /* Forbid mm->exe_file change if old file still mapped. */
old_exe_file = get_mm_exe_file(mm); old_exe_file = get_mm_exe_file(mm);
if (old_exe_file) { if (old_exe_file) {
VMA_ITERATOR(vmi, mm, 0);
mmap_read_lock(mm); mmap_read_lock(mm);
for (vma = mm->mmap; vma && !ret; vma = vma->vm_next) { for_each_vma(vmi, vma) {
if (!vma->vm_file) if (!vma->vm_file)
continue; continue;
if (path_equal(&vma->vm_file->f_path, if (path_equal(&vma->vm_file->f_path,
&old_exe_file->f_path)) &old_exe_file->f_path)) {
ret = -EBUSY; ret = -EBUSY;
break;
}
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);
fput(old_exe_file); fput(old_exe_file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment