Skip to content

Commit 4bfbe37

Browse files
tehcasterakpm00
authored andcommitted
mm/mremap: simplify vma expansion again
This effectively reverts d014cd7 ("mm, mremap: fix mremap() expanding for vma's with vm_ops->close()"). After the recent changes, vma_merge() is able to handle the expansion properly even when the vma being expanded has a vm_ops->close operation, so we don't need to special case it anymore. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Vlastimil Babka <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 714965c commit 4bfbe37

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

mm/mremap.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,23 +1040,11 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
10401040
* vma (expand operation itself) and possibly also with
10411041
* the next vma if it becomes adjacent to the expanded
10421042
* vma and otherwise compatible.
1043-
*
1044-
* However, vma_merge() can currently fail due to
1045-
* is_mergeable_vma() check for vm_ops->close (see the
1046-
* comment there). Yet this should not prevent vma
1047-
* expanding, so perform a simple expand for such vma.
1048-
* Ideally the check for close op should be only done
1049-
* when a vma would be actually removed due to a merge.
10501043
*/
1051-
if (!vma->vm_ops || !vma->vm_ops->close) {
1052-
vma = vma_merge(&vmi, mm, vma, extension_start,
1053-
extension_end, vma->vm_flags, vma->anon_vma,
1054-
vma->vm_file, extension_pgoff, vma_policy(vma),
1055-
vma->vm_userfaultfd_ctx, anon_vma_name(vma));
1056-
} else if (vma_expand(&vmi, vma, vma->vm_start,
1057-
addr + new_len, vma->vm_pgoff, NULL)) {
1058-
vma = NULL;
1059-
}
1044+
vma = vma_merge(&vmi, mm, vma, extension_start,
1045+
extension_end, vma->vm_flags, vma->anon_vma,
1046+
vma->vm_file, extension_pgoff, vma_policy(vma),
1047+
vma->vm_userfaultfd_ctx, anon_vma_name(vma));
10601048
if (!vma) {
10611049
vm_unacct_memory(pages);
10621050
ret = -ENOMEM;

0 commit comments

Comments
 (0)