]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: make vmg->target consistent and further simplify commit_merge()
authorLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Fri, 31 Jan 2025 12:31:52 +0000 (12:31 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 28 Feb 2025 00:59:44 +0000 (16:59 -0800)
commit9eb273d858d228dedc250731e7d0cb0d44b2f873
tree1584e6eda55ab9f524f1841b4fe74c9c1d0bb0ad
parent4f19fa920c36cc380d6083bada4bcff6be4ebb56
mm: make vmg->target consistent and further simplify commit_merge()

It is confusing for vmg->target to sometimes be the target merged VMA and
in one case not.

Fix this by having commit_merge() use its awareness of the
vmg->_adjust_next_start case to know that it is manipulating a separate
vma, abstracted in the 'vma' local variable.

Place removal and adjust VMA determination logic into
init_multi_vma_prep(), as the flags give us enough information to do so,
and since this is the function that sets up the vma_prepare struct it
makes sense to do so here.

Doing this significantly simplifies commit_merge(), allowing us to
eliminate the 'merge_target' handling, initialise the VMA iterator in a
more sensible place and simply return vmg->target consistently.

This also allows us to simplify setting vmg->target in
vma_merge_existing_range() since we are then left only with two cases -
merge left (or both) where the target is vmg->prev or merge right in which
the target is vmg->next.

This makes it easy for somebody reading the code to know what VMA will
actually be the one returned and merged into and removes a great deal of
the confusing 'adjust' nonsense.

This patch has no change in functional behaviour.

Link: https://lkml.kernel.org/r/50f96e31ab1980eaaf1006e34a4f6e6dad9320b8.1738326519.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 Howlett <liam.howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vma.c
mm/vma.h