Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: remove unnecessary reset state logic on merge new VMA

The only place where this was used was in mmap_region(), which we have now
adjusted to not require this to be performed (we reset ourselves in
effect).

It also created a dangerous assumption that VMG state could be safely
reused after a merge, at which point it may have been mutated in
unexpected ways, leading to subtle bugs.

Note that it was discovered by Wei Yang that there was also an error in
this code - we are comparing vmg->vma with prev after setting it to NULL.

This however had no impact, as we previously reset VMA iterator state
before attempting merge again, but it was useless effort.

In any case, this patch removes all of the logic so also eliminates this
wasted effort.

Link: https://lkml.kernel.org/r/5d9a59eee6498ae017cc87d89aa723de7179f75d.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>

authored by

Lorenzo Stoakes and committed by
Andrew Morton
5a689bac 0d11630c

-11
-11
mm/vma.c
··· 963 963 struct vm_area_struct *next = vmg->next; 964 964 unsigned long start = vmg->start; 965 965 unsigned long end = vmg->end; 966 - pgoff_t pgoff = vmg->pgoff; 967 966 pgoff_t pglen = PHYS_PFN(end - start); 968 967 bool can_merge_left, can_merge_right; 969 968 bool just_expand = vmg->merge_flags & VMG_FLAG_JUST_EXPAND; ··· 1017 1018 khugepaged_enter_vma(vmg->vma, vmg->flags); 1018 1019 vmg->state = VMA_MERGE_SUCCESS; 1019 1020 return vmg->vma; 1020 - } 1021 - 1022 - /* If expansion failed, reset state. Allows us to retry merge later. */ 1023 - if (!just_expand) { 1024 - vmg->vma = NULL; 1025 - vmg->start = start; 1026 - vmg->end = end; 1027 - vmg->pgoff = pgoff; 1028 - if (vmg->vma == prev) 1029 - vma_iter_set(vmg->vmi, start); 1030 1021 } 1031 1022 1032 1023 return NULL;