linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm/cow: Modify the incorrect checking parameters
@ 2025-01-13  3:28 Hao Ge
  2025-01-13  4:26 ` Anshuman Khandual
  0 siblings, 1 reply; 6+ messages in thread
From: Hao Ge @ 2025-01-13  3:28 UTC (permalink / raw)
  To: akpm, shuah; +Cc: sj, linux-mm, linux-kselftest, linux-kernel, hao.ge, Hao Ge

From: Hao Ge <gehao@kylinos.cn>

In the run_with_memfd_hugetlb function, some error handle
have passed incorrect parameters.
It should be "smem", but it was mistakenly written as "mem".

Let's fix it.

Fixes: baa489fabd01 ("selftests/vm: rename selftests/vm to selftests/mm")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
 tools/testing/selftests/mm/cow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
index 32c6ccc2a6be..7a89680d1566 100644
--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -1684,7 +1684,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
 		goto close;
 	}
 	smem = mmap(NULL, hugetlbsize, PROT_READ, MAP_SHARED, fd, 0);
-	if (mem == MAP_FAILED) {
+	if (smem == MAP_FAILED) {
 		ksft_test_result_fail("mmap() failed\n");
 		goto munmap;
 	}
@@ -1696,7 +1696,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
 	fn(mem, smem, hugetlbsize);
 munmap:
 	munmap(mem, hugetlbsize);
-	if (mem != MAP_FAILED)
+	if (smem != MAP_FAILED)
 		munmap(smem, hugetlbsize);
 close:
 	close(fd);
-- 
2.25.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests/mm/cow: Modify the incorrect checking parameters
  2025-01-13  3:28 [PATCH] selftests/mm/cow: Modify the incorrect checking parameters Hao Ge
@ 2025-01-13  4:26 ` Anshuman Khandual
  2025-01-13  4:59   ` Hao Ge
  0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2025-01-13  4:26 UTC (permalink / raw)
  To: Hao Ge, akpm, shuah; +Cc: sj, linux-mm, linux-kselftest, linux-kernel, Hao Ge

Hello Hao,

On 1/13/25 08:58, Hao Ge wrote:
> From: Hao Ge <gehao@kylinos.cn>
> 
> In the run_with_memfd_hugetlb function, some error handle
> have passed incorrect parameters.
> It should be "smem", but it was mistakenly written as "mem".

I guess there are couple of more instances where the returned address
'smem' is not getting tested for MAP_FAILED. Hence the commit message
here needs to be bit more generic rather than run_with_memfd_hugetlb()
specific.

--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -1482,7 +1482,7 @@ static void run_with_zeropage(non_anon_test_fn fn, const char *desc)
        }
 
        smem = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
-       if (mem == MAP_FAILED) {
+       if (smem == MAP_FAILED) {
                ksft_test_result_fail("mmap() failed\n");
                goto munmap;
        }
@@ -1583,7 +1583,7 @@ static void run_with_memfd(non_anon_test_fn fn, const char *desc)
                goto close;
        }
        smem = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fd, 0);
-       if (mem == MAP_FAILED) {
+       if (smem == MAP_FAILED) {
                ksft_test_result_fail("mmap() failed\n");
                goto munmap;
        }


> 
> Let's fix it.
> 
> Fixes: baa489fabd01 ("selftests/vm: rename selftests/vm to selftests/mm")

This commit just renamed the directory from vm/ to mm/ directory. The following
commit introduced the problem instead. Please update the Fixes: tag as required.

f8664f3c4a08f799 ("selftests/vm: cow: basic COW tests for non-anonymous pages")

> Signed-off-by: Hao Ge <gehao@kylinos.cn>
> ---
>  tools/testing/selftests/mm/cow.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
> index 32c6ccc2a6be..7a89680d1566 100644
> --- a/tools/testing/selftests/mm/cow.c
> +++ b/tools/testing/selftests/mm/cow.c
> @@ -1684,7 +1684,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
>  		goto close;
>  	}
>  	smem = mmap(NULL, hugetlbsize, PROT_READ, MAP_SHARED, fd, 0);
> -	if (mem == MAP_FAILED) {
> +	if (smem == MAP_FAILED) {
>  		ksft_test_result_fail("mmap() failed\n");
>  		goto munmap;
>  	}
> @@ -1696,7 +1696,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
>  	fn(mem, smem, hugetlbsize);
>  munmap:
>  	munmap(mem, hugetlbsize);
> -	if (mem != MAP_FAILED)
> +	if (smem != MAP_FAILED)
>  		munmap(smem, hugetlbsize);
>  close:
>  	close(fd);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests/mm/cow: Modify the incorrect checking parameters
  2025-01-13  4:26 ` Anshuman Khandual
@ 2025-01-13  4:59   ` Hao Ge
  2025-01-13  5:09     ` [PATCH v2] " Hao Ge
  0 siblings, 1 reply; 6+ messages in thread
From: Hao Ge @ 2025-01-13  4:59 UTC (permalink / raw)
  To: Anshuman Khandual, akpm, shuah
  Cc: sj, linux-mm, linux-kselftest, linux-kernel, Hao Ge

Hi Anshuman


Thanks for your revirew.


On 2025/1/13 12:26, Anshuman Khandual wrote:
> Hello Hao,
>
> On 1/13/25 08:58, Hao Ge wrote:
>> From: Hao Ge <gehao@kylinos.cn>
>>
>> In the run_with_memfd_hugetlb function, some error handle
>> have passed incorrect parameters.
>> It should be "smem", but it was mistakenly written as "mem".
> I guess there are couple of more instances where the returned address
> 'smem' is not getting tested for MAP_FAILED. Hence the commit message
> here needs to be bit more generic rather than run_with_memfd_hugetlb()
> specific.


Thank you for bringing it to my attention. Upon reviewing, I confirm 
that you are correct.


>
> --- a/tools/testing/selftests/mm/cow.c
> +++ b/tools/testing/selftests/mm/cow.c
> @@ -1482,7 +1482,7 @@ static void run_with_zeropage(non_anon_test_fn fn, const char *desc)
>          }
>   
>          smem = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
> -       if (mem == MAP_FAILED) {
> +       if (smem == MAP_FAILED) {
>                  ksft_test_result_fail("mmap() failed\n");
>                  goto munmap;
>          }
> @@ -1583,7 +1583,7 @@ static void run_with_memfd(non_anon_test_fn fn, const char *desc)
>                  goto close;
>          }
>          smem = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fd, 0);
> -       if (mem == MAP_FAILED) {
> +       if (smem == MAP_FAILED) {
>                  ksft_test_result_fail("mmap() failed\n");
>                  goto munmap;
>          }
>
>
>> Let's fix it.
>>
>> Fixes: baa489fabd01 ("selftests/vm: rename selftests/vm to selftests/mm")
> This commit just renamed the directory from vm/ to mm/ directory. The following
> commit introduced the problem instead. Please update the Fixes: tag as required.
>
> f8664f3c4a08f799 ("selftests/vm: cow: basic COW tests for non-anonymous pages")


Yes, I accidentally copied the wrong information. I will resend a v2  to 
address these issues. Thank you very much


Thanks

Best Regards

Hao


>> Signed-off-by: Hao Ge <gehao@kylinos.cn>
>> ---
>>   tools/testing/selftests/mm/cow.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
>> index 32c6ccc2a6be..7a89680d1566 100644
>> --- a/tools/testing/selftests/mm/cow.c
>> +++ b/tools/testing/selftests/mm/cow.c
>> @@ -1684,7 +1684,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
>>   		goto close;
>>   	}
>>   	smem = mmap(NULL, hugetlbsize, PROT_READ, MAP_SHARED, fd, 0);
>> -	if (mem == MAP_FAILED) {
>> +	if (smem == MAP_FAILED) {
>>   		ksft_test_result_fail("mmap() failed\n");
>>   		goto munmap;
>>   	}
>> @@ -1696,7 +1696,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
>>   	fn(mem, smem, hugetlbsize);
>>   munmap:
>>   	munmap(mem, hugetlbsize);
>> -	if (mem != MAP_FAILED)
>> +	if (smem != MAP_FAILED)
>>   		munmap(smem, hugetlbsize);
>>   close:
>>   	close(fd);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] selftests/mm/cow: Modify the incorrect checking parameters
  2025-01-13  4:59   ` Hao Ge
@ 2025-01-13  5:09     ` Hao Ge
  2025-01-13  5:55       ` Anshuman Khandual
  2025-01-13  6:02       ` Dev Jain
  0 siblings, 2 replies; 6+ messages in thread
From: Hao Ge @ 2025-01-13  5:09 UTC (permalink / raw)
  To: akpm, shuah; +Cc: sj, linux-mm, linux-kselftest, linux-kernel, hao.ge, Hao Ge

From: Hao Ge <gehao@kylinos.cn>

In the cow.c,some error handle have passed incorrect
parameters. It should be "smem", but it was mistakenly
written as "mem".

Let's fix it.

Fixes: f8664f3c4a08 ("selftests/vm: cow: basic COW tests for non-anonymous pages")
Signed-off-by: Hao Ge <gehao@kylinos.cn>
---
v2: Anshuman pointed out that the error is not limited to the run_with_memfd_hugetlb function;
    there are other places where it occurs as well.
    Therefore, let's fix it all together.
    Similarly, Update the Fix tag to be accurate.
---
 tools/testing/selftests/mm/cow.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
index 32c6ccc2a6be..c52c93996ba1 100644
--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -1482,7 +1482,7 @@ static void run_with_zeropage(non_anon_test_fn fn, const char *desc)
 	}
 
 	smem = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
-	if (mem == MAP_FAILED) {
+	if (smem == MAP_FAILED) {
 		ksft_test_result_fail("mmap() failed\n");
 		goto munmap;
 	}
@@ -1583,7 +1583,7 @@ static void run_with_memfd(non_anon_test_fn fn, const char *desc)
 		goto close;
 	}
 	smem = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fd, 0);
-	if (mem == MAP_FAILED) {
+	if (smem == MAP_FAILED) {
 		ksft_test_result_fail("mmap() failed\n");
 		goto munmap;
 	}
@@ -1634,7 +1634,7 @@ static void run_with_tmpfile(non_anon_test_fn fn, const char *desc)
 		goto close;
 	}
 	smem = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fd, 0);
-	if (mem == MAP_FAILED) {
+	if (smem == MAP_FAILED) {
 		ksft_test_result_fail("mmap() failed\n");
 		goto munmap;
 	}
@@ -1684,7 +1684,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
 		goto close;
 	}
 	smem = mmap(NULL, hugetlbsize, PROT_READ, MAP_SHARED, fd, 0);
-	if (mem == MAP_FAILED) {
+	if (smem == MAP_FAILED) {
 		ksft_test_result_fail("mmap() failed\n");
 		goto munmap;
 	}
@@ -1696,7 +1696,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
 	fn(mem, smem, hugetlbsize);
 munmap:
 	munmap(mem, hugetlbsize);
-	if (mem != MAP_FAILED)
+	if (smem != MAP_FAILED)
 		munmap(smem, hugetlbsize);
 close:
 	close(fd);
-- 
2.25.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] selftests/mm/cow: Modify the incorrect checking parameters
  2025-01-13  5:09     ` [PATCH v2] " Hao Ge
@ 2025-01-13  5:55       ` Anshuman Khandual
  2025-01-13  6:02       ` Dev Jain
  1 sibling, 0 replies; 6+ messages in thread
From: Anshuman Khandual @ 2025-01-13  5:55 UTC (permalink / raw)
  To: Hao Ge, akpm, shuah; +Cc: sj, linux-mm, linux-kselftest, linux-kernel, Hao Ge

A small nit.

Please always send a new patch version separately as a new email
thread instead - not part of an ongoing discussion.

On 1/13/25 10:39, Hao Ge wrote:
> From: Hao Ge <gehao@kylinos.cn>
> 
> In the cow.c,some error handle have passed incorrect
> parameters. It should be "smem", but it was mistakenly
> written as "mem".
> 
> Let's fix it.
> 
> Fixes: f8664f3c4a08 ("selftests/vm: cow: basic COW tests for non-anonymous pages")
> Signed-off-by: Hao Ge <gehao@kylinos.cn>
> ---
> v2: Anshuman pointed out that the error is not limited to the run_with_memfd_hugetlb function;
>     there are other places where it occurs as well.
>     Therefore, let's fix it all together.
>     Similarly, Update the Fix tag to be accurate.

LGTM

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>

> ---
>  tools/testing/selftests/mm/cow.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
> index 32c6ccc2a6be..c52c93996ba1 100644
> --- a/tools/testing/selftests/mm/cow.c
> +++ b/tools/testing/selftests/mm/cow.c
> @@ -1482,7 +1482,7 @@ static void run_with_zeropage(non_anon_test_fn fn, const char *desc)
>  	}
>  
>  	smem = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
> -	if (mem == MAP_FAILED) {
> +	if (smem == MAP_FAILED) {
>  		ksft_test_result_fail("mmap() failed\n");
>  		goto munmap;
>  	}
> @@ -1583,7 +1583,7 @@ static void run_with_memfd(non_anon_test_fn fn, const char *desc)
>  		goto close;
>  	}
>  	smem = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fd, 0);
> -	if (mem == MAP_FAILED) {
> +	if (smem == MAP_FAILED) {
>  		ksft_test_result_fail("mmap() failed\n");
>  		goto munmap;
>  	}
> @@ -1634,7 +1634,7 @@ static void run_with_tmpfile(non_anon_test_fn fn, const char *desc)
>  		goto close;
>  	}
>  	smem = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fd, 0);
> -	if (mem == MAP_FAILED) {
> +	if (smem == MAP_FAILED) {
>  		ksft_test_result_fail("mmap() failed\n");
>  		goto munmap;
>  	}
> @@ -1684,7 +1684,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
>  		goto close;
>  	}
>  	smem = mmap(NULL, hugetlbsize, PROT_READ, MAP_SHARED, fd, 0);
> -	if (mem == MAP_FAILED) {
> +	if (smem == MAP_FAILED) {
>  		ksft_test_result_fail("mmap() failed\n");
>  		goto munmap;
>  	}
> @@ -1696,7 +1696,7 @@ static void run_with_memfd_hugetlb(non_anon_test_fn fn, const char *desc,
>  	fn(mem, smem, hugetlbsize);
>  munmap:
>  	munmap(mem, hugetlbsize);
> -	if (mem != MAP_FAILED)
> +	if (smem != MAP_FAILED)
>  		munmap(smem, hugetlbsize);
>  close:
>  	close(fd);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] selftests/mm/cow: Modify the incorrect checking parameters
  2025-01-13  5:09     ` [PATCH v2] " Hao Ge
  2025-01-13  5:55       ` Anshuman Khandual
@ 2025-01-13  6:02       ` Dev Jain
  1 sibling, 0 replies; 6+ messages in thread
From: Dev Jain @ 2025-01-13  6:02 UTC (permalink / raw)
  To: Hao Ge, akpm, shuah; +Cc: sj, linux-mm, linux-kselftest, linux-kernel, Hao Ge



On 13/01/25 10:39 am, Hao Ge wrote:
> From: Hao Ge <gehao@kylinos.cn>
> 
> In the cow.c,some error handle have passed incorrect
> parameters. It should be "smem", but it was mistakenly
> written as "mem".
> 
> Let's fix it.
> 
> Fixes: f8664f3c4a08 ("selftests/vm: cow: basic COW tests for non-anonymous pages")
> Signed-off-by: Hao Ge <gehao@kylinos.cn>
> ---

You should also CC the person whose code you are changing, in this case, 
David Hildenbrand.

Reviewed-by: Dev Jain <dev.jain@arm.com>



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-01-13  6:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-13  3:28 [PATCH] selftests/mm/cow: Modify the incorrect checking parameters Hao Ge
2025-01-13  4:26 ` Anshuman Khandual
2025-01-13  4:59   ` Hao Ge
2025-01-13  5:09     ` [PATCH v2] " Hao Ge
2025-01-13  5:55       ` Anshuman Khandual
2025-01-13  6:02       ` Dev Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox