linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: "Andrew Morton" <akpm@linux-foundation.org>,
	"Shuah Khan" <shuah@kernel.org>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Mark Brown" <broonie@kernel.org>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Florent Revest" <revest@chromium.org>,
	"Peter Xu" <peterx@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org
Subject: [PATCH v2 2/8] selftests/mm: Skip soft-dirty tests on arm64
Date: Mon, 17 Jul 2023 11:31:46 +0100	[thread overview]
Message-ID: <20230717103152.202078-3-ryan.roberts@arm.com> (raw)
In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com>

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.

Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---
 tools/testing/selftests/mm/Makefile        |  5 ++++-
 tools/testing/selftests/mm/madv_populate.c | 26 ++++++++++++++++++++--
 tools/testing/selftests/mm/run_vmtests.sh  |  5 ++++-
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile
index 66d7c07dc177..3514697fc2db 100644
--- a/tools/testing/selftests/mm/Makefile
+++ b/tools/testing/selftests/mm/Makefile
@@ -63,12 +63,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)
diff --git a/tools/testing/selftests/mm/madv_populate.c b/tools/testing/selftests/mm/madv_populate.c
index 60547245e479..17bcb07f19f3 100644
--- a/tools/testing/selftests/mm/madv_populate.c
+++ b/tools/testing/selftests/mm/madv_populate.c
@@ -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)
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 3f26f6e15b2a..9e4338aa5e09 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -290,7 +290,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
-- 
2.25.1



  parent reply	other threads:[~2023-07-17 10:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 10:31 [PATCH v2 0/8] selftests/mm fixes for arm64 Ryan Roberts
2023-07-17 10:31 ` [PATCH v2 1/8] selftests: Line buffer test program's stdout Ryan Roberts
2023-07-17 17:22   ` Mark Brown
2023-07-17 10:31 ` Ryan Roberts [this message]
2023-07-17 17:20   ` [PATCH v2 2/8] selftests/mm: Skip soft-dirty tests on arm64 David Hildenbrand
2023-07-17 10:31 ` [PATCH v2 3/8] selftests/mm: Enable mrelease_test for arm64 Ryan Roberts
2023-07-17 10:31 ` [PATCH v2 4/8] selftests/mm: Fix thuge-gen test bugs Ryan Roberts
2023-07-17 17:22   ` David Hildenbrand
2023-07-17 10:31 ` [PATCH v2 5/8] selftests/mm: va_high_addr_switch should skip unsupported arm64 configs Ryan Roberts
2023-07-17 10:31 ` [PATCH v2 6/8] selftests/mm: Make migration test robust to failure Ryan Roberts
2023-07-17 17:40   ` David Hildenbrand
2023-07-18 10:49     ` Ryan Roberts
2023-07-18 11:23       ` David Hildenbrand
2023-07-18 11:24         ` David Hildenbrand
2023-07-18 12:42           ` Ryan Roberts
2023-07-18 15:24             ` David Hildenbrand
2023-07-17 10:31 ` [PATCH v2 7/8] selftests/mm: Optionally pass duration to transhuge-stress Ryan Roberts
2023-07-17 17:24   ` David Hildenbrand
2023-07-17 10:31 ` [PATCH v2 8/8] selftests/mm: Run all tests from run_vmtests.sh Ryan Roberts
2023-07-17 17:27   ` David Hildenbrand
2023-07-19 20:45     ` Peter Xu
2023-07-20  8:14       ` Ryan Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230717103152.202078-3-ryan.roberts@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@kernel.org \
    --cc=david@redhat.com \
    --cc=jglisse@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=revest@chromium.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).