mm: defer second attempt at merge on mmap()
authorLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Fri, 25 Oct 2024 12:26:27 +0000 (13:26 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 7 Nov 2024 04:11:20 +0000 (20:11 -0800)
commit5ac87a885aecb3fa2aae04215410882757a2ef06
tree7e7cd1962a9492e7d7af579f75f5c8d6cfa13247
parent5a689bac0bbc1ddad1e9f87b574f3d409643759c
mm: defer second attempt at merge on mmap()

Rather than trying to merge again when ostensibly allocating a new VMA,
instead defer until the VMA is added and attempt to merge the existing
range.

This way we have no complicated unwinding logic midway through the process
of mapping the VMA.

In addition this removes limitations on the VMA not being able to be the
first in the virtual memory address space which was previously implicitly
required.

In theory, for this very same reason, we should unconditionally attempt
merge here, however this is likely to have a performance impact so it is
better to avoid this given the unlikely outcome of a merge.

[lorenzo.stoakes@oracle.com: remove unnecessary indirection]
Link: https://lkml.kernel.org/r/5106696d-e625-4d8a-8545-9d1430301730@lucifer.local
Link: https://lkml.kernel.org/r/d4f84502605d7651ac114587f507395c0fc76004.1729858176.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vma.c