selftests/mm: skip soft-dirty tests on arm64
authorRyan Roberts <ryan.roberts@arm.com>
Mon, 24 Jul 2023 08:25:16 +0000 (09:25 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 18 Aug 2023 17:12:42 +0000 (10:12 -0700)
arm64 does not support the soft-dirty PTE bit.  However, the `soft-dirty`
test suite is currently run unconditionally and therefore generates
spurious test failures on arm64.  There are also some tests in
`madv_populate` which assume it is supported.

For `soft-dirty` lets disable the whole suite for arm64; it is no longer
built and run_vmtests.sh will skip it if its not present.

For `madv_populate`, we need a runtime mechanism so that the remaining
tests continue to be run.  Unfortunately, the only way to determine if the
soft-dirty dirty bit is supported is to write to a page, then see if the
bit is set in /proc/self/pagemap.  But the tests that we want to
conditionally execute are testing precicesly this.  So if we introduced
this feature check, we could accedentally turn a real failure (on a system
that claims to support soft-dirty) into a skip.  So instead, do the check
based on architecture; for arm64, we report that soft-dirty is not
supported.

Link: https://lkml.kernel.org/r/20230724082522.1202616-3-ryan.roberts@arm.com
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Florent Revest <revest@chromium.org>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/Makefile
tools/testing/selftests/mm/madv_populate.c
tools/testing/selftests/mm/run_vmtests.sh

index b7fce9073279ef8313be5b841d77e8128e4f9e0f..f35977a2bbf3fe9679cd64c1d1b8ee8e06e93a4d 100644 (file)
@@ -64,12 +64,15 @@ TEST_GEN_PROGS += thuge-gen
 TEST_GEN_PROGS += transhuge-stress
 TEST_GEN_PROGS += uffd-stress
 TEST_GEN_PROGS += uffd-unit-tests
-TEST_GEN_PROGS += soft-dirty
 TEST_GEN_PROGS += split_huge_page_test
 TEST_GEN_PROGS += ksm_tests
 TEST_GEN_PROGS += ksm_functional_tests
 TEST_GEN_PROGS += mdwe_test
 
+ifneq ($(ARCH),arm64)
+TEST_GEN_PROGS += soft-dirty
+endif
+
 ifeq ($(ARCH),x86_64)
 CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32)
 CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c)
index 60547245e479b1517f83adb30360c64728036899..17bcb07f19f3491b074e32442b47ec0ddff29278 100644 (file)
@@ -264,14 +264,35 @@ static void test_softdirty(void)
        munmap(addr, SIZE);
 }
 
+static int system_has_softdirty(void)
+{
+       /*
+        * There is no way to check if the kernel supports soft-dirty, other
+        * than by writing to a page and seeing if the bit was set. But the
+        * tests are intended to check that the bit gets set when it should, so
+        * doing that check would turn a potentially legitimate fail into a
+        * skip. Fortunately, we know for sure that arm64 does not support
+        * soft-dirty. So for now, let's just use the arch as a corse guide.
+        */
+#if defined(__aarch64__)
+       return 0;
+#else
+       return 1;
+#endif
+}
+
 int main(int argc, char **argv)
 {
+       int nr_tests = 16;
        int err;
 
        pagesize = getpagesize();
 
+       if (system_has_softdirty())
+               nr_tests += 5;
+
        ksft_print_header();
-       ksft_set_plan(21);
+       ksft_set_plan(nr_tests);
 
        sense_support();
        test_prot_read();
@@ -279,7 +300,8 @@ int main(int argc, char **argv)
        test_holes();
        test_populate_read();
        test_populate_write();
-       test_softdirty();
+       if (system_has_softdirty())
+               test_softdirty();
 
        err = ksft_get_fail_cnt();
        if (err)
index 9666c0c171ab862295be73ca2aa62f0f0b67c776..4eaefc3d2e59adba413649b8de761d5c6a70eb82 100755 (executable)
@@ -322,7 +322,10 @@ then
        CATEGORY="pkey" run_test ./protection_keys_64
 fi
 
-CATEGORY="soft_dirty" run_test ./soft-dirty
+if [ -x ./soft-dirty ]
+then
+       CATEGORY="soft_dirty" run_test ./soft-dirty
+fi
 
 # COW tests
 CATEGORY="cow" run_test ./cow