mmap: save some cycles for the shared anonymous mapping
shmem_zero_setup() does not change vm_start, pgoff or vm_flags, only some drivers change them (such as /driver/video/bfin-t350mcqb-fb.c). Move these codes to a more proper place to save cycles for shared anonymous mapping. Signed-off-by: Huang Shijie <shijie8@gmail.com> Reviewed-by: Minchan Kim <minchan.kim@gmail.com> Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
252c5f94d9
commit
f8dbf0a7a4
10
mm/mmap.c
10
mm/mmap.c
|
@ -1191,11 +1191,6 @@ munmap_back:
|
||||||
goto unmap_and_free_vma;
|
goto unmap_and_free_vma;
|
||||||
if (vm_flags & VM_EXECUTABLE)
|
if (vm_flags & VM_EXECUTABLE)
|
||||||
added_exe_file_vma(mm);
|
added_exe_file_vma(mm);
|
||||||
} else if (vm_flags & VM_SHARED) {
|
|
||||||
error = shmem_zero_setup(vma);
|
|
||||||
if (error)
|
|
||||||
goto free_vma;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Can addr have changed??
|
/* Can addr have changed??
|
||||||
*
|
*
|
||||||
|
@ -1205,6 +1200,11 @@ munmap_back:
|
||||||
addr = vma->vm_start;
|
addr = vma->vm_start;
|
||||||
pgoff = vma->vm_pgoff;
|
pgoff = vma->vm_pgoff;
|
||||||
vm_flags = vma->vm_flags;
|
vm_flags = vma->vm_flags;
|
||||||
|
} else if (vm_flags & VM_SHARED) {
|
||||||
|
error = shmem_zero_setup(vma);
|
||||||
|
if (error)
|
||||||
|
goto free_vma;
|
||||||
|
}
|
||||||
|
|
||||||
if (vma_wants_writenotify(vma))
|
if (vma_wants_writenotify(vma))
|
||||||
vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
|
vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
|
||||||
|
|
Loading…
Reference in a new issue