selftests/mm: add support for arm64 platform on va switch
authorChaitanya S Prakash <chaitanyas.prakash@arm.com>
Thu, 23 Mar 2023 10:52:39 +0000 (16:22 +0530)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 18 Apr 2023 23:53:51 +0000 (16:53 -0700)
Patch series "selftests/mm: Implement support for arm64 on va".

The va_128TBswitch selftest is designed and implemented for PowerPC and
x86 architectures which support a 128TB switch, up to 256TB of virtual
address space and hugepage sizes of 16MB and 2MB respectively.  Arm64
platforms on the other hand support a 256Tb switch, up to 4PB of virtual
address space and a default hugepage size of 512MB when 64k pagesize is
enabled.

These architectural differences require introducing support for arm64
platforms, after which a more generic naming convention is suggested.  The
in code comments are amended to provide a more platform independent
explanation of the working of the code and nr_hugepages are configured as
required.  Finally, the file running the testcase is modified in order to
prevent skipping of hugetlb testcases of va_high_addr_switch.

This patch (of 5):

Arm64 platforms have the ability to support 64kb pagesize, 512MB default
hugepage size and up to 4PB of virtual address space.  The address switch
occurs at 256TB as opposed to 128TB.  Hence, the necessary support has
been added.

Link: https://lkml.kernel.org/r/20230323105243.2807166-1-chaitanyas.prakash@arm.com
Link: https://lkml.kernel.org/r/20230323105243.2807166-2-chaitanyas.prakash@arm.com
Signed-off-by: Chaitanya S Prakash <chaitanyas.prakash@arm.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/va_128TBswitch.c

index 1d206898988396dfeac14748f7c0d1e74d4318d3..6679213effed0dc6b8485b90d924e3d631f96b24 100644 (file)
  * This will work with 16M and 2M hugepage size
  */
 #define HUGETLB_SIZE   (16 << 20)
+#elif __aarch64__
+/*
+ * The default hugepage size for 64k base pagesize
+ * is 512MB.
+ */
+#define PAGE_SIZE      (64 << 10)
+#define HUGETLB_SIZE   (512 << 20)
 #else
 #define PAGE_SIZE      (4 << 10)
 #define HUGETLB_SIZE   (2 << 20)
  * >= 128TB is the hint addr value we used to select
  * large address space.
  */
-#define ADDR_SWITCH_HINT (1UL << 47)
+
+#define ADDR_MARK_128TB        (1UL << 47)
+#define ADDR_MARK_256TB        (1UL << 48)
+
+#define HIGH_ADDR_128TB        ((void *) (1UL << 48))
+#define HIGH_ADDR_256TB        ((void *) (1UL << 49))
+
 #define LOW_ADDR       ((void *) (1UL << 30))
-#define HIGH_ADDR      ((void *) (1UL << 48))
+
+#ifdef __aarch64__
+#define ADDR_SWITCH_HINT ADDR_MARK_256TB
+#define HIGH_ADDR       HIGH_ADDR_256TB
+#else
+#define ADDR_SWITCH_HINT ADDR_MARK_128TB
+#define HIGH_ADDR       HIGH_ADDR_128TB
+#endif
 
 struct testcase {
        void *addr;
@@ -270,6 +290,8 @@ static int supported_arch(void)
        return 1;
 #elif defined(__x86_64__)
        return 1;
+#elif defined(__aarch64__)
+       return 1;
 #else
        return 0;
 #endif