From: Vlastimil Babka <vbabka@suse.cz>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: "Liam R . Howlett" <Liam.Howlett@oracle.com>,
Jann Horn <jannh@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Peter Xu <peterx@redhat.com>
Subject: Re: [PATCH v3 4/5] mm: remove unnecessary reset state logic on merge new VMA
Date: Fri, 25 Oct 2024 19:35:22 +0200 [thread overview]
Message-ID: <21e7bed9-b705-4fb1-84e6-9fab2e66dbeb@suse.cz> (raw)
In-Reply-To: <5d9a59eee6498ae017cc87d89aa723de7179f75d.1729858176.git.lorenzo.stoakes@oracle.com>
On 10/25/24 14:26, Lorenzo Stoakes wrote:
> 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.
>
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Yeah glad to be rid of this.
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/vma.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/mm/vma.c b/mm/vma.c
> index b91c947babd6..7c690be67910 100644
> --- a/mm/vma.c
> +++ b/mm/vma.c
> @@ -963,7 +963,6 @@ struct vm_area_struct *vma_merge_new_range(struct vma_merge_struct *vmg)
> struct vm_area_struct *next = vmg->next;
> unsigned long start = vmg->start;
> unsigned long end = vmg->end;
> - pgoff_t pgoff = vmg->pgoff;
> pgoff_t pglen = PHYS_PFN(end - start);
> bool can_merge_left, can_merge_right;
> bool just_expand = vmg->merge_flags & VMG_FLAG_JUST_EXPAND;
> @@ -1020,16 +1019,6 @@ struct vm_area_struct *vma_merge_new_range(struct vma_merge_struct *vmg)
> return vmg->vma;
> }
>
> - /* If expansion failed, reset state. Allows us to retry merge later. */
> - if (!just_expand) {
> - vmg->vma = NULL;
> - vmg->start = start;
> - vmg->end = end;
> - vmg->pgoff = pgoff;
> - if (vmg->vma == prev)
> - vma_iter_set(vmg->vmi, start);
> - }
> -
> return NULL;
> }
>
next prev parent reply other threads:[~2024-10-25 17:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 12:26 [PATCH v3 0/5] fix error handling in mmap_region() and refactor Lorenzo Stoakes
2024-10-25 12:26 ` [PATCH v3 1/5] tools: testing: add additional vma_internal.h stubs Lorenzo Stoakes
2024-10-25 12:26 ` [PATCH v3 2/5] mm: isolate mmap internal logic to mm/vma.c Lorenzo Stoakes
2024-10-25 12:26 ` [PATCH v3 3/5] mm: refactor __mmap_region() Lorenzo Stoakes
2024-10-25 12:26 ` [PATCH v3 4/5] mm: remove unnecessary reset state logic on merge new VMA Lorenzo Stoakes
2024-10-25 17:35 ` Vlastimil Babka [this message]
2024-10-25 12:26 ` [PATCH v3 5/5] mm: defer second attempt at merge on mmap() Lorenzo Stoakes
2024-10-25 17:40 ` Vlastimil Babka
2024-10-25 17:53 ` Lorenzo Stoakes
2024-10-26 10:34 ` Lorenzo Stoakes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=21e7bed9-b705-4fb1-84e6-9fab2e66dbeb@suse.cz \
--to=vbabka@suse.cz \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=peterx@redhat.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®