summaryrefslogtreecommitdiff
path: root/mm/vma.h
diff options
context:
space:
mode:
authorLorenzo Stoakes <lorenzo.stoakes@oracle.com>2025-01-31 12:31:52 +0000
committerAndrew Morton <akpm@linux-foundation.org>2025-03-16 22:06:02 -0700
commit0e5ffe9b2bd6d9ab7bf45f512c016e4710bf6d5d (patch)
tree5a25a49961c7206a749c7e00c28eb88e5de38109 /mm/vma.h
parentfe3e9cf0d7a28d333523189d1405770d980b07d6 (diff)
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>
Diffstat (limited to 'mm/vma.h')
-rw-r--r--mm/vma.h6
1 files changed, 1 insertions, 5 deletions
diff --git a/mm/vma.h b/mm/vma.h
index e18487797fa4..e55e68abfbe3 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -82,11 +82,7 @@ struct vma_merge_struct {
struct vm_area_struct *prev;
struct vm_area_struct *middle;
struct vm_area_struct *next;
- /*
- * This is the VMA we ultimately target to become the merged VMA, except
- * for the one exception of merge right, shrink next (for details of
- * this scenario see vma_merge_existing_range()).
- */
+ /* This is the VMA we ultimately target to become the merged VMA. */
struct vm_area_struct *target;
/*
* Initially, the start, end, pgoff fields are provided by the caller