linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/5] mm: simplify vma merge structure and expand comments
Date: Tue, 28 Jan 2025 12:38:48 +0100	[thread overview]
Message-ID: <86bed9d6-299f-4e28-8cb3-c60a5df78493@suse.cz> (raw)
In-Reply-To: <a878b5817f50e252553e124a20cc89c769eb887e.1737929364.git.lorenzo.stoakes@oracle.com>

On 1/27/25 16:50, Lorenzo Stoakes wrote:
> The merge code, while much improved, still has a number of points of
> confusion. As part of a broader series cleaning this up to make this more
> maintainable, we start by addressing some confusion around vma_merge_struct
> fields.
> 
> So far, the caller either provides no vmg->vma (a new VMA) or supplies the
> existing VMA which is being altered, setting vmg->start,end,pgoff to the
> proposed VMA dimensions.
> 
> vmg->vma is then updated, as are vmg->start,end,pgoff as the merge process
> proceeds and the appropriate merge strategy is determined.
> 
> This is rather confusing, as vmg->vma starts off as the 'middle' VMA
> between vmg->prev,next, but becomes the 'target' VMA, except in one
> specific edge case (merge next, shrink middle).
> 
> Int his patch we introduce vmg->middle to describe the VMA that is between
> vmg->prev and vmg->next, and does NOT change during the merge operation.
> 
> We replace vmg->vma with vmg->target, and use this only during the merge
> operation itself.

Yeah that's much better.

> Aside from the merge right, shrink middle case, this becomes the VMA that
> forms the basis of the VMA that is returned. This edge case can be
> addressed in a future commit.
> 
> We also add a number of comments to explain what is going on.
> 
> Finally, we adjust the ASCII diagrams showing each merge case in
> vma_merge_existing_range() to be clearer - the arrow range previously
> showed the vmg->start, end spanned area, but it is clearer to change this
> to show the final merged VMA.
> 
> This patch has no change in functional behaviour.
> 
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

Reviewed-by: Vlastimil Babka <vbabka@suse.cz>

> --- a/mm/vma.h
> +++ b/mm/vma.h
> @@ -69,16 +69,48 @@ enum vma_merge_flags {
>  	VMG_FLAG_JUST_EXPAND = 1 << 0,
>  };
>  
> -/* Represents a VMA merge operation. */
> +/*
> + * Describes a VMA merge operation and is threaded throughout it.
> + *
> + * Any of the fields may be mutated by the merge operation, so no guarantees are
> + * made to the contents of this structure after a merge operation has completed.
> + */

Well this patch seems like a step in the direction to limit what's mutated,
and perhaps defining some of the guarantees (via const?) could be then possible?

>  struct vma_merge_struct {
>  	struct mm_struct *mm;
>  	struct vma_iterator *vmi;
> -	pgoff_t pgoff;
> +	/*
> +	 * Adjacent VMAs, any of which may be NULL if not present:
> +	 *
> +	 * |------|--------|------|
> +	 * | prev | middle | next |
> +	 * |------|--------|------|
> +	 *
> +	 * middle may not yet exist in the case of a proposed new VMA being
> +	 * merged, or it may be an existing VMA.
> +	 *
> +	 * next may be assigned by the caller.

Caller of what?




  reply	other threads:[~2025-01-28 11:39 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-27 15:50 [PATCH 0/5] mm: further simplify VMA merge operation Lorenzo Stoakes
2025-01-27 15:50 ` [PATCH 1/5] mm: simplify vma merge structure and expand comments Lorenzo Stoakes
2025-01-28 11:38   ` Vlastimil Babka [this message]
2025-01-28 14:05     ` Lorenzo Stoakes
2025-01-27 15:50 ` [PATCH 2/5] mm: further refactor commit_merge() Lorenzo Stoakes
2025-01-28 15:05   ` Vlastimil Babka
2025-01-28 15:45   ` Vlastimil Babka
2025-01-28 16:07     ` Lorenzo Stoakes
2025-01-28 16:42       ` Lorenzo Stoakes
2025-01-27 15:50 ` [PATCH 3/5] mm: eliminate adj_start parameter from commit_merge() Lorenzo Stoakes
2025-01-29 14:13   ` Vlastimil Babka
2025-01-29 14:19     ` Lorenzo Stoakes
2025-01-27 15:50 ` [PATCH 4/5] mm: make vmg->target consistent and further simplify commit_merge() Lorenzo Stoakes
2025-01-29 14:45   ` Vlastimil Babka
2025-01-29 14:51     ` Lorenzo Stoakes
2025-01-29 15:19   ` Vlastimil Babka
2025-01-29 15:30     ` Lorenzo Stoakes
2025-01-27 15:50 ` [PATCH 5/5] mm: completely abstract unnecessary adj_start calculation Lorenzo Stoakes
2025-01-27 18:50   ` kernel test robot
2025-01-27 18:56     ` Lorenzo Stoakes
2025-01-27 19:58     ` Lorenzo Stoakes
2025-01-27 20:13   ` kernel test robot
2025-01-27 20:35   ` kernel test robot
2025-01-28  7:54   ` kernel test robot
2025-01-29 15:42   ` Vlastimil Babka
2025-01-29 16:19     ` 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=86bed9d6-299f-4e28-8cb3-c60a5df78493@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 \
    /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