From patchwork Mon Jul 24 08:25:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13323543 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 66C47C001B0 for ; Mon, 24 Jul 2023 08:25:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C88D46B0074; Mon, 24 Jul 2023 04:25:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C38EE6B0075; Mon, 24 Jul 2023 04:25:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD9348E0001; Mon, 24 Jul 2023 04:25:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A0A0D6B0074 for ; Mon, 24 Jul 2023 04:25:37 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4F8851A09CC for ; Mon, 24 Jul 2023 08:25:37 +0000 (UTC) X-FDA: 81045821514.30.A86B9F3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 970121C0014 for ; Mon, 24 Jul 2023 08:25:35 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.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=1690187135; 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=XlRIL9y77l4hUsgR6WNGVesaqf711bWwIXAfz4ZM0r8=; b=ScA67Qp4khusok9r+vYrvMp2wDfY840tbayYYK2zv/wJ1JbYvKDUyXRjeOjaxUL9UNl+qa i42XdRCTktnln41imRWRR3Q4mmebPSUxghQoK25dDAOD57s0qYFytRIIziwHUzMThsH2nf Th8+70xYwCm82mKk+W+xjNyZtB2dMGE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.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=1690187135; a=rsa-sha256; cv=none; b=htDE5F0TNEwnQa4lq4NDbw8uG7NxmT2IDP58BD83xIjJuarsbzsMOydbUpek2LxXngBDfn BqUOuwOqRr1r1x2nvCGbb+TQh3KVkKwgLMd58BQazdbHmLaT0jd1w0tLnM32v9SrzWRWAm xAxKmX408eHV1NTl4mydMOdpPXXNDZM= 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 DB53EFEC; Mon, 24 Jul 2023 01:26:17 -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 081BE3F67D; Mon, 24 Jul 2023 01:25:32 -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 1/8] selftests: Line buffer test program's stdout Date: Mon, 24 Jul 2023 09:25:15 +0100 Message-Id: <20230724082522.1202616-2-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-Queue-Id: 970121C0014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 71bptggfbm7p3ttizttqabri3ryp6xoa X-HE-Tag: 1690187135-428098 X-HE-Meta: U2FsdGVkX1+ltsTB5l1Y5qskJQ2o0ph2bnJvSxMv0fNE/S3FLaLi2fesQ+oEKBt7enwKlW3QIpuFt+wlRXgRDbtYynQpW+9x+cdGsqN9gCxDEz26b8s/lvW6WuSz9Jrgz3bKIbRZ7enfNtpcBF3eOlM/dIJsUaWYDMTpjaPvsHAWe77fet/1thfLNGkFcAPBLyQgQLVjGra7Cb+q0mhrJCcD0BGyCEo4K0zTk09BPt9VFfhzGamb1RxCDIqCO+IvsL97biJ6dWQu9EoZYtUo2gI6LBzHe9bj4Rray9k9I0bnhxlML1qzT+lDVEY5yRyeCh05eW5AlvW0WuMb3ZD4DrvjvifIxP3+ytqfjoxRlxLy1S4PnpK/h/5U+gSRU8ZZhlEmLLo1Y4vWXig5Uk3VJFik6WpUA/HS9tSp7R9FNZvNm3P0C7yNYoxcBIGgqFAT2sQ65WuOmphlFZ2Nxd5WsKk/Wxbek0EIVjiQbAjela+geQf3bFZ5IYihUYT+ib1XnIA2FmBaYF/jZirG+aJsAfS8tBNV32VUbi5UAKClGhbZFMu15wrMrKII1HG2R+sJzlzMSs00FEV3MLIj6u/QcA3DoTAogFwGRqEm7F8dTdawLMQeB78BOHQE+74LxIQ+uJQ72Hb9KXy0Zb4YKgg+kzVMxJaeBOMLYNHjqxpwjI4aTXeBrmnRd7wkZNQRodkihJhpwfMxIEqRpc2PMGUwXKGq+M2o+DXOZrQ8DPKny8osGEp0mw3TuPs5rt3ScHeZUGzwxIpW9PKYN2ZZmSF0tellswPWnwEfLuBIkKeN7gkoiKPOMJ45dNKCGMwTbe4KiupPzJHk+xBPkSrLd1moZCrb46hhiMipKdNioFPm/BAa3JpU+/SfWJ5jjSmNHvTZIKpeCyAMP0EZLvVnOo8+3LmXj6FIFOgrdk8KvtKMkURWmV6bwYbtlS6tyJjgmorU6bNcBKgn2NaFKaNSeEA jVksd6tg tWnNuDkqsRUfKGFg/KMD50YiEF1a6yoSb75FPWqn1JahZ16QdZeDkjtumakPwCut60JUGRjMCmEZavsP1QxHGwtAyQS4pRLzfQRAIgoN2y/hqIlUDpkM9ShKAsqWI9LTh+Zorp2cFQsYd0Eb7L0UMB8D/6DdGTCRpDhJODE9jcJ+yTiRg25xLhnTDwzaUyk74TASBmHG1KxhLTmQR7aLIvw3ffvuvf1eEbTk/ 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: The selftests runner pipes the test program's stdout to tap_prefix. The presence of the pipe means that the test program sets its stdout to be fully buffered (as aposed to line buffered when directly connected to the terminal). The block buffering means that there is often content in the buffer at fork() time, which causes the output to end up duplicated. This was causing problems for mm:cow where test results were duplicated 20-30x. Solve this by using `stdbuf`, when available to force the test program to use line buffered mode. This means previously printf'ed results are flushed out of the program before any fork(). Additionally, explicitly set line buffer mode in ksft_print_header(), which means that all test programs that use the ksft framework will benefit even if stdbuf is not present on the system. Reviewed-by: Mark Brown Signed-off-by: Ryan Roberts --- tools/testing/selftests/kselftest.h | 9 +++++++++ tools/testing/selftests/kselftest/runner.sh | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index 829be379545a..529d29a35900 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -113,6 +113,15 @@ static inline int ksft_get_error_cnt(void) { return ksft_cnt.ksft_error; } static inline void ksft_print_header(void) { + /* + * Force line buffering; If stdout is not connected to a terminal, it + * will otherwise default to fully buffered, which can cause output + * duplication if there is content in the buffer when fork()ing. If + * there is a crash, line buffering also means the most recent output + * line will be visible. + */ + setvbuf(stdout, NULL, _IOLBF, 0); + if (!(getenv("KSFT_TAP_LEVEL"))) printf("TAP version 13\n"); } diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 1c952d1401d4..261c73cab41b 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -105,15 +105,18 @@ run_one() echo "# Warning: file $TEST is missing!" echo "not ok $test_num $TEST_HDR_MSG" else + if [ -x /usr/bin/stdbuf ]; then + stdbuf="/usr/bin/stdbuf --output=L " + fi eval kselftest_cmd_args="\$${kselftest_cmd_args_ref:-}" - cmd="./$BASENAME_TEST $kselftest_cmd_args" + cmd="$stdbuf ./$BASENAME_TEST $kselftest_cmd_args" if [ ! -x "$TEST" ]; then echo "# Warning: file $TEST is not executable" if [ $(head -n 1 "$TEST" | cut -c -2) = "#!" ] then interpreter=$(head -n 1 "$TEST" | cut -c 3-) - cmd="$interpreter ./$BASENAME_TEST" + cmd="$stdbuf $interpreter ./$BASENAME_TEST" else echo "not ok $test_num $TEST_HDR_MSG" return 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 From patchwork Mon Jul 24 08:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13323545 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 21349C001B0 for ; Mon, 24 Jul 2023 08:25:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADB156B0078; Mon, 24 Jul 2023 04:25:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3C9F6B007B; Mon, 24 Jul 2023 04:25:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B7BD6B007D; Mon, 24 Jul 2023 04:25:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7DC5D6B0078 for ; Mon, 24 Jul 2023 04:25:41 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 44A7880962 for ; Mon, 24 Jul 2023 08:25:41 +0000 (UTC) X-FDA: 81045821682.06.FA38FB7 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf29.hostedemail.com (Postfix) with ESMTP id A08E1120009 for ; Mon, 24 Jul 2023 08:25:39 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.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=1690187139; 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=+gbe2Lov6qmOHVSUu3pkHDpd9c8tQzyYAgTsJk6v9w0=; b=Y/BLI+OjJwFy+Lg9Gnz+CRf9cSU1x8P4diwsDs3btPITFGys27rLpfqXapmc7fOUmCtgTG zEMzdH85IM3pXyf6rrFter3I+jeFkRAjm7p/WqtfAI8FR7etNFc1zSakh3E+/rj8tgoljp AtpFslrXiG4RLFTanCP+lKf0rWMZXMg= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.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=1690187139; a=rsa-sha256; cv=none; b=pCMYY6D7po/N0DeixgV0/J7DGAMIiC4RnHVsi705k8BBWArsUjRKXLRQw6ChCbYwV/ypuT 2igtBclEXqya7NaUpvyNbzwmvRIgpz9CbZEQ2KLUmQW01C1SsDKAjNY1GDJuhFeqXt3Nu9 rNIKq6DeShekkI24VBhQzac4UTZyUD8= 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 C54A715A1; Mon, 24 Jul 2023 01:26:21 -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 E5F693F67D; Mon, 24 Jul 2023 01:25:36 -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 3/8] selftests/mm: Enable mrelease_test for arm64 Date: Mon, 24 Jul 2023 09:25:17 +0100 Message-Id: <20230724082522.1202616-4-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: A08E1120009 X-Stat-Signature: iuswcaju9rfce789c1q57h9py7pbur13 X-Rspam-User: X-HE-Tag: 1690187139-731946 X-HE-Meta: U2FsdGVkX19yx4X0zsulRuOo2DQFsaFuSk3/htax0OupAJZxJnSZAdzViOwNubV6fpP5wfY3STgKYIuoeHlARAsARlbpZHHpvF2x+QS9p05Q75eyQ0RGwZGQKLtaQdhpHr9QH5l4xTmn9n2M47WDFYqV+fkoM05SkgAaeXymykWDJXD9lBxcB0Tq8WrNHg1PxobNcYOzyiwBqygS5Sb/4pPWCS3bO2n/4bFrfuClCsuq+f26G6LFIOYFNTEuyipBDw3agq/HJxGYOgA7PDyNa6f5WyPBdI/Jm6OEBqm/9UkyGFPxeSpje529R/9Ncg1AKXQ0VELZsk2LVVxpmiNUlG4iEFd21XVJaR1d+KYkYrIMHO/MrSIwbcIGw+DvSZKn+6A3NGnpQPHeRXuVAjK6y4mei40PbKfTlyvD2twYCy5OmvmQyoF1ODNwTufBIwxi4/AJIGaQsvcvy9dN5VB0oM+IHYW1BuOp+xm6/qUxJ0CPHDImnzpTxZzG6kxGl84aSW9RTbDKaTYijxMmkYEf2PTjorv2eriN3KYPRXIK6A2F977dkTHMuqsb8C7k2TYzk0LxAdQOvH1rbf/lzNlTuCtfi90yuu7SxQAAAaI2lRAX6b07I+8StpGfdUBggtRlKK4Oy8t6k+Om8Wps98i75yqx49yQMr3HMyM58b4b+C0EzSYUxzTOiqE994mTQF6tSJnmBDHQb/H1Qo/ZI+3a8A7odEJ5RV/CDzuVIUqOstr0JQWuSw5gurj63a6mSN5QQrn8I5elMBa/0KspOKifLbReNJY4VWJKwS8kD+E8BoXbfgEFGacPOXHxrT7dxfFGaqk9MerS2YaM/dGTzA8XYbgzwkFxle+Mwbt9TEXgIUNBNf1RwQnR50qBO8y3KuxjlyvyvE/ihv5TbGte1t4QjMPkUkwtyUAKiHlXh5RUkZ74iZgIbrX1sGFTV6HwyLGR2s2ICQvyCHVV15akRBF RE9eyusA RmBQohtaibIkQHwsNuP9n/IYWJdgwQOiJoAavxae9PaOI+Lhk1NNme92HaDhxyB7jPnee2qz0zeVlxOZx5gw/kVvmDi68XOlNmbAcM53+4XaEB7QlGBA/LzInVyhk1BBlW99idxCFqJahPXziuLFecCt863xK8WolVoxN5al/VkGJZHTzNWw1xiAiy+Gasm69I6hpgCh5Rlic117z5Y92YraYiBeXT058Cr2Gld5WuodEA0s= 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: mrelease_test defaults to defining __NR_pidfd_open and __NR_process_mrelease syscall numbers to -1, if they are not defined anywhere else, and the suite would then be marked as skipped as a result. arm64 (at least the stock debian toolchain that I'm using) requires including to pull in the defines for these syscalls. So let's add this header. With this in place, the test is passing on arm64. Reviewed-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/mrelease_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/mm/mrelease_test.c b/tools/testing/selftests/mm/mrelease_test.c index dca21042b679..d822004a374e 100644 --- a/tools/testing/selftests/mm/mrelease_test.c +++ b/tools/testing/selftests/mm/mrelease_test.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include From patchwork Mon Jul 24 08:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13323546 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 EEE9DC04FDF for ; Mon, 24 Jul 2023 08:25:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EB5E6B007B; Mon, 24 Jul 2023 04:25:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29BB26B007D; Mon, 24 Jul 2023 04:25:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13DA66B007E; Mon, 24 Jul 2023 04:25:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EE74E6B007B for ; Mon, 24 Jul 2023 04:25:42 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B2A8BB1F89 for ; Mon, 24 Jul 2023 08:25:42 +0000 (UTC) X-FDA: 81045821724.23.1B0A1ED Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id F20AE100005 for ; Mon, 24 Jul 2023 08:25:40 +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=1690187141; 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=RlF+OWSt7Xg4Y8gUX/1pDNyyb2oDlnFwm/E3+/VsYzs=; b=tIfKnQt/lqdgONNKtBPXEEL6MPKYrqulZKoBO/Vqz8ktx2p3FN0oyfOlncoUeZrHdYwEQz 4JuiQXbH4xTtNvaJm8DBi3DJ3oVEL6+suMh4AVSKrNXqtdctWV+mLajQMq6upzUU5iZv5r bWjw8sj4twQzU9Y3jOd9TDy7Ha4ZG7k= 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=1690187141; a=rsa-sha256; cv=none; b=48VLf1btxDCCGIgYdrYZzeOpwQy7HU4HDOq5x+WXLE/sAkYpE+Lk8Wh85S1LNDgIML3zSB UeQv7+ZLyYSkh8CPFzksMQVN6dWxgMF0ii6hZH8xO5kFcxFOmoNqLhrcoO3sQIvL6H6J1J GKmplQDXsA/KsjAeTwTq2QiagxTtPxI= 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 BDAAB11FB; Mon, 24 Jul 2023 01:26:23 -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 DA6DE3F67D; Mon, 24 Jul 2023 01:25:38 -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 4/8] selftests/mm: Fix thuge-gen test bugs Date: Mon, 24 Jul 2023 09:25:18 +0100 Message-Id: <20230724082522.1202616-5-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: F20AE100005 X-Stat-Signature: f8f9d9ck4jy3hkqq9wsg9tpnkro9u53a X-Rspam-User: X-HE-Tag: 1690187140-687266 X-HE-Meta: U2FsdGVkX188bKHF0jo2iPulRL26RAVLcj1eE9fvdr4HklTeeuvY3nq2wb19TonoYZZjWOqG90gFC7GOupo+QeoThH0Am8i1Ey3M7nW5MyOnuJYrhRaVGDJLdEDbjYGBxNkqZcguR+9EDREVCoRQJhQBra+K0Dtyxzr1411zwbbaIjFi0KzcUEPX+iVuGOJjGDJs4t3NDfbfKShkdFl2WgN0hMa7M8duV4mr7LbLPQZc5fTOHN46Q8x5qhp5xX+2g+QB22Itwa1zPrsF8A46kIVLsBlulpFpf1ZLdNJQ3JJHcUBNNpSpXhTH4t5NxknVV0QU1X5ryqBUuHwgD6kiwuOw2gJkcudRgzNhdPaALivWDqkNlRTX1BlgF44iutGk/xdL98Q0niglq7SOC5v64khNGv9+imBYUDr0eJl+5vYJ38iRAm3YnDAUE+++JG8xWvChHQ0qJk1r7h5KlGbrLQd5UB//FxtzGjiHY7EVOXx0tOqlvglkJyGwpJVuPS9m2t0/g1rE1CFDsq0uQ/9wVhQnIfG0Uikzlvb1IFdAnQpZBd2wbopsq1rEXsFOENDKhdfGUDJ2hJt1IzXN2tONmRmHqDo/T5l7ui7lgWqJodYcvkOPT+Goowf3it/XQdn3Fuf1L2ueOWGrWX8vQbZ6+MOR6+ad5JJZ2N1YJiVRpeGJ8j+2T00UsGfRi64AWCWRMDagQTuKP5Rca391xPXjHm7M7YMIz+tyz+RTVmqV2+magShRr+G0MLcdGmYXUrTaEnRFNXXSo/7fj9xs6pR3gX4+fz/6SZqhXiJBEmcJLZbfaqwrpRds4cssuSpJbWMiXBdrXcCeifkjRwkTt4Cj3lx7Xy+CDBE4AmVmfcsrggrFtDC9rW3C/Y/5HYO4hYdRG7YlsVmOCKxSMl5QJmr71jcVJnqP9J+TqSgDD5xOiEiEOIdkxOzJLtllqRLToP+EJqXcxW0cl9Vto6hh7ft eRnz34KD JC9G9L/vUWML3EpGRrmYvMKpUoaITXkOO/TuvPwhH00G+rBJzBNQyp4M6PK8JIQtDo/NhfvMf98cNESHR4WDrrF79UQNvyEUsVTKQONVFQcKHDdDUfJOyK3xh/HbfkfsagNie+9ehfbLo9+dFPWqGbY/DHj70FFlgM23LmZ2JRAKH4t95cTpBO/RJnA== 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: thuge-gen was previously only munmapping part of the mmapped buffer, which caused us to run out of 1G huge pages for a later part of the test. Fix this by munmapping the whole buffer. Based on the code, it looks like a typo rather than an intention to keep some of the buffer mapped. thuge-gen was also calling mmap with SHM_HUGETLB flag (bit 11 set), which is actually MAP_DENYWRITE in mmap context. The man page says this flag is ignored in modern kernels. I'm pretty sure from the context that the author intended to pass the MAP_HUGETLB flag so I've fixed that up too. Reviewed-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/thuge-gen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/thuge-gen.c b/tools/testing/selftests/mm/thuge-gen.c index 380ab5f0a534..16ed4dfa7359 100644 --- a/tools/testing/selftests/mm/thuge-gen.c +++ b/tools/testing/selftests/mm/thuge-gen.c @@ -139,7 +139,7 @@ void test_mmap(unsigned long size, unsigned flags) before, after, before - after, size); assert(size == getpagesize() || (before - after) == NUM_PAGES); show(size); - err = munmap(map, size); + err = munmap(map, size * NUM_PAGES); assert(!err); } @@ -222,7 +222,7 @@ int main(void) test_mmap(ps, MAP_HUGETLB | arg); } printf("Testing default huge mmap\n"); - test_mmap(default_hps, SHM_HUGETLB); + test_mmap(default_hps, MAP_HUGETLB); puts("Testing non-huge shmget"); test_shmget(getpagesize(), 0); From patchwork Mon Jul 24 08:25:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13323547 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 09AE9C001B0 for ; Mon, 24 Jul 2023 08:25:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 586186B007D; Mon, 24 Jul 2023 04:25:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 497E76B007E; Mon, 24 Jul 2023 04:25:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 388948E0001; Mon, 24 Jul 2023 04:25:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2AF376B007D for ; Mon, 24 Jul 2023 04:25:45 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1151AB1F28 for ; Mon, 24 Jul 2023 08:25:45 +0000 (UTC) X-FDA: 81045821850.13.F98F092 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 502A21C000D for ; Mon, 24 Jul 2023 08:25:43 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.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=1690187143; 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=IStgpvB/AxFXY+gD4sZN5L7DJnID4eqcXYh0yWnPJzA=; b=UYIOpJOwBMayjrQfwkY3mBEdQAqeOfxoqebdJE5fuw3r44texm8ve0lbYakIwmbzA/iX/6 SGhX8amQwEbyCvb4+Rrs1sqWbZW0rszSFK7beAiZVivf28aDSU7c6hX/6VbcpQKqsgpdBr dCwoPT5984++WE4h6tJb1zEBvJTOFiY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.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=1690187143; a=rsa-sha256; cv=none; b=MRJpe59CJcEeevZdn5Nm9zSeQMEIh+ZNPaWk60kgJvl8P/7IqZ0Bto66rzOqYrVgKRnG+j 7IbrgN/6m4sPBA/TBjJOdTxOVUogjpi9BjOFTUWudAKKdTNmUrCJsQkfQM0WJyPq9Q31mf s1dloRAibiMJWI+QTEMF/4CIuj8vVU4= 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 AF3D9DE0; Mon, 24 Jul 2023 01:26:25 -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 D04CD3F67D; Mon, 24 Jul 2023 01:25:40 -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 5/8] selftests/mm: va_high_addr_switch should skip unsupported arm64 configs Date: Mon, 24 Jul 2023 09:25:19 +0100 Message-Id: <20230724082522.1202616-6-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-Rspam-User: X-Stat-Signature: r63cswmfq4bnn3cksi571xrwz36hwezf X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 502A21C000D X-HE-Tag: 1690187143-101656 X-HE-Meta: U2FsdGVkX1/KaKvkTQAl1nyCvCDQkTryN30cC4fyr7cZL+fgIc8ES8OeI/19jcUBl9MuzmVUgRPvioTrfOgl1hPWjOI4QsiCR53BLiIc2zwzGGwYzSuT90SGhu5JHyIzy5SNMJUrg2XTCl2V8nqIpRfoT+1zQyPZ3GVT7p4EuowZJo+E43kw8O5cIHBw9/I9Ei/8e6JJCdeUm6ajSJlGNz8WAe0czz/VCi+lLdm2afushe+pqA5l3NrNlZbaehjqWaP6hhfA3Eo29vyuYuxHSIQlY03yXQflW1aeDqUscMyWkXfrzLcYPxq8MQ8+ELtDSE+JcBSv9j51oexAvzoO73dXLXlg4VQdJcZF4Pyi0GOPD6yh4LDeLK4W+Hloh9Af7V3zdKYHsfmWMtb4QUsrFlJnnGyjr8+5qZpCE7TSwVvBLf4IQG9fuFURW2GJl2RdO9XmG8+g8Nru6FAteXw9Y0f1Md93LMnROLmhFsC0Z8ASdfiSwY5JWPaJ+2R1bh9F8FqhSgkRrXqwUrKB3q+L+SOPb2PRZDhxSohbp7CctMDcdbPE6rBXx1nkj9sXQVsCWlUUw8iUxNRop92y7pu1rtKGJpSDWWeRP00y4hvUSa60PgHI4lJiJh+YrAvMACBsAxpgvOhNwDUMkoizeTd7O85kgHAph02GEzmzwWvNHraHhe9gutd4+9PN9XuXo+UeCqdV+XhuM2zly8A7Vjb8Hwak5QS7HcHmZi5VHy4SLeb5Bxl+HU/OxzUEXsYOYET2615m0cPyBAUD4prlQKXfs2xqYMRQelEKtAbQC+9QWKMG5SSIZ7EjFx/2CwbFAxJIw/LuSSis/GxirldbIkcv8uOV1XOERhj7u80UJAAFK3XcN7snwDsLTxA6tbh0k/BA6DQSSwbN1DoiXqKTq0k/wp6/80ASMqWCfBT4Y+Sx6vojfuCYDvVB9e2fzFbZU98bFZGO2nX3ciKohUxVzU2 Q7KKwjzf N+m1QFU/dT93V9f+Ih8jmAfGdMOehTcWH614zAXpNobQ8oXVSGMsMDCEKNjtSoB4Dq5hsVpFyFzTNB6RRjxB5IdWd2uYsO+ELVdRI5/VFYg91oua7UQQLbdM20kbNkdjsvEghwuEzHV2d8RrEd7I2UQHewYHSK6m1Jvc8K/FsdbFFlKGXX6IWigV+Ild+Gg+XgBpb1oE/c1ey1gse8GWfS41Ht8XB/TuayW7r 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: va_high_addr_switch has a mechanism to determine if the tests should be run or skipped (supported_arch()). This currently returns unconditionally true for arm64. However, va_high_addr_switch also requires a large virtual address space for the tests to run, otherwise they spuriously fail. Since arm64 can only support VA > 48 bits when the page size is 64K, let's decide whether we should skip the test suite based on the page size. This reduces noise when running on 4K and 16K kernels. Reviewed-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/va_high_addr_switch.c | 2 +- 1 file changed, 1 insertion(+), 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 7cfaf4a74c57..cfbc501290d3 100644 --- a/tools/testing/selftests/mm/va_high_addr_switch.c +++ b/tools/testing/selftests/mm/va_high_addr_switch.c @@ -292,7 +292,7 @@ static int supported_arch(void) #elif defined(__x86_64__) return 1; #elif defined(__aarch64__) - return 1; + return getpagesize() == PAGE_SIZE; #else return 0; #endif From patchwork Mon Jul 24 08:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13323548 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 02BF4C04A94 for ; Mon, 24 Jul 2023 08:25:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 955DC6B007E; Mon, 24 Jul 2023 04:25:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8DD976B0080; Mon, 24 Jul 2023 04:25:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CC9B6B0081; Mon, 24 Jul 2023 04:25:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 668266B007E for ; Mon, 24 Jul 2023 04:25:47 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3DCCE1C902E for ; Mon, 24 Jul 2023 08:25:47 +0000 (UTC) X-FDA: 81045821934.26.6765191 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id 828D24000F for ; Mon, 24 Jul 2023 08:25:45 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.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=1690187145; 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=851WhiQknpUsE4X1CElE53hGZjRb+eoC5oQhWBMUHjk=; b=KOfEDqjLc04CRhZRLeuv3v21JptMf0srbwcmqtF3d1f4TUb9Sywly2bTVk6Dko3odQ0dh/ x9KI8iF30TrjxWYku8goJ6CIX/aXq+ahondDMmkV2HUejv6RVfCFRJvDli2P484S02QVBd jR/G0n+aoI4uelL97QwqwT2PDZm0bac= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.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=1690187145; a=rsa-sha256; cv=none; b=SaZmB7MCzOTtztX3su9Tyk2uPniaMFOj4brRyZnafZ1DnnZU00A1UZQPMN8dNNSiv3MOwO YCW8S2m2eicqE2h4bKyVZwgBu4nB6ma0RbT6C0SDVliMh4OFunevYc7jUirVzbjOUyINc+ hSMFUOGn83rpi9+pfZucPDPPaI1yUjQ= 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 A37E515A1; Mon, 24 Jul 2023 01:26:27 -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 C45423F67D; Mon, 24 Jul 2023 01:25:42 -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 6/8] selftests/mm: Make migration test robust to failure Date: Mon, 24 Jul 2023 09:25:20 +0100 Message-Id: <20230724082522.1202616-7-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 828D24000F X-Stat-Signature: tqwdq81oyrq8n8194e14smht6apj74kd X-HE-Tag: 1690187145-415853 X-HE-Meta: U2FsdGVkX1/iQFfUN2U1DoZblEjJOI9xmu73s5MhNkdR0LACN6AGiQhJpYxuDw6qE4nYQE5LDb8HEU5v4y9sBfre4TNk17ZyGMrk4qiG868QRfHx4Y5CzWN3ebJLpB6EEpgtugSG6QsNPSMb4njh9PGDOaU7CZn3d6128h2e2rzmJgioJln7z5cYWA6j6rym4neRWvOrwBbpYIgRzjx59nNdRjpCiQCmpjBtLN2/m8f+m5R6B382vE4CiTV91jqbMOX3STcqeWakQkqqBLo2sckuxbRvCBKYOvevvS2F3UR4seIBYUGe7MW7fPP5FeVJ/OEKZuVWiiX1ADIkopOAnve4K3L4cSGIdktwr13v/98cI5CrXfRyksXNH5Sl1Gv5FSuVKjdbN1qoYKXRBN4La4wH5efU2WVgAfxWjUndYHJUFsUl9J4SdquhA4brW08loRFHXLd5qlZOIkym96EZOyRztirmMzLACKPGARooVt2uKa7rNblrtTqpL5/eLdqY+z/IiYLi/DFi8LZ4zmbGfG6ESkA9ONa+9IbYD4qlHHS4ph+MOxomZFkBS5aO9TNf/yvRgoZZnd1TGHT0tz/BcChmDxNVkJTrr8I+qA5cSlYzstU2a61fLDQJrUOFhrC77fT6VitE3Qs8VRq2c/K9xsSqwBXWkwN4Knuxw4YqKKRVGW8Jw/IHRw+2x+U/bozTgxbe892LphaFT1LViT3khArZxUWgSJxC1A/fuZ0nNmSMCDnToTq4VkiP5iL/PxucVICL+ohAu8Y/mgkI/Ew/5aikoz0onsPI+YB/ztodPViNJvTKH6bcGloMcIVMw8Os6Tlu3KTPWVWp6mDdcEdnIAPmtTutvLOblMvARutQGFfXskt761QKRQvRmUKlH9iJ6tZ8aLG3ja7JkXY05umCJzITzSrr22rwAv9yIYhyVXS3QsBZM0BN9vJGj/dLSQiCwZQ3z9vGpOBZ7X1lcrd B3zYJzYL 62pn0V43dfEdEE9qMEyzPul25EmyJQF1EYDRFp+dlrg0dblmPPhBXVrwCdeCU20Ii5pEK5Vz8ZAtlWz0NpVv2jYWL6jIM0dfp0N+80iAeEUnTFQcw2Ng+KaAJEuHCQwh5cIDenLgg3y9sWbIshOuy9pwcquKPpUeT3B+J 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: The `migration` test currently has a number of robustness problems that cause it to hang and leak resources. Timeout: There are 3 tests, which each previously ran for 60 seconds. However, the timeout in mm/settings for a single test binary was set to 45 seconds. So when run using run_kselftest.sh, the top level timeout would trigger before the test binary was finished. Solve this by meeting in the middle; each of the 3 tests now runs for 20 seconds (for a total of 60), and the top level timeout is set to 90 seconds. Leaking child processes: the `shared_anon` test fork()s some children but then an ASSERT() fires before the test kills those children. The assert causes immediate exit of the parent and leaking of the children. Furthermore, if run using the run_kselftest.sh wrapper, the wrapper would get stuck waiting for those children to exit, which never happens. Solve this by setting the "parent death signal" to SIGHUP in the child, so that the child is killed automatically if the parent dies. With these changes, the test binary now runs to completion on arm64, with 2 tests passing and the `shared_anon` test failing. Signed-off-by: Ryan Roberts Reviewed-by: David Hildenbrand --- tools/testing/selftests/mm/migration.c | 12 +++++++++--- tools/testing/selftests/mm/settings | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c index 379581567f27..6908569ef406 100644 --- a/tools/testing/selftests/mm/migration.c +++ b/tools/testing/selftests/mm/migration.c @@ -10,12 +10,13 @@ #include #include #include +#include #include #include #include #define TWOMEG (2<<20) -#define RUNTIME (60) +#define RUNTIME (20) #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1))) @@ -155,10 +156,15 @@ TEST_F_TIMEOUT(migration, shared_anon, 2*RUNTIME) memset(ptr, 0xde, TWOMEG); for (i = 0; i < self->nthreads - 1; i++) { pid = fork(); - if (!pid) + if (!pid) { + prctl(PR_SET_PDEATHSIG, SIGHUP); + /* Parent may have died before prctl so check now. */ + if (getppid() == 1) + kill(getpid(), SIGHUP); access_mem(ptr); - else + } else { self->pids[i] = pid; + } } ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); diff --git a/tools/testing/selftests/mm/settings b/tools/testing/selftests/mm/settings index 9abfc60e9e6f..ba4d85f74cd6 100644 --- a/tools/testing/selftests/mm/settings +++ b/tools/testing/selftests/mm/settings @@ -1 +1 @@ -timeout=45 +timeout=90 From patchwork Mon Jul 24 08:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13323549 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 E706CC001B0 for ; Mon, 24 Jul 2023 08:25:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 620BF6B0080; Mon, 24 Jul 2023 04:25:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D1B76B0081; Mon, 24 Jul 2023 04:25:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 470E66B0082; Mon, 24 Jul 2023 04:25:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3909F6B0080 for ; Mon, 24 Jul 2023 04:25:49 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0EBFD1609CA for ; Mon, 24 Jul 2023 08:25:49 +0000 (UTC) X-FDA: 81045822018.07.62E4473 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 562D040020 for ; Mon, 24 Jul 2023 08:25:47 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf12.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=1690187147; 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=c+gqtMtT71E+QHqOq+JqAAJ/D08SVzIjdaWzP+X/2vY=; b=HjEfie/DpB6do6GX0l+B7Xr4+5iFYx5mH7UkQJGpzw6nd7FOBOd/Tqsb95G86GTaP8kXKM AFGSY+ZtfRYhrjUwdYqFc6ikGQd5GzE7vK7xhAljTJcFCHVipcm0aZO14gFvjjUcKCz03W 27xSIfjlsZR9epk23R4XBhlndTxbgBs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf12.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=1690187147; a=rsa-sha256; cv=none; b=3nf/587KdCvf7Pi0TRDplUw+OqIbxAS/19ZmY//aPPaH8MQPe/P7uq32TxGR/rI+hLYDxN 2HqbcC7hQCKOwVUptJe0KGmHA3xPsgYKy68ny91uBY8foHbQrLfhV+DRKWPskMAS+N5eVe Rbkl7WWs9Xky253W/xKKdKKLg4Adig4= 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 97F62DE0; Mon, 24 Jul 2023 01:26:29 -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 B8B9E3F67D; Mon, 24 Jul 2023 01:25:44 -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 7/8] selftests/mm: Optionally pass duration to transhuge-stress Date: Mon, 24 Jul 2023 09:25:21 +0100 Message-Id: <20230724082522.1202616-8-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-Rspam-User: X-Stat-Signature: tchmnuwzcyc4yoe9jbtdo71w5ygiwha8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 562D040020 X-HE-Tag: 1690187147-140434 X-HE-Meta: U2FsdGVkX18yK9MWl+IyQ9OKhpeZRqjtkDWS+l33lmyHAk6lXEZxrS/2T5aFfwNAP8LFNPFXUUplH1zlQ+6How761B8kPptn6jAbvflpgBiKdPeaVaxadSW+34h2LXkhSHN4Z8hfvHsWx13vUhlY3nMQx+WFnQP8PmOHT6nE1A2iBdcFDjkVVyENsEfQKts3xzYgQ/5mKYQSPzZsKlkUP6vSVy3862xi8v0e/RWB8GULGThFRC2+eUnn7DvXC+DhpC19cC5Dsd3qxUhJ6E+FDlvy3JoPW3N6RZKk4h+8o+9kVqQFBzIx22ZmLxQ0+PyvjQzFWO2PuV2+kX3RxqVfDW6UMon78NREDqkGiV3Apr2f7PtmfATkhqXSUW0RD/3JQDoZh0dY57TL8xaZC4dZFa1EUaz6EhcogS/Et+8+MP1mrSwdULGH2OCnDnY/iN5W4dPXcPXbs+sAjzLQrmeplspt8rDAsJZy6LjAbe2vZ/RjLE5IqNj6PT7FfbCzTwEgS22iJcEeU/BpCPCyQhhE2kGUi1n+4kw4PUl112JRCLEOpWllWvFZzQ3vY6p/Oho8cNOjo1P094zSqqYhvZUztW/a6IT00pdbnTDEUy+HFIdRtOdn3G/FLtsgsCw51MFnK59dZ9gr4R1Az5ad1bqMPwbW22Jjc7COZ06JkINWHyqSJud4VvR6CGtJ89D7V/mNw0OZ/bfGQj/lfWGPCGf8I9E4bA/BJcEfMQmKQsd9ml2DiJBtaMl6Z8Q3smzYkzhlMFTtosZcuFaXAmleAE9DO0iOhdEFCd2ZDe3igXYQZmNZ+czbrgNOVGMis4OF8TGzLJeeIgwV3XXs05UwCzqx966Lfe9L8oswNY5rlCeCDAhv/Oa+Ix/Afa6eJ0ynpDi1BLAwdoAWhVS00V6YrgN0GNcyHwxfHZ3eSx1571EHgqhw4Ad5mFdLzAjTDp14xHGwKn/mYKoUmQZuwNyDeU2 1I7M73tX xvsIFSx5yGu7bRUzo+m85FzK/+aQJpt6siR2UCiTpCq6QkIwpahH5nsLjWS7eK4hQPvwCBJNVh3CapsoYFgmGR3+0Rzz6ftHrAP/fwCRsN+yEO+wmRAOcWNld9ICuhHH1QFmf7gnN8ccKgjaCexuInBBHxhqHO8W9zjZA9V96435YBGRFpTLbDb4vaA== 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: Until now, transhuge-stress runs until its explicitly killed, so when invoked by run_kselftest.sh, it would run until the test timeout, then it would be killed and the test would be marked as failed. Add a new, optional command line parameter that allows the user to specify the duration in seconds that the program should run. The program exits after this duration with a success (0) exit code. If the argument is omitted the old behacvior remains. On it's own, this doesn't quite solve our problem because run_kselftest.sh does not allow passing parameters to the program under test. But we will shortly move this to run_vmtests.sh, which does allow parameter passing. Acked-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/transhuge-stress.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c index ba9d37ad3a89..c61fb9350b8c 100644 --- a/tools/testing/selftests/mm/transhuge-stress.c +++ b/tools/testing/selftests/mm/transhuge-stress.c @@ -25,13 +25,14 @@ int main(int argc, char **argv) { size_t ram, len; void *ptr, *p; - struct timespec a, b; + struct timespec start, a, b; int i = 0; char *name = NULL; double s; uint8_t *map; size_t map_len; int pagemap_fd; + int duration = 0; ram = sysconf(_SC_PHYS_PAGES); if (ram > SIZE_MAX / psize() / 4) @@ -42,9 +43,11 @@ int main(int argc, char **argv) while (++i < argc) { if (!strcmp(argv[i], "-h")) - errx(1, "usage: %s [size in MiB]", argv[0]); + errx(1, "usage: %s [-f ] [-d ] [size in MiB]", argv[0]); else if (!strcmp(argv[i], "-f")) name = argv[++i]; + else if (!strcmp(argv[i], "-d")) + duration = atoi(argv[++i]); else len = atoll(argv[i]) << 20; } @@ -78,6 +81,8 @@ int main(int argc, char **argv) if (!map) errx(2, "map malloc"); + clock_gettime(CLOCK_MONOTONIC, &start); + while (1) { int nr_succeed = 0, nr_failed = 0, nr_pages = 0; @@ -118,5 +123,8 @@ int main(int argc, char **argv) "%4d succeed, %4d failed, %4d different pages", s, s * 1000 / (len >> HPAGE_SHIFT), len / s / (1 << 20), nr_succeed, nr_failed, nr_pages); + + if (duration > 0 && b.tv_sec - start.tv_sec >= duration) + return 0; } } From patchwork Mon Jul 24 08:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13323550 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 DD0DBC001DE for ; Mon, 24 Jul 2023 08:25:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55D0F6B0081; Mon, 24 Jul 2023 04:25:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E7086B0082; Mon, 24 Jul 2023 04:25:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AFD48E0001; Mon, 24 Jul 2023 04:25:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 231036B0081 for ; Mon, 24 Jul 2023 04:25:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DCEFEC0989 for ; Mon, 24 Jul 2023 08:25:50 +0000 (UTC) X-FDA: 81045822060.22.CF34BAD Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 3532C40008 for ; Mon, 24 Jul 2023 08:25:48 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690187149; 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=P38aKxBNTwdPxsWii2NJDfq7k7dgyHj7yDkmvWqAUjA=; b=5cynkcPuknY0PDaBnMkadAaE8hak1EK94WgZi6qvxr2IaIuUr8Mqi4YPYdK/60C9jAwnpo tihL+E3n4cnoCIIild4pWNm1c7ekUpWHlA5hYIjT6XQcJP0dSH5LQAlbWOr93Q61frhRl8 KxhzrqIHjZNS3KThwzPePTieZ9TzeBk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690187149; a=rsa-sha256; cv=none; b=f0fEQ6PwLRjqON1QZ1p8lRqZ/CYwQUpwQFjDF8tawt71GXC3wIPyN8Kk35SHXN/JVt/5FN JqyplD5tAcJUOWS2D0NrJwXlzFlKaHSIYa5gTXRT/PqymiyG5OVMwptWNS0pvBaikfucNv otEj3MDM4aGok7qGX7LwLWgysiTrH2Q= 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 AAB3E11FB; Mon, 24 Jul 2023 01:26:31 -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 AD6E83F67D; Mon, 24 Jul 2023 01:25:46 -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 8/8] selftests/mm: Run all tests from run_vmtests.sh Date: Mon, 24 Jul 2023 09:25:22 +0100 Message-Id: <20230724082522.1202616-9-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-Queue-Id: 3532C40008 X-Rspam-User: X-Stat-Signature: 16db4iznqiihgm49muxuzst5iiqz9s3n X-Rspamd-Server: rspam01 X-HE-Tag: 1690187148-603346 X-HE-Meta: U2FsdGVkX1/ApmTLSM6UEEry3W9opfrgAtGMEJh2sgt0C5Fpk0hypPtngREz0OB49NnWe1wZRWIlDnbcEc6Aa1yBWjVuiofN11zSyx+cDzP3uTlS/i6nYGSQq6+4VH64toC3OUirJOC/KbyKCcAsytIky7eECyXoaGcNvtkP44bH6CRzj39LvPXtZOa79Jfqg+v7/y8C+ofq8uNoBk4Wx2jzLaeUvuzBg3re8RhoMLJcZGCHnD4ZESx1YwjDTPP96kkg+I65P2w29ONCdi2IxVd8SrnMl2+KvqXYsku2Ot52NG2coXtxD0C1p+Ja/DMkecy7/wzB8dngG590wDOqPfPJt+J70SThkLd48NqPPIvazoC9ZduvJkLCZtPWkw9lqkZ0RWe2lGJpzbCyZW008/yAmLnNAuT8MJahD/xvHSy8k2nZIzAM4ps6xC/4YZGgeKb83LQnA1N425Jqm4b013TWGL3cxQj7k4F7gIS84rFO+3oZGhQXVqhaISXi0Vbky1v8A5cG8/t+zmEdzKvEuzwGFCJgj5pOrCf9qGUrawawwUFtmqa3YqJVuqBFS0SneQxNaHE6iCXrq34DPVBW31zqAA7GRhX78tOV4su7oQm2wwToBTGuc1RdjXzMopUg2Bl8ocUogQ10wUm2YNUPknv4PXIjECkMZquOWtUSOLZW3uQTZhOorFcG3KvhcjZvkZxoPZX3QK4tMmJb4yEmcCSDyIeVWYTvNvNhKsszrcwQQ20DXrwnG+mwsrG1J4PFaWhU3Sd0EHAn2gcvviqr7DjKP1Js0QkjE0G7exL1AiIbBEG+lIGe8I5rCAyWUHknTooZB1eUiagkSZn05Mq9KEecNHXUL1iZqy/zG3KLi6Ed+LjHsVTUQ7W4r7dIuyfiS7gt0t8PBG7GpbChUIGjq8XelBYtwzP4MPeTHhLO5Q4DURDFDQ19VCbB36Mx0zW4PWEGHCLZlxZMQ4xJYQR hMgeIP5n siGb5Cw44RHc4X7WYdULwJ1im0cxvdFSCoy4bXYn0vF6etFCiEgyjPaInwLrVyK/uWsCDqPQChAEaBzCRJpXczRNwWM/38CpO04pAEJmLa2RkGkL6qOwsmeYdoJxwP2Z1Fc3xxmenHCwO5oxiRfXI7QbpFuY+0PdUKYdNQ3qEgugGPvAvVS8ch9QGRrg8RmO/JRujKkrUqVbj6o0Y+IR8wtiqrPpDMkuMmDuh 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: It is very unclear to me how one is supposed to run all the mm selftests consistently and get clear results. Most of the test programs are launched by both run_vmtests.sh and run_kselftest.sh: hugepage-mmap hugepage-shm map_hugetlb hugepage-mremap hugepage-vmemmap hugetlb-madvise map_fixed_noreplace gup_test gup_longterm uffd-unit-tests uffd-stress compaction_test on-fault-limit map_populate mlock-random-test mlock2-tests mrelease_test mremap_test thuge-gen virtual_address_range va_high_addr_switch mremap_dontunmap hmm-tests madv_populate memfd_secret ksm_tests ksm_functional_tests soft-dirty cow However, of this set, when launched by run_vmtests.sh, some of the programs are invoked multiple times with different arguments. When invoked by run_kselftest.sh, they are invoked without arguments (and as a consequence, some fail immediately). Some test programs are only launched by run_vmtests.sh: test_vmalloc.sh And some test programs and only launched by run_kselftest.sh: khugepaged migration mkdirty transhuge-stress split_huge_page_test mdwe_test write_to_hugetlbfs Furthermore, run_vmtests.sh is invoked by run_kselftest.sh, so in this case all the test programs invoked by both scripts are run twice! Needless to say, this is a bit of a mess. In the absence of fully understanding the history here, it looks to me like the best solution is to launch ALL test programs from run_vmtests.sh, and ONLY invoke run_vmtests.sh from run_kselftest.sh. This way, we get full control over the parameters, each program is only invoked the intended number of times, and regardless of which script is used, the same tests get run in the same way. The only drawback is that if using run_kselftest.sh, it's top-level tap result reporting reports only a single test and it fails if any of the contained tests fail. I don't see this as a big deal though since we still see all the nested reporting from multiple layers. The other issue with this is that all of run_vmtests.sh must execute within a single kselftest timeout period, so let's increase that to something more suitable. In the Makefile, TEST_GEN_PROGS will compile and install the tests and will add them to the list of tests that run_kselftest.sh will run. TEST_GEN_FILES will compile and install the tests but will not add them to the test list. So let's move all the programs from TEST_GEN_PROGS to TEST_GEN_FILES so that they are built but not executed by run_kselftest.sh. Note that run_vmtests.sh is added to TEST_PROGS, which means it ends up in the test list. (the lack of "_GEN" means it won't be compiled, but simply copied). Acked-by: David Hildenbrand Acked-by: Peter Xu Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/Makefile | 79 ++++++++++++----------- tools/testing/selftests/mm/run_vmtests.sh | 23 +++++++ tools/testing/selftests/mm/settings | 2 +- 3 files changed, 64 insertions(+), 40 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 3514697fc2db..f39ba27d15fa 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -35,41 +35,41 @@ MAKEFLAGS += --no-builtin-rules CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) LDLIBS = -lrt -lpthread -TEST_GEN_PROGS = cow -TEST_GEN_PROGS += compaction_test -TEST_GEN_PROGS += gup_longterm -TEST_GEN_PROGS += gup_test -TEST_GEN_PROGS += hmm-tests -TEST_GEN_PROGS += hugetlb-madvise -TEST_GEN_PROGS += hugepage-mmap -TEST_GEN_PROGS += hugepage-mremap -TEST_GEN_PROGS += hugepage-shm -TEST_GEN_PROGS += hugepage-vmemmap -TEST_GEN_PROGS += khugepaged -TEST_GEN_PROGS += madv_populate -TEST_GEN_PROGS += map_fixed_noreplace -TEST_GEN_PROGS += map_hugetlb -TEST_GEN_PROGS += map_populate -TEST_GEN_PROGS += memfd_secret -TEST_GEN_PROGS += migration -TEST_GEN_PROGS += mkdirty -TEST_GEN_PROGS += mlock-random-test -TEST_GEN_PROGS += mlock2-tests -TEST_GEN_PROGS += mrelease_test -TEST_GEN_PROGS += mremap_dontunmap -TEST_GEN_PROGS += mremap_test -TEST_GEN_PROGS += on-fault-limit -TEST_GEN_PROGS += thuge-gen -TEST_GEN_PROGS += transhuge-stress -TEST_GEN_PROGS += uffd-stress -TEST_GEN_PROGS += uffd-unit-tests -TEST_GEN_PROGS += split_huge_page_test -TEST_GEN_PROGS += ksm_tests -TEST_GEN_PROGS += ksm_functional_tests -TEST_GEN_PROGS += mdwe_test +TEST_GEN_FILES = cow +TEST_GEN_FILES += compaction_test +TEST_GEN_FILES += gup_longterm +TEST_GEN_FILES += gup_test +TEST_GEN_FILES += hmm-tests +TEST_GEN_FILES += hugetlb-madvise +TEST_GEN_FILES += hugepage-mmap +TEST_GEN_FILES += hugepage-mremap +TEST_GEN_FILES += hugepage-shm +TEST_GEN_FILES += hugepage-vmemmap +TEST_GEN_FILES += khugepaged +TEST_GEN_FILES += madv_populate +TEST_GEN_FILES += map_fixed_noreplace +TEST_GEN_FILES += map_hugetlb +TEST_GEN_FILES += map_populate +TEST_GEN_FILES += memfd_secret +TEST_GEN_FILES += migration +TEST_GEN_FILES += mkdirty +TEST_GEN_FILES += mlock-random-test +TEST_GEN_FILES += mlock2-tests +TEST_GEN_FILES += mrelease_test +TEST_GEN_FILES += mremap_dontunmap +TEST_GEN_FILES += mremap_test +TEST_GEN_FILES += on-fault-limit +TEST_GEN_FILES += thuge-gen +TEST_GEN_FILES += transhuge-stress +TEST_GEN_FILES += uffd-stress +TEST_GEN_FILES += uffd-unit-tests +TEST_GEN_FILES += split_huge_page_test +TEST_GEN_FILES += ksm_tests +TEST_GEN_FILES += ksm_functional_tests +TEST_GEN_FILES += mdwe_test ifneq ($(ARCH),arm64) -TEST_GEN_PROGS += soft-dirty +TEST_GEN_FILES += soft-dirty endif ifeq ($(ARCH),x86_64) @@ -86,24 +86,24 @@ CFLAGS += -no-pie endif ifeq ($(CAN_BUILD_I386),1) -TEST_GEN_PROGS += $(BINARIES_32) +TEST_GEN_FILES += $(BINARIES_32) endif ifeq ($(CAN_BUILD_X86_64),1) -TEST_GEN_PROGS += $(BINARIES_64) +TEST_GEN_FILES += $(BINARIES_64) endif else ifneq (,$(findstring $(ARCH),ppc64)) -TEST_GEN_PROGS += protection_keys +TEST_GEN_FILES += protection_keys endif endif ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64)) -TEST_GEN_PROGS += va_high_addr_switch -TEST_GEN_PROGS += virtual_address_range -TEST_GEN_PROGS += write_to_hugetlbfs +TEST_GEN_FILES += va_high_addr_switch +TEST_GEN_FILES += virtual_address_range +TEST_GEN_FILES += write_to_hugetlbfs endif TEST_PROGS := run_vmtests.sh @@ -115,6 +115,7 @@ TEST_FILES += va_high_addr_switch.sh include ../lib.mk $(TEST_GEN_PROGS): vm_util.c +$(TEST_GEN_FILES): vm_util.c $(OUTPUT)/uffd-stress: uffd-common.c $(OUTPUT)/uffd-unit-tests: uffd-common.c diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 9e4338aa5e09..cc2cbc4405ff 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -55,6 +55,17 @@ separated by spaces: test soft dirty page bit semantics - cow test copy-on-write semantics +- thp + test transparent huge pages +- migration + invoke move_pages(2) to exercise the migration entry code + paths in the kernel +- mkdirty + test handling of code that might set PTE/PMD dirty in + read-only VMAs +- mdwe + test prctl(PR_SET_MDWE, ...) + example: ./run_vmtests.sh -t "hmm mmap ksm" EOF exit 0 @@ -298,6 +309,18 @@ fi # COW tests CATEGORY="cow" run_test ./cow +CATEGORY="thp" run_test ./khugepaged + +CATEGORY="thp" run_test ./transhuge-stress -d 20 + +CATEGORY="thp" run_test ./split_huge_page_test + +CATEGORY="migration" run_test ./migration + +CATEGORY="mkdirty" run_test ./mkdirty + +CATEGORY="mdwe" run_test ./mdwe_test + echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}" exit $exitcode diff --git a/tools/testing/selftests/mm/settings b/tools/testing/selftests/mm/settings index ba4d85f74cd6..a953c96aa16e 100644 --- a/tools/testing/selftests/mm/settings +++ b/tools/testing/selftests/mm/settings @@ -1 +1 @@ -timeout=90 +timeout=180