[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250407120948.zb5th45e6ehxpmrm@master>
Date: Mon, 7 Apr 2025 12:09:48 +0000
From: Wei Yang <richard.weiyang@...il.com>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Cc: Wei Yang <richard.weiyang@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>,
"Liam R . Howlett" <Liam.Howlett@...cle.com>,
Suren Baghdasaryan <surenb@...gle.com>,
David Hildenbrand <david@...hat.com>,
Matthew Wilcox <willy@...radead.org>,
Rik van Riel <riel@...riel.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] tools/testing/selftests: assert that anon merge
cases behave as expected
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
Powered by blists - more mailing lists