From patchwork Mon Jul 17 10:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1026156vqt; Mon, 17 Jul 2023 03:39:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlGJUp8jr9fVfKzswizsjpcoGlYd8whIV8FUlJeF7wJGVwKNuZ+BRxtqYEu1nmsUd/zHTkWG X-Received: by 2002:a17:906:74cf:b0:994:5577:aef1 with SMTP id z15-20020a17090674cf00b009945577aef1mr8061505ejl.7.1689590364956; Mon, 17 Jul 2023 03:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689590364; cv=none; d=google.com; s=arc-20160816; b=YeZAm8WWUs9kbgSJ4OgPYzKxthLt5p4L9yCN9sRXHN/YLsryZKLqQDUbhENk5iBdS0 W3teHUpcjrnmHhcSJQmepJzP36nuuL5IqHvXBu3b0UquyS2lOe2ebAyO2dFxklFx2wrj 5F+UEmK7xdqv+7+YAuJfIGEL0r+bwP3CApGrtCPTHN6K191OIKrHXcEum/8AgcJsRQVC DEvsKalh3Ik4s90X4d7wGrDT5WrH6KsV03z9D6tjvlOADYMix87FuBe05qYr4ADqsynQ oVONq3dHnmX4cUWJDEe8aZbdmTqPJ6WxGMEacm9DO+kueFILGREgHcJ+ViujnNFZCA4I BrRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4IQ8IXDko9tfglX73dLBnmTqnSbgJyeqxWIDPYOqiN0=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=gdiJXxQIYvA/RBm7UV8yg2ADzq45SsfnJQF7Tt6oQ93jI3h9F74FbNRIVMhYuCXevC jbVq5BP1g+L98zWaymrtge0NucpqF8vg6WfdLauIkTq9TXvrFoQQa0J5mU8ZascyXCtA 1QSR+ZasuN2U4HHYuhDFek09g3WtGpsdZry8evJjEspY+DZeyhpUKDi2fe40+jDaraTI wtTTlnakkIWtH/RMNBX0GSI8DgwYvLFIjA3KgL2w2Nv+hIAMUsct1Oc4lcM5pVYmnZ8b FRNurUDQzs4BjI+iIT1738D7XTspJLXA+TYOssgwJ9kyMuW9OoaVXf86zvKmn/Lckycf o5aQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v25-20020a170906489900b00992e21b04aasi11790567ejq.720.2023.07.17.03.39.00; Mon, 17 Jul 2023 03:39:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbjGQKcL (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjGQKcK (ORCPT ); Mon, 17 Jul 2023 06:32:10 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FE8BE9; Mon, 17 Jul 2023 03:32:08 -0700 (PDT) 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 97EC2D75; Mon, 17 Jul 2023 03:32:51 -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 9E9463F67D; Mon, 17 Jul 2023 03:32:06 -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 v2 1/8] selftests: Line buffer test program's stdout Date: Mon, 17 Jul 2023 11:31:45 +0100 Message-Id: <20230717103152.202078-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771663906663082810 X-GMAIL-MSGID: 1771663906663082810 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. Signed-off-by: Ryan Roberts Reviewed-by: Mark Brown --- 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 17 10:31:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1025458vqt; Mon, 17 Jul 2023 03:37:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlG94FXMX2W5KahgULAJ46q54wXnmAUFVdhbFcvGBamW2qVcdlm5L7idZS04AkvZjgRmf+kR X-Received: by 2002:a05:6512:b85:b0:4f8:442c:de25 with SMTP id b5-20020a0565120b8500b004f8442cde25mr8693447lfv.5.1689590252098; Mon, 17 Jul 2023 03:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689590252; cv=none; d=google.com; s=arc-20160816; b=AdBOhCPfqhzBk59aBTuBniub9vpriDrWQqBurx60cPvXuDlcB4Msu8bR/mgItD2gsS EXPRykl+hZCdOvs1LoelapLJdgPB1vPFa0rRbmZi8KkdDsbr8OYqPF59MS7g7eW34FRg DKhna0ayLIsqDLT6xvsQjGe+yh1gIkot7GWrkSkAZyi5yuEv6cZdV80+vtClYMhgLbpO 2OhfeyNivF6lbAhJdmqbvbQaQ8EWLFlWnsRxTIZ7jikzY5y+Qlx23NaZra/6dcqRMsEK QnK5ValyafOXJ3Tk4EyxRvaXu22gYkjiNofE+LI2gYrfRA8MwdvErqggg8qB3oWrCruQ ud1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OhDfs2rBRxa6sjKAOBnl3G00rvbgCnvO7zVueRIMeN8=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=MXhk9Hp2ng7nXGd8VxAN7iy3snApjjx2qC7eEvirAfQKQzQQWySb/ScuUnHu2luUfF X7+5ba6uwB/LhpcK7MPYGAAegr/XAwb3iyL+EYBwjLvhaYfqjghfh8ZytfvCyXYIe9CZ 1SDhqA6Ng+XhCgCInpN2oSrK1wvsy65TP8Hi60W8D8I9bSVLeHCvmGjTrz9o+yghIAvm jPqxU283ZjaN49WW9uvbJ4RqGmsXKjkfoHKnExd+fTr9CkgpRFKXEeCjLfmoT8EqRgfJ I0UgttwXdbRSfoWaMiYuoSI5HcNRn0A2mdNaAZ8ooRVZ9xsMH4f3/rLzXyUI+6fB9ZuB DU0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g23-20020a056402181700b005187aee0b5esi7226828edy.396.2023.07.17.03.37.09; Mon, 17 Jul 2023 03:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbjGQKcO (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230062AbjGQKcL (ORCPT ); Mon, 17 Jul 2023 06:32:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 89357A6; Mon, 17 Jul 2023 03:32:10 -0700 (PDT) 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 8D7CE2F4; Mon, 17 Jul 2023 03:32:53 -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 930F33F67D; Mon, 17 Jul 2023 03:32:08 -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 v2 2/8] selftests/mm: Skip soft-dirty tests on arm64 Date: Mon, 17 Jul 2023 11:31:46 +0100 Message-Id: <20230717103152.202078-3-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771663788550485891 X-GMAIL-MSGID: 1771663788550485891 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 Acked-by: David Hildenbrand --- 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 17 10:31:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1025487vqt; Mon, 17 Jul 2023 03:37:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlG6MGyuenbLc52thfp6kgfRpm5ee8kw+8+1azWmyKjnBoea0rtxQwCE1MOnlRQ/u4sRDj04 X-Received: by 2002:a17:906:3f54:b0:97e:17cc:cc95 with SMTP id f20-20020a1709063f5400b0097e17cccc95mr8618389ejj.36.1689590255475; Mon, 17 Jul 2023 03:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689590255; cv=none; d=google.com; s=arc-20160816; b=HKEf6Mc4gDWHlDAgLSvAL3ZPao0E7Putf0hi/RY0V8Fp/8+DE8h81kO1bJcZ5g/u6k qQRQMOHjEWz1MqqLlmXOygevVFH0LdQPaRn7BbUSjmuTvoDciZkmpviKW2qENPVdwu/i z1hOuYqUEHhQ3BOB4L855mV0mXhKHPMZgB6lLkndzOXgCbcHbzcB5+7g2tnW7tX+Imk+ JMuP4vRm+8UOGDJnnHmHQAE8OOGhg++rmj5/9eHvuNotI6Q/PwkV7PlU+wYv3IUxa8v+ k8wzKTrQJSEc1bFyHMpqfHfAj2G9p7q0zA+XChrZY6AsZ9uBq/Ss0nPyQiJnzVHjJQ6N DnnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=W95hEJNsKwhNPSMzODBmivBuPCYdlHmjU8Wbx+BJ5Yw=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=Qryv47dsaEzz5yo/RO8DBAN1zXbLmPUie4VUvbi6NxoWBkyyJHNc2UbW0lAiAeeOpo v4fhPH91i+ceXtCqNx7eBvrzYvUT92digYGV/51KDZH2ZXiTDt6J1XWOtktNhqJCLR1G kvEYH5ZGVhS00rM+QBbXzgQDvV6uUGCBZVZEt4lUEcm2iZp0gsPgS8tp78AaRKNvB9M6 3cLnW+M2pjE+VkvrZRNU0pYfFY0SrLoHddzwlr4+XjYGHFqliaFH9mlVb33lJ6DAVsCa JsepRLl5og7+r98S7rEInmhpxpOzHr1txpIHy4ZFQU1TUgE+woHdK3mTS4WMdzVjVJel YYsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kg17-20020a17090776f100b0098874379199si13157696ejc.163.2023.07.17.03.37.10; Mon, 17 Jul 2023 03:37:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbjGQKcR (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbjGQKcN (ORCPT ); Mon, 17 Jul 2023 06:32:13 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7338D118; Mon, 17 Jul 2023 03:32:12 -0700 (PDT) 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 803E4D75; Mon, 17 Jul 2023 03:32:55 -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 872443F67D; Mon, 17 Jul 2023 03:32:10 -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 v2 3/8] selftests/mm: Enable mrelease_test for arm64 Date: Mon, 17 Jul 2023 11:31:47 +0100 Message-Id: <20230717103152.202078-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771663791658981574 X-GMAIL-MSGID: 1771663791658981574 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. Signed-off-by: Ryan Roberts Reviewed-by: David Hildenbrand --- 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 17 10:31:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1030166vqt; Mon, 17 Jul 2023 03:50:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlHxA2eFJwdmmiMKMnRQ6RfvTBGl5Rh25xiBfa0ZKzMyCf0ld3w8x7W8Qh/lWLGVRg9OZ7MF X-Received: by 2002:a17:902:e74d:b0:1b8:95fc:d19 with SMTP id p13-20020a170902e74d00b001b895fc0d19mr13234388plf.52.1689591035636; Mon, 17 Jul 2023 03:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689591035; cv=none; d=google.com; s=arc-20160816; b=Cl2Hem7dSuV6xKJMCgeLdYLbpnNuOV3+6PLFjs3GOPcLZNyMrUKWPxh2mD2/yp13hG 3rrtmZncTq4sJg1KaGf8MV/vdVyztAX2LKa3P8GZ5pfowuj9Q8pxUGQfcl42yyw1JOfV NK+H555DCsuyk0BLjNCicziFZApVPECMQuZXbCJYhDIlzOMETY1TbgZW4vncnRfOiVMt gML1KaTGPqfKxnFT0EnGwUybuQkAa2L5cAfPvDuo6tumzjV8RA3jyxSExYeSrS2L0t8w Ehw4aMqDV1hKiLcuKobjt9crEGCE1Eb2SQOA4ZeautTsKsh1N6wrjb0JpfBrUs8OjLfT NQSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/uEzG53FLjd2glqlFJWx0HAfJNrq3vkp38/U3IednXU=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=qW6qCqVo0gfjSXBf6E2he21tfchY1IRnd+ZLrMyJxCcL787YWgy6Fpj31DeeggVTGD UMFnbcXsWCGTq1ruQn5besPisB6efvLfaHD6ALBVlwaPdg3NTd4Abh8yHMd7mXjswBVE fSjHjj9q0TMdGF57j7yT5G99S7ok4GU3ipEcmy+nxwO5P2XBTaboUT6d9yYWO8/jIYH5 Xbq9FFqKSkcbaL0iwCotgsvuhP2HBNCoNU4sXAzehKc9LzazxI81tjsm5ogivymOsfUK ii3iSP0P64ibCxBN2zB2tPA1yywAvR3wQrfROicKkpsdDNdwhowZGQcTX4llwGxqA5sA O+Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kf12-20020a17090305cc00b001b9d03d0bdesi6516326plb.79.2023.07.17.03.50.19; Mon, 17 Jul 2023 03:50:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbjGQKcU (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjGQKcP (ORCPT ); Mon, 17 Jul 2023 06:32:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 65D26A6; Mon, 17 Jul 2023 03:32:14 -0700 (PDT) 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 7416A2F4; Mon, 17 Jul 2023 03:32:57 -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 7B42D3F67D; Mon, 17 Jul 2023 03:32:12 -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 v2 4/8] selftests/mm: Fix thuge-gen test bugs Date: Mon, 17 Jul 2023 11:31:48 +0100 Message-Id: <20230717103152.202078-5-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771664609866576072 X-GMAIL-MSGID: 1771664609866576072 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. Signed-off-by: Ryan Roberts Reviewed-by: David Hildenbrand --- 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 17 10:31:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1038229vqt; Mon, 17 Jul 2023 04:08:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlE+kV45M2Q9ge6kLTFfJRxlghONYpSGWJPDLTERqjSK/b4JRsiO+Pgu946GwR+l2c6+vuZl X-Received: by 2002:a17:907:1003:b0:993:c48f:184c with SMTP id ox3-20020a170907100300b00993c48f184cmr9766060ejb.10.1689592089887; Mon, 17 Jul 2023 04:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689592089; cv=none; d=google.com; s=arc-20160816; b=QqezUt+DTMfgUS9Z/N3Fxkbl/4AjkSuTlCLlownGrixzMpHP8uTiFTpfTRMQfr187G AwBBGLpRU5KhY5cb2OfIzqvlVF9TthTWgvGIwMBM5mf0hYybkplzbI1y0xqYqg6p2upx aQrYkHpt+3wcGQyS/u3PmKEmDHbdKX3nmQpDKo4H14vpoojVLNiVwyfgreWxNxHFbrHB YmrsXOJoSA7YkO1ijx/UH8WklTLiCKVzY2n9GQ7+V8ADjvZGE/7isOAjZXobqP8viCvI 7sHiWY/FagReEh4hKNm/EHGBRc+s42oXNiIfWHyH9HY8+74pcm5Ovvaw82mbEuqvsjR2 pKlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dNlBjDfq+AmKtLS3RpRye5O1GUWvdXIGLiTgWzCy/u4=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=XlOAlW077c1g10detgp9Md76lTZ8u9uKs/Di8nHFCvxdHMtGWh8h7gd9/IqYI7JtRc O/MWfnvukh61/O1aWxeZn0yAYzB+1uvKwBZphbPJOK/q+oN//NMWQdjJLeOEDB6kZWK+ i0ZAXwpX0uzjL4HpPEMJUBi9AUx9XDgw53L+PUaRlp9SVEgkwvX9nwXyEawJ925t1Op1 6kTo3BOBGFUh4gSOC0mhH/bajcY6Tk9kpOU2kWYRMqXCE5D4UJZQ30HoOO4ZB0TL0gbv jyRWKLVkwTeEMb1v8NE6cn08RxKZLSVNQV5aIhPA4f3m+Cd1y8iIcs/0U7DcnRi+dXfK qLIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id op19-20020a170906bcf300b00988d6a7cdefsi13326122ejb.212.2023.07.17.04.07.46; Mon, 17 Jul 2023 04:08:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbjGQKc1 (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbjGQKcU (ORCPT ); Mon, 17 Jul 2023 06:32:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BC9A910C0; Mon, 17 Jul 2023 03:32:16 -0700 (PDT) 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 685612F4; Mon, 17 Jul 2023 03:32:59 -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 6F4F93F67D; Mon, 17 Jul 2023 03:32:14 -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 v2 5/8] selftests/mm: va_high_addr_switch should skip unsupported arm64 configs Date: Mon, 17 Jul 2023 11:31:49 +0100 Message-Id: <20230717103152.202078-6-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771665714986396244 X-GMAIL-MSGID: 1771665714986396244 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. Signed-off-by: Ryan Roberts Reviewed-by: David Hildenbrand --- 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 17 10:31:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1026356vqt; Mon, 17 Jul 2023 03:39:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlG5b/MvcbxW4zO82MWiq1QIwgSswQxbIg0Y4U8HwpOIDXntrXKMkjRp2OdSv+co1+amcOa1 X-Received: by 2002:a17:906:10cd:b0:98d:e696:de4f with SMTP id v13-20020a17090610cd00b0098de696de4fmr11595194ejv.26.1689590396007; Mon, 17 Jul 2023 03:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689590395; cv=none; d=google.com; s=arc-20160816; b=ALaf1vcBRBzzpqTuIQYmvrMC+ByL7+dHGsdm7av6v6XAk4O6ARqFO7z2gWVcmD9sf0 thwlJGqiW+L5cBBiLulXt7GQ64V1BdTziiv9a6H2DlIQl5LEXgFjtAd8luK1EJwv8t3L EMnzUbV8r7KQeiFy/fCEv6Lhfw4p3A2Vep+Ci/L1cxshq6jD6Gqk6HllIT28GqC8zlQy ylOzo1CmcS06GaYc3RSzCaaPyqnBnjyzx709+xAeIx2X3egrhDX3f6I+cssHIhB8ODpo iu6stbt9xFF79ADNATeCSmy0IMN60ue4+B6qFYE5OOIuR6l20PC8vGiTp74dDM4NOaTf vEJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rHtD/pnAHEzhlHxmKN5MIBCps4aYfm1NZFwHzfIO8rs=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=OGT9bt/OAqvJ1LLVv4gZy6mmDdosZFMq3z3fCqiPSF4qH1pExgtgYuGi+GL99YNMfR GNUYduNZdqE8pnXzZCX9uWL0XLRQXIue1pD4uVgy+QqLLmuFSpkt3Wwrhyu6QrtOoCtw pGaQhP14B6OYHe6EEfJIT7y7RIgpEme8UIHX7Ipip/Le61kzjT9JHWNcnwzSjswNJiuB vTTGwsFgAWgkd1RDxHQS19ychW+YlpversurYfW72ZKlBnv4Jiw548jx9FB5l/D5zW1+ u9kZTUfsgQ1ZQ51qwhI7EmJvlpuIxJw42+PW5HQ85ehrnbaPeBjOa1zoR+OKzh9JGgPl +Fmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb4-20020a170906b88400b0096f81ae0ac9si13377040ejb.34.2023.07.17.03.39.32; Mon, 17 Jul 2023 03:39:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230338AbjGQKc3 (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjGQKcY (ORCPT ); Mon, 17 Jul 2023 06:32:24 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 87CB110DA; Mon, 17 Jul 2023 03:32:18 -0700 (PDT) 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 5DE7F11FB; Mon, 17 Jul 2023 03:33:01 -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 639333F67D; Mon, 17 Jul 2023 03:32:16 -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 v2 6/8] selftests/mm: Make migration test robust to failure Date: Mon, 17 Jul 2023 11:31:50 +0100 Message-Id: <20230717103152.202078-7-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771663939060580155 X-GMAIL-MSGID: 1771663939060580155 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 deferring any asserts until after the children are killed. The same pattern is used for the threaded tests for uniformity. 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 --- tools/testing/selftests/mm/migration.c | 14 ++++++++++---- tools/testing/selftests/mm/settings | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c index 379581567f27..189d7d9070e8 100644 --- a/tools/testing/selftests/mm/migration.c +++ b/tools/testing/selftests/mm/migration.c @@ -15,7 +15,7 @@ #include #define TWOMEG (2<<20) -#define RUNTIME (60) +#define RUNTIME (20) #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1))) @@ -118,6 +118,7 @@ TEST_F_TIMEOUT(migration, private_anon, 2*RUNTIME) { uint64_t *ptr; int i; + int ret; if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0) SKIP(return, "Not enough threads or NUMA nodes available"); @@ -131,9 +132,10 @@ TEST_F_TIMEOUT(migration, private_anon, 2*RUNTIME) if (pthread_create(&self->threads[i], NULL, access_mem, ptr)) perror("Couldn't create thread"); - ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); + ret = migrate(ptr, self->n1, self->n2); for (i = 0; i < self->nthreads - 1; i++) ASSERT_EQ(pthread_cancel(self->threads[i]), 0); + ASSERT_EQ(ret, 0); } /* @@ -144,6 +146,7 @@ TEST_F_TIMEOUT(migration, shared_anon, 2*RUNTIME) pid_t pid; uint64_t *ptr; int i; + int ret; if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0) SKIP(return, "Not enough threads or NUMA nodes available"); @@ -161,9 +164,10 @@ TEST_F_TIMEOUT(migration, shared_anon, 2*RUNTIME) self->pids[i] = pid; } - ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); + ret = migrate(ptr, self->n1, self->n2); for (i = 0; i < self->nthreads - 1; i++) ASSERT_EQ(kill(self->pids[i], SIGTERM), 0); + ASSERT_EQ(ret, 0); } /* @@ -173,6 +177,7 @@ TEST_F_TIMEOUT(migration, private_anon_thp, 2*RUNTIME) { uint64_t *ptr; int i; + int ret; if (self->nthreads < 2 || self->n1 < 0 || self->n2 < 0) SKIP(return, "Not enough threads or NUMA nodes available"); @@ -188,9 +193,10 @@ TEST_F_TIMEOUT(migration, private_anon_thp, 2*RUNTIME) if (pthread_create(&self->threads[i], NULL, access_mem, ptr)) perror("Couldn't create thread"); - ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); + ret = migrate(ptr, self->n1, self->n2); for (i = 0; i < self->nthreads - 1; i++) ASSERT_EQ(pthread_cancel(self->threads[i]), 0); + ASSERT_EQ(ret, 0); } TEST_HARNESS_MAIN 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 17 10:31:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1036273vqt; Mon, 17 Jul 2023 04:04:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlGw+YcgyxzFpoO+nG18/yzlSrIvjTyJsP4jMetLWfsx8KKukHJLth0kftjV/tKzf8OzC5bo X-Received: by 2002:a05:6512:3143:b0:4f8:67a5:94df with SMTP id s3-20020a056512314300b004f867a594dfmr6818177lfi.15.1689591880488; Mon, 17 Jul 2023 04:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689591880; cv=none; d=google.com; s=arc-20160816; b=JU/MXav8JB4hG/7sfXSjIgQkxtRKYEXNjXFmiqZXA6HSmuOqxwjfoCyyGAjhssVYY/ Kos2ml5Stw8MVG7Zblbx46V3hRrZDvwJmtu/QG2GS4LW1AnuaMrxNb1l95DbTU2n2z25 fkQLTkgjBx95s758MUgMKh9fRtOaP/AeAsBPjFDdRi50uGQYGzm23jvTCgL2oMSpJQok p2rGDc3O2L6Cudg/nPRpBAZidTdrvXUuBcjsK9uSB43GHw0tvvy/+bl2D5a+EPvJceuV ZCd0VvIXOMTOXRxySbD4RUNqgxNaiu06mZNCGYukCmkY1+/S/OOd/5qlpeZ29SeIAoJP 7hkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HXaz2BG8nd6sNHnpf1UWxQkbMfGOr+JlGHxrRhsm3QQ=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=fcGVzXajmflntKYv8A5MCIHm2I9cJaaAn1SlhttS6hQNtnAxtGr03LinR9Ufw8eiMu VV1nw7fkOuDaTuBavcVinoOUMBkfQmK4jiMA5gd+DWERNI0EcEP/StkGgWdETLsNT5IZ u8YjnF5VmVBsiJTBtZ39fZBZIeHozhbkzbMWVloT2oIAyS/rKBkAAq2tSf3nRMO5i2H0 Yk+pwG5gjpZkjhmgwVwBqYNjTkRmRwamahAQkFp4rbcn2rKGwf/lKSUIitsNRQ/s4nnd cxeRK+aTT2b/nqIH49XBbqRfLQVlwPAjEidRJbjKbczJ8/FmYVp1LfAMDmleZpg95Vs+ adHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020aa7d398000000b0051dd3e8fc91si12625955edq.67.2023.07.17.04.04.16; Mon, 17 Jul 2023 04:04:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbjGQKco (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjGQKc2 (ORCPT ); Mon, 17 Jul 2023 06:32:28 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BBB14E7F; Mon, 17 Jul 2023 03:32:20 -0700 (PDT) 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 50AD12F4; Mon, 17 Jul 2023 03:33:03 -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 578983F67D; Mon, 17 Jul 2023 03:32:18 -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 v2 7/8] selftests/mm: Optionally pass duration to transhuge-stress Date: Mon, 17 Jul 2023 11:31:51 +0100 Message-Id: <20230717103152.202078-8-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771665495618719758 X-GMAIL-MSGID: 1771665495618719758 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. Signed-off-by: Ryan Roberts Acked-by: David Hildenbrand --- 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 17 10:31:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 121206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1036945vqt; Mon, 17 Jul 2023 04:05:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlGvcirP4em0mLnWj5OVDxQClsX45aek/D/O4OSlZt6ZN++qZ3Fp3qGBVpqn+kNXoFvKUUCw X-Received: by 2002:aa7:d605:0:b0:50b:c085:1991 with SMTP id c5-20020aa7d605000000b0050bc0851991mr12200910edr.19.1689591947195; Mon, 17 Jul 2023 04:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689591947; cv=none; d=google.com; s=arc-20160816; b=JzesFlYXhYbus1d19hJvTEP/BL4X+vFm691xJEgGnrxD98wSoY9dGa8AcsSZKzKlWW zYK8f1m6shFKlrkZC92gVXvNdu2Gmb9zwpMlmEbXKPC7b+NyZZrpovYbdgO+QTenEyzB tA0WrebQ9vtAZ9DaSHOq0giS+y3wAGhvUJfPYbcxqotDhacgKkkc7R7REJ8PoxtjQbdX BO8c+8BmrGhzH1sheZ/wJ0eCM1CBvQqv6w57nYP3EJrcvNgWSA031UAwEoz7S701YFhS YaDJOdZaVzYsWTmRfR2eNVYLHjwkbYDTTJMpImenV439uWQt3cRjEglJoGG4QU7m2WdH lxew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rQ/yQh59/qrckarEtbcXWsGAbVL9grbrJM92PTJUxc4=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=cdfwFNE4sEiBWfadgdlx5MmwaH+l8EdE9i0HcRn55T52GMzbHYyMo2GercTe7qXJxM j+xorkiV2RvAbYgQjh2ztqKrAue0s9kADVflCnOuOA4+SzV6SYbDhp/3ZxLwE7ZAkrjP wpQVaTfA109bToiwngRhx/bm0+egVQu+tvbDLVqSksjB7T+N/vczMLe6AuKRI7KCjk/i trmTF0EBbh25qAQJkmyGsZA9JTVQvityZxmZywr1Kub2jPAkXeoTtl0dgBws1fnfwaZ/ RVC2ikmQixYCJh85meVL0B8Hlzd76kPZ1w3nL6KJ6L+GWHwww4SrnbWc0P/lXxLwy+ug 8udA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i22-20020a056402055600b005217421a386si4148913edx.201.2023.07.17.04.05.21; Mon, 17 Jul 2023 04:05:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbjGQKcq (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbjGQKcb (ORCPT ); Mon, 17 Jul 2023 06:32:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EB89210FE; Mon, 17 Jul 2023 03:32:22 -0700 (PDT) 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 62C32D75; Mon, 17 Jul 2023 03:33:05 -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 4BFF43F67D; Mon, 17 Jul 2023 03:32:20 -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 v2 8/8] selftests/mm: Run all tests from run_vmtests.sh Date: Mon, 17 Jul 2023 11:31:52 +0100 Message-Id: <20230717103152.202078-9-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771665565619888497 X-GMAIL-MSGID: 1771665565619888497 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). Signed-off-by: Ryan Roberts Acked-by: David Hildenbrand Acked-by: Peter Xu --- 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