linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Wei Yang <richard.weiyang@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	Suren Baghdasaryan <surenb@google.com>,
	Matthew Wilcox <willy@infradead.org>,
	David Hildenbrand <david@redhat.com>,
	Pedro Falcato <pfalcato@suse.de>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 01/10] mm/mremap: introduce more mergeable mremap via MREMAP_RELOCATE_ANON
Date: Sat, 3 May 2025 18:50:19 +0100	[thread overview]
Message-ID: <5b8fdef2-c605-475f-9673-f42328db7128@lucifer.local> (raw)
In-Reply-To: <dd10778d-3721-44da-8c7d-10d94378777f@lucifer.local>

On Sat, May 03, 2025 at 03:29:08PM +0100, Lorenzo Stoakes wrote:
> OK have dug into this some more with a drgn script to read actual kernel
> metadata state and it's simpler than I thought - the root anon_vma is
> self-childed, but descendent anon_vma's are not.
>
> We can correct this with a anon_vma->root == anon_vma check. I believe
> we're probably safe with anon_vma reuse, because in that instance the
> anon_vma would not be mapped a shared folio.
>
> However, to be safe, I will check this, and I as I said previously, I will
> add a number of tests explicitly tested forking scenarios.
>
> The respin should have this fully addressed.
>
> Thanks, Lorenzo

Note that in practice, this wouldn't have broken anything, as in this case you
would _have_ to have parent anon_vma's.

The root will hang around even if all VMA's unmapped also, we only clear down
anon_vma's once no references from the anon_vma exist, and by nature everything
below the root must reference it.

But the function is misleading as-is so needs fixing.

As for anon_vma re-use - this is not permitted for root anon_vma's so naturally
it requires a parented anon_vma, which again implies AVC's which the uncowed
parent check would pick up.

Additionally, the reuse implies that the folio is not mapped within the process
that first created the anon_vma, and thus the num_children counts remain correct
across the board.

See https://pastebin.com/raw/q6wzUMLi for a detailed diagram of both scenarios
with anon_vma parameters and linking derived from real-world kernel values
obtained via drgn.

These will form part of the added tests.

Cheers, Lorenzo


  reply	other threads:[~2025-05-03 17:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22  8:09 [RFC PATCH v2 00/10] " Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 01/10] " Lorenzo Stoakes
2025-04-30  0:47   ` Wei Yang
2025-04-30 12:50     ` Vlastimil Babka
2025-04-30 13:15     ` Lorenzo Stoakes
2025-04-30 15:41       ` Wei Yang
2025-04-30 16:07         ` Lorenzo Stoakes
2025-05-01  1:18           ` Wei Yang
2025-05-01  9:27             ` Lorenzo Stoakes
2025-05-01 14:35               ` Wei Yang
2025-05-01 14:38                 ` Lorenzo Stoakes
2025-05-03 14:29                   ` Lorenzo Stoakes
2025-05-03 17:50                     ` Lorenzo Stoakes [this message]
2025-04-22  8:09 ` [RFC PATCH v2 02/10] mm/mremap: add MREMAP_MUST_RELOCATE_ANON Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 03/10] mm/mremap: add MREMAP[_MUST]_RELOCATE_ANON support for large folios Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 04/10] tools UAPI: Update copy of linux/mman.h from the kernel sources Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 05/10] tools/testing/selftests: add sys_mremap() helper to vm_util.h Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 06/10] tools/testing/selftests: add mremap() cases that merge normally Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 07/10] tools/testing/selftests: add MREMAP_RELOCATE_ANON merge test cases Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 08/10] tools/testing/selftests: expand mremap() tests for MREMAP_RELOCATE_ANON Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 09/10] tools/testing/selftests: have CoW self test use MREMAP_RELOCATE_ANON Lorenzo Stoakes
2025-04-22  8:09 ` [RFC PATCH v2 10/10] tools/testing/selftests: test relocate anon in split huge page test 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=5b8fdef2-c605-475f-9673-f42328db7128@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pfalcato@suse.de \
    --cc=richard.weiyang@gmail.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.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