linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <richard.weiyang@gmail.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	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>,
	David Hildenbrand <david@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	Rik van Riel <riel@surriel.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] tools/testing/selftests: assert that anon merge cases behave as expected
Date: Mon, 7 Apr 2025 12:09:48 +0000	[thread overview]
Message-ID: <20250407120948.zb5th45e6ehxpmrm@master> (raw)
In-Reply-To: <4a8a1163-a7f9-4368-98e1-f79b0411aac4@lucifer.local>

On Mon, Apr 07, 2025 at 12:02:00PM +0100, Lorenzo Stoakes wrote:
>I know you mean well Wei,
>
>But drive-by extremely pedantic review on minor details isn't really
>useful. I can't tell you not to do this, but I can at least ask. I don't
>think this is a great use of either of our time.
>
>Thanks.
>
[...]
>> >+
>> >+	/* unCOWing everything does not cause the AVC to go away. */
>>            ^^^
>>
>> Before ptr[i] = 'x', we have unCOWed pages in vma. What we are doing here is
>> COWing, right?
>
>Nope, it's the other way round, as commented. A 'CoW' page is one marked
>for copy-on-write right? we now make it just a normal mapping by writing to
>it.
>

Oh, I misunderstand the meaning of 'CoW' page. It is the page before copy. I
thought it is the page after. Sorry for bothering.

>>
>> >+	for (i = 0; i < 5 * page_size; i += page_size)
>> >+		ptr[i] = 'x';
>> >+
>> >+	/*
>> >+	 * Map in adjacent VMA in child.
>> >+	 *
>> >+	 *     forked
>> >+	 * |-----------|-----------|
>> >+	 * |  faulted  | unfaulted |
>> >+	 * |-----------|-----------|
>> >+	 *      ptr         ptr2
>> >+	 */
>> >+	ptr2 = mmap(&ptr[5 * page_size], 5 * page_size, PROT_READ | PROT_WRITE,
>> >+		   MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0);
>> >+	ASSERT_NE(ptr2, MAP_FAILED);
>> >+
>> >+	/* Make sure not merged. */
>> >+	ASSERT_TRUE(find_vma_procmap(procmap, ptr));
>> >+	ASSERT_EQ(procmap->query.vma_start, (unsigned long)ptr);
>> >+	ASSERT_EQ(procmap->query.vma_end, (unsigned long)ptr + 5 * page_size);
>> >+}
>> >+
>> >+TEST_F(merge, forked_source_vma)
>> >+{
>> >+	unsigned int page_size = self->page_size;
>> >+	char *carveout = self->carveout;
>> >+	struct procmap_fd *procmap = &self->procmap;
>> >+	pid_t pid;
>> >+	char *ptr, *ptr2;
>> >+	int i;
>> >+
>> >+	/*
>> >+	 * |............|-----------|
>> >+	 * | <unmapped> | unfaulted |
>> >+	 * |............|-----------|
>>
>> I am not sure "unmapped" is correct here. The range has already been mapped by
>> FIXTURE_SETUP(merge).
>
>This is pointless and actually misleading pedantry.
>
>For the purposes of what we are doing here, this is unmapped. Do you truly
>think mentioning a PROT_NONE mapping here would be useful, meaningful, or
>add anything but noise?
>
>>
>> >+	 */
>> >+	ptr = mmap(&carveout[page_size], 5 * page_size, PROT_READ | PROT_WRITE,
>> >+		   MAP_ANON | MAP_PRIVATE | MAP_FIXED | MAP_NORESERVE, -1, 0);
>> >+	ASSERT_NE(ptr, MAP_FAILED);
>> >+
>> >+	/*
>> >+	 * Fault in process.
>> >+	 *
>> >+	 * |............||-----------|
>> >+	 * | <unmapped> ||  faulted  |
>> >+	 * |............||-----------|
>>                          ^
>>
>> Extra line here?
>
>Eh? I don't understand what you mean... you mean an extra '-'? This is to
>fit both unfaulted/faulted in the same size SACII 'VMA', a convention I've
>kept (hopefully) consistently...
>

Sounds the character format is corrupted.

The extra line I meant is "||" between unmapped and faulted area. Well it is
trivial, just forget it.

-- 
Wei Yang
Help you, Help me


  reply	other threads:[~2025-04-07 12:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17 21:15 [PATCH 0/3] fix incorrectly disallowed anonymous VMA merges Lorenzo Stoakes
2025-03-17 21:15 ` [PATCH 1/3] mm/vma: " Lorenzo Stoakes
2025-04-04 12:53   ` Wei Yang
2025-04-04 13:04     ` Lorenzo Stoakes
2025-04-04 23:32       ` Wei Yang
2025-04-07 10:24         ` Lorenzo Stoakes
2025-04-07 16:44           ` Lorenzo Stoakes
2025-03-17 21:15 ` [PATCH 2/3] tools/testing: add PROCMAP_QUERY helper functions in mm self tests Lorenzo Stoakes
2025-03-18 15:18   ` Lorenzo Stoakes
2025-04-07  2:42   ` Wei Yang
2025-03-17 21:15 ` [PATCH 3/3] tools/testing/selftests: assert that anon merge cases behave as expected Lorenzo Stoakes
2025-04-07  2:54   ` Wei Yang
2025-04-07 11:02     ` Lorenzo Stoakes
2025-04-07 12:09       ` Wei Yang [this message]
2025-03-20 13:33 ` [PATCH 0/3] fix incorrectly disallowed anonymous VMA merges Yeoreum Yun

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=20250407120948.zb5th45e6ehxpmrm@master \
    --to=richard.weiyang@gmail.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=lorenzo.stoakes@oracle.com \
    --cc=riel@surriel.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