From patchwork Mon Jul 24 08:25:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13323544 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87A0FC04A94 for ; Mon, 24 Jul 2023 08:25:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07B066B0075; Mon, 24 Jul 2023 04:25:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02AC16B0078; Mon, 24 Jul 2023 04:25:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E35B08E0001; Mon, 24 Jul 2023 04:25:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D53CD6B0075 for ; Mon, 24 Jul 2023 04:25:39 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 59AC640923 for ; Mon, 24 Jul 2023 08:25:39 +0000 (UTC) X-FDA: 81045821598.18.6C829EF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id 8BD9C100015 for ; Mon, 24 Jul 2023 08:25:37 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690187137; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pv8pF/WPDvj1kM4ae908pjU7ySgq/Sv6xLJvnAf6h4E=; b=DwSYDI4WhUknTI7/vyh6ekwzPF+GlPLuLkjA6HZv0d60/RiV/VETUDmCWem0W15mNPjl5n R+SMbsMim1l1VD9Z+eN4RHkgE9lED0olgo2Ex0KM901hN9MnpELS69CkBR3yzpyzBKZQaM 09ieretDWECaIYZ6Z3uhxsUhYvk8egE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690187137; a=rsa-sha256; cv=none; b=ftw/jDlWfWpuJ1ckXkmSEdW+/01dMhqVWRrrLbZLybkTu6ZMCBaP6AFhlfCZKzbJyBO5bQ w18IaMH2V1glrQcgkx/v9Bvxozh08W2JQvy84P6rMh/EDfms+s75CPlzH6+dBubYbgmyHA GeGYgWR9JCRJM12F5C41JsX2xRR0sN0= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D18A411FB; Mon, 24 Jul 2023 01:26:19 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0D383F67D; Mon, 24 Jul 2023 01:25:34 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 2/8] selftests/mm: Skip soft-dirty tests on arm64 Date: Mon, 24 Jul 2023 09:25:16 +0100 Message-Id: <20230724082522.1202616-3-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8BD9C100015 X-Stat-Signature: yix19perq8gn1jjqc9h1cxeqanex8qaw X-Rspam-User: X-HE-Tag: 1690187137-586132 X-HE-Meta: U2FsdGVkX19b8zjGSGW3sSiOt2lQOMktZrlNLWL87GsvmcCT4eLKJFkzTUa54rGkPj6Bm8iqSIZbK1FYSsAuv6+nys01oic2kD/HO5y0ocoocxnT6dss+h+VzSmffJ6MfvTgUOULk42GxrGieJrzQkUHymqDXjjT9rLkb+9y5kzSMhlzBid5z7FBfNtYXgOWh2i6/CWuK2rJyVsvco/zgQI1GN93fAp+CM87PC47bUTOT9K5IlSghjxDzGaZF23gM9iuBCb8u/c1AFWqAAaCMhYqdnetTzKT1YlmV9Bucj1xgFcyEu/SxhN6XkJXv5AEg4Fl/9dqdUUjTljqNCopoGfuxWsBXMQAp3PiUGx37AhVja1Uyk7wbwuOmCaZmEWIYqgbIxaF6lGNzciFozgSbUlgojbTijGFEvOubRaMlY+bX+3l41ZOVHV7Uc9hADSONn6TB9ErZ91OjQsyZZXXOgml0pmbl2boXG6kxLbEVDNn3S2s6kmrxFvo4RvPLavpYPKLWIQD+8uVary1F5FMKY2lB+oYZAQgVIQlVKnvjiQEdXGLAkBslB0AjZ2/PsfS9Nsuxbh4QpqyqNs/w/mDYI4nEXkk7GlBNa0KCPBB+GUQ0HmiqE2qwIOTUYXKOgt/tERJCJpCG4jkapGygjoXfQigu0M863IkjNCBID/TG2KX4osVEhs8ZvAKuZkntqCnZ8D50rocMBJazM/VQpL2jamdV/DowSGls3TuAOOLMf66RY3ZWSxczWwTDBNwu4qLN/1h5NMtoaAJeA/8ZMFUnJAvXyklh4NK3nfCXzOZx26nO03qSgZZFcR+SVaboKeWlvQHHPSznYWde2ZLkmoKOglyO/7Hm5kEd9mpyVi6zh8liytCLAnvm/XUHtPzAv1bXxgpONtFUZFahhSD1EHkZVCgsngzCPfEeErSynvTjpAJ3BC2K/42TACBfg02sXxVmKTGKMewUeJdnDgrjf+ F7Zks9Zt uKKNd3uhzcx5h7jIzkHtoypYJMPCfhpyVQoRxkLJirePX6wb0sga1ZKx+SVAHts7h8dM7dP0IsDfXKAVlWgUZ2qf4WXx/GjG33MRmtBDX8DO105BkMbUcM8eDs1oJ6FEjR32zQhr87/L/+EnP4W2IhrCgmvGQH59y075gutkja1T0dTjp6YjYpJNHyg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. Acked-by: David Hildenbrand Signed-off-by: Ryan Roberts --- 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