Re: [PATCH V2] selftests/vm: Add tests to validate mirror functionality with mremap

From: Anshuman Khandual
Date: Wed Jul 26 2017 - 00:26:22 EST


On 07/25/2017 07:06 PM, Michal Hocko wrote:
> On Tue 25-07-17 12:06:57, Anshuman Khandual wrote:
> [...]
>> diff --git a/tools/testing/selftests/vm/mremap_mirror_private_anon.c b/tools/testing/selftests/vm/mremap_mirror_private_anon.c
> [...]
>> + ptr = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE,
>> + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>> + if (ptr == MAP_FAILED) {
>> + perror("map() failed");
>> + return -1;
>> + }
>> + memset(ptr, PATTERN, alloc_size);
>> +
>> + mirror_ptr = (char *) mremap(ptr, 0, alloc_size, MREMAP_MAYMOVE);
>> + if (mirror_ptr == MAP_FAILED) {
>> + perror("mremap() failed");
>> + return -1;
>> + }
>
> What is the point of this test? It will break with Mike's patch very
> soon. Btw. it never worked.

It works now. The new 'mirrored' buffer does not have same elements
as that of the original one. Yes, once Mike's patch is merged, it
will fail during the mremap() call itself IIUC. I can change this
test to verify that mremap() call failure then but now the mismatch
of elements between the buffers is what is expected and is happening.

But if you would like I can change the test to check for mremap()
failure in this case (which will fail in the current mainline but
will pass eventually when Mike's patch is in). Please do suggest.