linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: va_high_addr_switch: Do not skip test and give warning message post FEAT_LPA2
@ 2024-05-16  3:56 Dev Jain
  2024-05-19 23:48 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Dev Jain @ 2024-05-16  3:56 UTC (permalink / raw)
  To: akpm, shuah
  Cc: linux-mm, linux-kselftest, linux-kernel, Anshuman.Khandual,
	kirill.shutemov, AneeshKumar.KizhakeVeetil, Dev Jain

Post FEAT_LPA2, Aarch64 extends the 4KB and 16KB translation granule to
large virtual addresses. Currently, the test is being skipped for said
granule sizes, because the page sizes have been statically defined; to
work around that would mean breaking the nice array of structs used for
adding testcases. Instead, don't skip the test, and encourage the user
to manually change the macros.

Signed-off-by: Dev Jain <dev.jain@arm.com>
---
 .../testing/selftests/mm/va_high_addr_switch.c  | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/va_high_addr_switch.c b/tools/testing/selftests/mm/va_high_addr_switch.c
index cfbc501290d3..ba862f51d395 100644
--- a/tools/testing/selftests/mm/va_high_addr_switch.c
+++ b/tools/testing/selftests/mm/va_high_addr_switch.c
@@ -292,12 +292,24 @@ static int supported_arch(void)
 #elif defined(__x86_64__)
 	return 1;
 #elif defined(__aarch64__)
-	return getpagesize() == PAGE_SIZE;
+	return 1;
 #else
 	return 0;
 #endif
 }
 
+#if defined(__aarch64__)
+void failure_message(void)
+{
+	printf("TEST MAY FAIL: Are you running on a pagesize other than 64K?\n");
+	printf("If yes, please change macros manually. Ensure to change the\n");
+	printf("address macros too if running defconfig on 16K pagesize,\n");
+	printf("since userspace VA = 47 bits post FEAT_LPA2.\n");
+}
+#else
+void failure_message(void) {}
+#endif
+
 int main(int argc, char **argv)
 {
 	int ret;
@@ -308,5 +320,8 @@ int main(int argc, char **argv)
 	ret = run_test(testcases, ARRAY_SIZE(testcases));
 	if (argc == 2 && !strcmp(argv[1], "--run-hugetlb"))
 		ret = run_test(hugetlb_testcases, ARRAY_SIZE(hugetlb_testcases));
+
+	if (ret)
+		failure_message();
 	return ret;
 }
-- 
2.39.2



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

* Re: [PATCH] selftests/mm: va_high_addr_switch: Do not skip test and give warning message post FEAT_LPA2
  2024-05-16  3:56 [PATCH] selftests/mm: va_high_addr_switch: Do not skip test and give warning message post FEAT_LPA2 Dev Jain
@ 2024-05-19 23:48 ` Andrew Morton
  2024-05-21 12:52   ` Dev Jain
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2024-05-19 23:48 UTC (permalink / raw)
  To: Dev Jain
  Cc: shuah, linux-mm, linux-kselftest, linux-kernel, Anshuman.Khandual,
	kirill.shutemov, AneeshKumar.KizhakeVeetil

On Thu, 16 May 2024 09:26:33 +0530 Dev Jain <dev.jain@arm.com> wrote:

> Post FEAT_LPA2, Aarch64 extends the 4KB and 16KB translation granule to
> large virtual addresses. Currently, the test is being skipped for said
> granule sizes, because the page sizes have been statically defined; to
> work around that would mean breaking the nice array of structs used for
> adding testcases.

Which array is that?  testcases[]?  If so, we could keep if fairly nice
by doing the array population at runtime.  Something like:

static struct testcase *testcases;

static void init_thing()
{
	struct testcase t[] = {
		...
	};

	testcases = malloc(sizeof(t));
	memcpy(testcases, t, sizeof(t));
}
	
>  
> +#if defined(__aarch64__)
> +void failure_message(void)
> +{
> +	printf("TEST MAY FAIL: Are you running on a pagesize other than 64K?\n");
> +	printf("If yes, please change macros manually. Ensure to change the\n");
> +	printf("address macros too if running defconfig on 16K pagesize,\n");
> +	printf("since userspace VA = 47 bits post FEAT_LPA2.\n");
> +}
> +#else
> +void failure_message(void) {}
> +#endif
> +
>  int main(int argc, char **argv)
>  {
>  	int ret;
> @@ -308,5 +320,8 @@ int main(int argc, char **argv)
>  	ret = run_test(testcases, ARRAY_SIZE(testcases));
>  	if (argc == 2 && !strcmp(argv[1], "--run-hugetlb"))
>  		ret = run_test(hugetlb_testcases, ARRAY_SIZE(hugetlb_testcases));
> +
> +	if (ret)
> +		failure_message();
>  	return ret;
>  }

This seems rather lame :(.  It would be nice to fix this for once and
for all.



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

* Re: [PATCH] selftests/mm: va_high_addr_switch: Do not skip test and give warning message post FEAT_LPA2
  2024-05-19 23:48 ` Andrew Morton
@ 2024-05-21 12:52   ` Dev Jain
  0 siblings, 0 replies; 3+ messages in thread
From: Dev Jain @ 2024-05-21 12:52 UTC (permalink / raw)
  To: Andrew Morton
  Cc: shuah, linux-mm, linux-kselftest, linux-kernel, Anshuman.Khandual,
	kirill.shutemov, AneeshKumar.KizhakeVeetil


On 5/20/24 05:18, Andrew Morton wrote:
> On Thu, 16 May 2024 09:26:33 +0530 Dev Jain <dev.jain@arm.com> wrote:
>
>> Post FEAT_LPA2, Aarch64 extends the 4KB and 16KB translation granule to
>> large virtual addresses. Currently, the test is being skipped for said
>> granule sizes, because the page sizes have been statically defined; to
>> work around that would mean breaking the nice array of structs used for
>> adding testcases.
> Which array is that?  testcases[]?  If so, we could keep if fairly nice
> by doing the array population at runtime.  Something like:
>
> static struct testcase *testcases;
>
> static void init_thing()
> {
> 	struct testcase t[] = {
> 		...
> 	};
>
> 	testcases = malloc(sizeof(t));
> 	memcpy(testcases, t, sizeof(t));
> }


Great idea! This should work. I shall implement it.



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

end of thread, other threads:[~2024-05-21 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-16  3:56 [PATCH] selftests/mm: va_high_addr_switch: Do not skip test and give warning message post FEAT_LPA2 Dev Jain
2024-05-19 23:48 ` Andrew Morton
2024-05-21 12:52   ` Dev Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).