linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	Jann Horn <jannh@google.com>, Pedro Falcato <pfalcato@suse.de>,
	Kees Cook <kees@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/vma: use vmg->target to specify target VMA for new VMA merge
Date: Thu, 19 Jun 2025 15:24:35 +0100	[thread overview]
Message-ID: <85378739-d71e-4ccc-a46e-c6cc72915f04@lucifer.local> (raw)
In-Reply-To: <7a1d94ca-65a1-4b60-83a7-055c69d5c882@suse.cz>

On Thu, Jun 19, 2025 at 03:44:21PM +0200, Vlastimil Babka wrote:
> On 6/13/25 20:48, Lorenzo Stoakes wrote:
> > In commit 3a75ccba047b ("mm: simplify vma merge structure and expand
> > comments") we introduced the vmg->target field to make the merging of
> > existing VMAs simpler - clarifying precisely which VMA would eventually
> > become the merged VMA once the merge operation was complete.
> >
> > New VMA merging did not get quite the same treatment, retaining the rather
> > confusing convention of storing the target VMA in vmg->middle.
> >
> > This patch corrects this state of affairs, utilising vmg->target for this
> > purpose for both vma_merge_new_range() and also for vma_expand().
> >
> > We retain the WARN_ON for vmg->middle being specified in
> > vma_merge_new_range() as doing so would make no sense, but add an
> > additional debug assert for setting vmg->target.
> >
> > This patch additionally updates VMA userland testing to account for this
> > change.
> >
> > Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
>
> Reviewed-by: Vlastimil Babka <vbabka@suse.cz>

Thanks!

>
> Nit below:
>
> > @@ -1086,27 +1087,29 @@ struct vm_area_struct *vma_merge_new_range(struct vma_merge_struct *vmg)
> >   * @vmg: Describes a VMA expansion operation.
> >   *
> >   * Expand @vma to vmg->start and vmg->end.  Can expand off the start and end.
> > - * Will expand over vmg->next if it's different from vmg->middle and vmg->end ==
> > - * vmg->next->vm_end.  Checking if the vmg->middle can expand and merge with
> > + * Will expand over vmg->next if it's different from vmg->target and vmg->end ==
> > + * vmg->next->vm_end.  Checking if the vmg->target can expand and merge with
> >   * vmg->next needs to be handled by the caller.
> >   *
> >   * Returns: 0 on success.
> >   *
> >   * ASSUMPTIONS:
> > - * - The caller must hold a WRITE lock on vmg->middle->mm->mmap_lock.
> > - * - The caller must have set @vmg->middle and @vmg->next.
> > + * - The caller must hold a WRITE lock on vmg->target->mm->mmap_lock.
>
> The assert uses vmg->mm so maybe the comment should do the same? (IIRC mm
> was added only later to vmg?)

Haha you are the master of spotting stuff like this :)

Yeah you're right, this was actually updated for vma_merge_new_range() and
vma_merge_existing_range(), but missed this one.

Since we're updating it we may as well fix it, will send a fix-patch at
top-level :>)

>
> > + * - The caller must have set @vmg->target and @vmg->next.


  reply	other threads:[~2025-06-19 14:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-13 18:48 Lorenzo Stoakes
2025-06-19 13:44 ` Vlastimil Babka
2025-06-19 14:24   ` Lorenzo Stoakes [this message]
2025-06-19 14:36 ` 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=85378739-d71e-4ccc-a46e-c6cc72915f04@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=jannh@google.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pfalcato@suse.de \
    --cc=vbabka@suse.cz \
    /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