linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH v2 06/10] mm: avoid using vma_merge() for new VMAs
Date: Fri, 30 Aug 2024 16:19:54 +0100	[thread overview]
Message-ID: <5b641d45-3898-40c9-8288-f2aacae1400d@lucifer.local> (raw)
In-Reply-To: <yyywfqdagobkzz26znuqgembxq7jkciq6kbhhhdvo4gox4idke@ixtspzmu6ttv>

On Wed, Aug 28, 2024 at 04:52:07PM GMT, Liam R. Howlett wrote:

[snip]

> > +	/*
> > +	 * Now try to expand adjacent VMA(s). This takes care of removing the
> > +	 * following VMA if we have VMAs on both sides.
> > +	 */
> > +	if (vmg->vma && !vma_expand(vmg)) {
> > +		khugepaged_enter_vma(vmg->vma, vmg->flags);
>
> This might be able to be moved into vma_expand().

Sorry for the multiple emails, but am working my way through.

Can't do this, as relocate_vma_down() (and the original implementation in
fs/exec.c - I checked) does not invoke khugepaged_enter_vma(), sadly.

>
> > +
>
> Extra whitespace

Ack. A lot of these are to subjective taste for clarity, but am happy to
adjust these for the most part...

>
> > +		vmg->state = VMA_MERGE_SUCCESS;
> > +		return vmg->vma;
> > +	}
> > +
> > +	/* If expansion failed, reset state. Allows us to retry merge later. */
> > +	vmg->vma = NULL;
> > +	vmg->start = start;
> > +	vmg->end = end;
> > +	vmg->pgoff = pgoff;
> > +	if (vmg->vma == prev)
> > +		vma_iter_set(vmg->vmi, start);
> > +
> > +	return NULL;
> > +}
> > +
> >  /*
> >   * vma_expand - Expand an existing VMA
> >   *
> > @@ -474,7 +584,11 @@ void validate_mm(struct mm_struct *mm)
> >   * vmg->next->vm_end.  Checking if the vmg->vma can expand and merge with
> >   * vmg->next needs to be handled by the caller.
> >   *
> > - * Returns: 0 on success
> > + * Returns: 0 on success.
> > + *
> > + * ASSUMPTIONS:
> > + * - The caller must hold a WRITE lock on vmg->vma->mm->mmap_lock.
> > + * - The caller must have set @vmg->vma and @vmg->next.
> >   */
> >  int vma_expand(struct vma_merge_struct *vmg)
> >  {
> > @@ -484,6 +598,8 @@ int vma_expand(struct vma_merge_struct *vmg)
> >  	struct vm_area_struct *next = vmg->next;
> >  	struct vma_prepare vp;
> >
> > +	mmap_assert_write_locked(vmg->mm);
> > +
>
> There are a few unnecessary whitespaces here..

...except here :) I like to keep the asserts separate from the rest of the
logic, and local declarations on their own lines.

[snip]


  reply	other threads:[~2024-08-30 15:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 20:06 [PATCH v2 00/10] mm: remove vma_merge() Lorenzo Stoakes
2024-08-23 20:06 ` [PATCH v2 01/10] tools: improve vma test Makefile Lorenzo Stoakes
2024-08-28 19:16   ` Liam R. Howlett
2024-08-23 20:06 ` [PATCH v2 02/10] tools: add VMA merge tests Lorenzo Stoakes
2024-08-28 19:16   ` Liam R. Howlett
2024-08-23 20:06 ` [PATCH v2 03/10] mm: introduce vma_merge_struct and abstract vma_merge(),vma_modify() Lorenzo Stoakes
2024-08-28 19:35   ` Liam R. Howlett
2024-08-30 13:28     ` Lorenzo Stoakes
2024-08-23 20:06 ` [PATCH v2 04/10] mm: remove duplicated open-coded VMA policy check Lorenzo Stoakes
2024-08-28 19:42   ` Liam R. Howlett
2024-08-23 20:07 ` [PATCH v2 05/10] mm: abstract vma_expand() to use vma_merge_struct Lorenzo Stoakes
2024-08-28 20:03   ` Liam R. Howlett
2024-08-23 20:07 ` [PATCH v2 06/10] mm: avoid using vma_merge() for new VMAs Lorenzo Stoakes
2024-08-27 11:41   ` Lorenzo Stoakes
2024-08-28 20:52   ` Liam R. Howlett
2024-08-30 15:19     ` Lorenzo Stoakes [this message]
2024-08-29 19:46   ` Mark Brown
2024-08-29 21:22     ` Lorenzo Stoakes
2024-08-30 12:59       ` Mark Brown
2024-08-30 13:02         ` Lorenzo Stoakes
2024-08-30 13:05           ` Mark Brown
2024-08-30 13:10             ` Lorenzo Stoakes
2024-08-23 20:07 ` [PATCH v2 07/10] mm: make vma_prepare() and friends static and internal to vma.c Lorenzo Stoakes
2024-08-23 20:07 ` [PATCH v2 08/10] mm: introduce commit_merge(), abstracting final commit of merge Lorenzo Stoakes
2024-08-23 20:07 ` [PATCH v2 09/10] mm: refactor vma_merge() into modify-only vma_merge_existing_range() Lorenzo Stoakes
2024-08-23 20:07 ` [PATCH v2 10/10] mm: rework vm_ops->close() handling on VMA merge 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=5b641d45-3898-40c9-8288-f2aacae1400d@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --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