From patchwork Thu Jul 13 13:54:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1855131vqm; Thu, 13 Jul 2023 07:15:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlGn8o2IKaurD6n+7iY6bav6KHyPTi75isNYaj31t/BLGbX9c1eLVQt7a0ogk2/PSEygzhw3 X-Received: by 2002:a2e:b614:0:b0:2b6:faaa:fb53 with SMTP id r20-20020a2eb614000000b002b6faaafb53mr1456692ljn.26.1689257722188; Thu, 13 Jul 2023 07:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257722; cv=none; d=google.com; s=arc-20160816; b=IAqRszVG3qI6qeRN40/9KyZCN097JIRsA0fwohEbJCmmJmSLYGA+NQrUMzi8Yjj0H4 PUpYYI1RpkAmj4N3DAu0lZQrLpdisEDe8GsmBRxB78hXvY78dDZgcpjOilFuq7at9xaB ezOfShMuPq5Z3JfUExyXe9g9kBOnd+IO1UhLaaVpkoRGnhlP99EUGBrYk6Mysa2C+tXP j2S09CDNN0QYmZ622oH+RA4dBcdsuzIECVU1QwwlEkKmaylcHfxpJz/02QAQC7m6TIFH 86O6Hd+zfy/vLtNE2DLsX4FmoLL1IYtHP2DO6UqrKIMeF0hhRPCTenPpb3bkPnwBk6C9 DGsg== 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=1UY/dJEooJnNbfAHm7UE9cYo3rXDScw1JA9mM8Arq2c=; fh=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=VGZt17xPYM62ad1cQLe54Qwi5lbIJEfsEx6V7RsCcwfY6v0axYFHnK2FUp4uNtCxON 4TFOT17FzzWVJPuH+npb9euzgLWX+zTgLfD8NAOBc8ei6J5obNHybQcKYHdjdaDmxlVD Jh2IkP5L5nNBGjIqAoBpNCaVw9mbIlXNNryMjSJtFHY7WapNEXENQ6B0gg2pwE5l5BNE 3pIanNsOlgtc2w9c+6fu2UdRS+3zTkOS8Kj/LH1cYKij3D4dOoJN7RrhAENNZpx6rWRd sR3tsbNif8BQNg1mOW3QYfnMdu8PQlCuIQV1GwmDX7t+zDP3OP35Z+x/nxqgJQOfHiMX 57kg== 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 o14-20020a170906358e00b009920ac37832si7244074ejb.504.2023.07.13.07.14.57; Thu, 13 Jul 2023 07:15:22 -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 S231799AbjGMNy6 (ORCPT + 99 others); Thu, 13 Jul 2023 09:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbjGMNyx (ORCPT ); Thu, 13 Jul 2023 09:54:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D3181992; Thu, 13 Jul 2023 06:54:52 -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 B25D71576; Thu, 13 Jul 2023 06:55:34 -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 A829D3F73F; Thu, 13 Jul 2023 06:54:50 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 1/9] selftests: Line buffer test program's stdout Date: Thu, 13 Jul 2023 14:54:32 +0100 Message-Id: <20230713135440.3651409-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771315105480991985 X-GMAIL-MSGID: 1771315105480991985 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(). Signed-off-by: Ryan Roberts --- tools/testing/selftests/kselftest/runner.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 1c952d1401d4..cb2b395ae296 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -105,8 +105,11 @@ 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" From patchwork Thu Jul 13 13:54:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119933 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1856893vqm; Thu, 13 Jul 2023 07:17:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlGnLwDM2Sqm7VmOTLWGTcdRY7jFQbl7/9AbJcA1iNAg4D9dxbrEB8D5VHXMAkxiugufRF5i X-Received: by 2002:a92:d44b:0:b0:345:3378:4258 with SMTP id r11-20020a92d44b000000b0034533784258mr1352274ilm.30.1689257861501; Thu, 13 Jul 2023 07:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257861; cv=none; d=google.com; s=arc-20160816; b=yG9TkpBhLaHR/z3+37NM3AxwY1XPZM3LYsuCIdb7wBzY/iNgYzXaHWuTHMu69wbSFj D4GzTa3Wn7pLaN/DF79i7DzmCpByyaa5MfchBhjV0zphzjkKtgSAFTQCdXC7Vn3hSu8K D0n1vugEKQAiN6MZFLTCfQeonQ3OdD47eooVjA+AvaZuQcBu0UBh+CDtwwN6x3D6/Wmf ZDRDWxNjI7IAwnfTqjpqY3uVeXc6UoeHFf/sn8pxE5RZvt5MSM0J/SSxpd+9DcHYtI3z gwLJOHw6mwtXmUuwWyVjmPVv4e+hqGiPpDDPNGBJRiC/mjEwoxuKU1mxEzw0dbSdEQIR YG9g== 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=yIADLCW8ozAl6AFw8ZxNQyL6kxz5rjSce+zRJErHvIk=; fh=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=J3Tl45k/k5hjrDb8YGlUCa97XYg4E9+qXZyjGmifuFSZjdlzwYEqcHlVT+1qCxJGgq 7qc9ZogXtJGb7XaDYaFtqXknWUmdBz9sBRtF7VajXUssFb95rBWq79kSPElYoEWaE9qV Iyq/vN9k+GKSTv1q/PdjOYiMyevVCTC2fbutUs2YLSXQyqLHlIRF2NssF5EeByYIpX6A gkoJe68U3UYuxxdfSPjrE9GBmcKSTy5b8G9LQdRsswqAueFJaKiYyh1loNVXr7WZrKuV +b2Rj918vbVc+qT7NxDnq+wHkORs2Y7FFSrpKPkMd61HZRHlvC7wKlvnY6Z9gCdeLooI OjAQ== 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 i17-20020a17090ad35100b0024e3527e8e9si12991465pjx.9.2023.07.13.07.17.26; Thu, 13 Jul 2023 07:17:41 -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 S231818AbjGMNzC (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbjGMNyz (ORCPT ); Thu, 13 Jul 2023 09:54:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DFBD1992; Thu, 13 Jul 2023 06:54:54 -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 75C6C1595; Thu, 13 Jul 2023 06:55:36 -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 6BABF3F73F; Thu, 13 Jul 2023 06:54:52 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 2/9] selftests/mm: Give scripts execute permission Date: Thu, 13 Jul 2023 14:54:33 +0100 Message-Id: <20230713135440.3651409-3-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771315251178500947 X-GMAIL-MSGID: 1771315251178500947 When run under run_vmtests.sh, test scripts were failing to run with "permission denied" due to the scripts not being executable. It is also annoying not to be able to directly invoke run_vmtests.sh, which is solved by giving also it the execute permission. Signed-off-by: Ryan Roberts Reviewed-by: David Hildenbrand --- tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 0 tools/testing/selftests/mm/check_config.sh | 0 tools/testing/selftests/mm/hugetlb_reparenting_test.sh | 0 tools/testing/selftests/mm/run_vmtests.sh | 0 tools/testing/selftests/mm/test_hmm.sh | 0 tools/testing/selftests/mm/test_vmalloc.sh | 0 tools/testing/selftests/mm/va_high_addr_switch.sh | 0 tools/testing/selftests/mm/write_hugetlb_memory.sh | 0 8 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/testing/selftests/mm/charge_reserved_hugetlb.sh mode change 100644 => 100755 tools/testing/selftests/mm/check_config.sh mode change 100644 => 100755 tools/testing/selftests/mm/hugetlb_reparenting_test.sh mode change 100644 => 100755 tools/testing/selftests/mm/run_vmtests.sh mode change 100644 => 100755 tools/testing/selftests/mm/test_hmm.sh mode change 100644 => 100755 tools/testing/selftests/mm/test_vmalloc.sh mode change 100644 => 100755 tools/testing/selftests/mm/va_high_addr_switch.sh mode change 100644 => 100755 tools/testing/selftests/mm/write_hugetlb_memory.sh diff --git a/tools/testing/selftests/mm/charge_reserved_hugetlb.sh b/tools/testing/selftests/mm/charge_reserved_hugetlb.sh old mode 100644 new mode 100755 diff --git a/tools/testing/selftests/mm/check_config.sh b/tools/testing/selftests/mm/check_config.sh old mode 100644 new mode 100755 diff --git a/tools/testing/selftests/mm/hugetlb_reparenting_test.sh b/tools/testing/selftests/mm/hugetlb_reparenting_test.sh old mode 100644 new mode 100755 diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh old mode 100644 new mode 100755 diff --git a/tools/testing/selftests/mm/test_hmm.sh b/tools/testing/selftests/mm/test_hmm.sh old mode 100644 new mode 100755 diff --git a/tools/testing/selftests/mm/test_vmalloc.sh b/tools/testing/selftests/mm/test_vmalloc.sh old mode 100644 new mode 100755 diff --git a/tools/testing/selftests/mm/va_high_addr_switch.sh b/tools/testing/selftests/mm/va_high_addr_switch.sh old mode 100644 new mode 100755 diff --git a/tools/testing/selftests/mm/write_hugetlb_memory.sh b/tools/testing/selftests/mm/write_hugetlb_memory.sh old mode 100644 new mode 100755 From patchwork Thu Jul 13 13:54:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1853480vqm; Thu, 13 Jul 2023 07:13:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlFD4qdZWfnpgiP1XBy1Md3cIq6/LmQCO0I0O52omEZFjBSpovwIsp13xyJgLZb108X+7Orf X-Received: by 2002:a05:6512:3d22:b0:4f8:5dd2:21f5 with SMTP id d34-20020a0565123d2200b004f85dd221f5mr1567675lfv.67.1689257583570; Thu, 13 Jul 2023 07:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257583; cv=none; d=google.com; s=arc-20160816; b=kt9MbRa5BZwozjSXjc/3aonAau/PwMgkCRr2+c7sr//5fE5P8RzZpCAeZ1/GGm7RpN txZHmyL8Od8yJM9Y7WG4kY+5a9WHzHa0dFNsd9Ado/wbHZZtmlq7zq/FcRGW/pvfFave jsvRckDJ/DVKhuQoXxH4eGXj6kdqjw+gi9GThgDgyPsneO9W78CVQ7Xy7YbkX9Qu6KWB X6eN0wZeBRuE4es8wOq3dzTVLK0mLSkWEuSfZvlfCRl/K+XDgiYRpjwho01bhi2C1N5g QS//NxzXfcZjGWVZKIuVKAwz+lM/H4r2zoZWBBXEbqnmUCnDrzzhorGQQwyDO7cbg+UZ 2WlA== 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=EOmj+hjrtgQIQSn4ZRGZjPSIqR/XjaDog302aSVz6lM=; fh=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=rclkK28TE5+XM7ivEZbKbloVF2OQ3NjFQJMycoedDpNA0i/ueGbopzCDs6UOlKgjmR fb6fK5q+kFU601Z6h0w6cVwYWtKw0LewjZ2VvwS5o2guW6VAIOlC8RaUAhz33s1W0Ajg IdkZb3KOo6s1U/K1auvNzvxUYvMjP3LAs9CBAvcEP+ZjuSOyGyzJP8ug5uo9QxJCQyK5 je1OurE9KKZnDlpCas/k2Lv1rYF6Erzjx43hR07zfEQImDiYfUoyKxuZrbJD9X7O/OS/ MlewLELjzJhALwH8d1BVJ+QkSIw/4aC/FN/iM9enJKXp9UffJoQlRZa1gHKTjOpkxQIj OEvA== 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 n22-20020a056402515600b0051e0fc05591si7083122edd.526.2023.07.13.07.12.39; Thu, 13 Jul 2023 07:13:03 -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 S231905AbjGMNzE (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231617AbjGMNy5 (ORCPT ); Thu, 13 Jul 2023 09:54:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E71781BB; Thu, 13 Jul 2023 06:54:55 -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 3B9D61570; Thu, 13 Jul 2023 06:55:38 -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 2F5A53F73F; Thu, 13 Jul 2023 06:54:54 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 3/9] selftests/mm: Skip soft-dirty tests on arm64 Date: Thu, 13 Jul 2023 14:54:34 +0100 Message-Id: <20230713135440.3651409-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771314820006044300 X-GMAIL-MSGID: 1771314959824911884 arm64 does not support the soft-dirty PTE bit. However there are tests in `madv_populate` and `soft-dirty` which assume it is supported and cause spurious failures to be reported when preferred behaviour would be to mark the tests as skipped. 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. This is wrapped up into a utility function `system_has_softdirty()`, which is used to skip the whole `soft-dirty` suite, and mark the soft-dirty tests in the `madv_populate` suite as skipped. Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/madv_populate.c | 18 +++++++++++++----- tools/testing/selftests/mm/soft-dirty.c | 3 +++ tools/testing/selftests/mm/vm_util.c | 17 +++++++++++++++++ tools/testing/selftests/mm/vm_util.h | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) -- 2.25.1 diff --git a/tools/testing/selftests/mm/madv_populate.c b/tools/testing/selftests/mm/madv_populate.c index 60547245e479..5a8c176d7fec 100644 --- a/tools/testing/selftests/mm/madv_populate.c +++ b/tools/testing/selftests/mm/madv_populate.c @@ -232,6 +232,14 @@ static bool range_is_not_softdirty(char *start, ssize_t size) return ret; } +#define ksft_test_result_if_softdirty(cond, ...) \ +do { \ + if (system_has_softdirty()) \ + ksft_test_result(cond, __VA_ARGS__); \ + else \ + ksft_test_result_skip(__VA_ARGS__); \ +} while (0) + static void test_softdirty(void) { char *addr; @@ -246,19 +254,19 @@ static void test_softdirty(void) /* Clear any softdirty bits. */ clear_softdirty(); - ksft_test_result(range_is_not_softdirty(addr, SIZE), + ksft_test_result_if_softdirty(range_is_not_softdirty(addr, SIZE), "range is not softdirty\n"); /* Populating READ should set softdirty. */ ret = madvise(addr, SIZE, MADV_POPULATE_READ); - ksft_test_result(!ret, "MADV_POPULATE_READ\n"); - ksft_test_result(range_is_not_softdirty(addr, SIZE), + ksft_test_result_if_softdirty(!ret, "MADV_POPULATE_READ\n"); + ksft_test_result_if_softdirty(range_is_not_softdirty(addr, SIZE), "range is not softdirty\n"); /* Populating WRITE should set softdirty. */ ret = madvise(addr, SIZE, MADV_POPULATE_WRITE); - ksft_test_result(!ret, "MADV_POPULATE_WRITE\n"); - ksft_test_result(range_is_softdirty(addr, SIZE), + ksft_test_result_if_softdirty(!ret, "MADV_POPULATE_WRITE\n"); + ksft_test_result_if_softdirty(range_is_softdirty(addr, SIZE), "range is softdirty\n"); munmap(addr, SIZE); diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c index cc5f144430d4..8a2cd161ec4d 100644 --- a/tools/testing/selftests/mm/soft-dirty.c +++ b/tools/testing/selftests/mm/soft-dirty.c @@ -192,6 +192,9 @@ int main(int argc, char **argv) int pagemap_fd; int pagesize; + if (!system_has_softdirty()) + return KSFT_SKIP; + ksft_print_header(); ksft_set_plan(15); diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c index 558c9cd8901c..f014fafbd2d3 100644 --- a/tools/testing/selftests/mm/vm_util.c +++ b/tools/testing/selftests/mm/vm_util.c @@ -53,6 +53,23 @@ unsigned long pagemap_get_pfn(int fd, char *start) return -1ul; } +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 +} + void clear_softdirty(void) { int ret; diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h index c7fa61f0dff8..5a57314d428a 100644 --- a/tools/testing/selftests/mm/vm_util.h +++ b/tools/testing/selftests/mm/vm_util.h @@ -36,6 +36,7 @@ bool pagemap_is_softdirty(int fd, char *start); bool pagemap_is_swapped(int fd, char *start); bool pagemap_is_populated(int fd, char *start); unsigned long pagemap_get_pfn(int fd, char *start); +int system_has_softdirty(void); void clear_softdirty(void); bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len); uint64_t read_pmd_pagesize(void); From patchwork Thu Jul 13 13:54:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119920 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1852937vqm; Thu, 13 Jul 2023 07:12:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlEI6qTmO/sdYXE3OD5l409Jn/T8ORb/0cIW9Z1r8pte7tW3lQwJvZfcBtM/w1K3qT53B6NJ X-Received: by 2002:a2e:b056:0:b0:2b6:e623:7b57 with SMTP id d22-20020a2eb056000000b002b6e6237b57mr1449299ljl.25.1689257542494; Thu, 13 Jul 2023 07:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257542; cv=none; d=google.com; s=arc-20160816; b=C1zdYmD/Wc9RT4BD+8Rngs1wSfgg6HgqfOA+eYoANWh0/BE25+7ZiZ3JhLoeEvgidU w/1f4JYpCr+GN3o9g0zhLCq81zsWkLJ1/JePL9EymkUta/BgL03xAnfnnsPFl9ANe/LL blvO2DZNj0iaEWgi/LyuWH+udZHxzLbf19zqKMHTqeVpJ3kWksVrkOusxKkzmU7Dt+7g eguIuVLL+npmCbSRYCXLA+CBBaAbjay5VAc7U9hl+JqL9szTptauwqdfF393wMtjvYFK b1+i9dbIqeFRzgJw3xGF7MXrPgVeNxHPE25n4TfQaJ9MA+lwC6FgiwD0DfGeu/TB1A+j mMoA== 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=Djiu/9OJ7MlYuTUobmA/ktywqApJW6btXzTBM5bZSFY=; fh=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=rWccwcV6fWLLX+wHXSpjJRGKM8q5f5hwGDoaoGFi9zRGURead1anJL8b2PU7WcPI8R u4bg6G1YocroxBGGTsPp++2yQXJkDnuRRcqOopslPW3gDdNsfc7a+pVSfALgwwBNn/jk AmBxm3QZE9JJNCJ0sQksEseEWxgG6s8uqk+9RqlJx29aFO9KGlEn3ePKaPKuTc6QZQ0X ieNB/gP5tr0VI66+Vf/ajdvtpib02SoSeiG9nnKQQYnllJDhm918ER1mTTHUBUSewB7D JVtECY8jY/Kf1cxne3qNk6rg2mcEqEYTX27Ex3llv5QkNbKiZVU3hVMDBarU7ExieFC8 nPiA== 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 b18-20020a170906d11200b00992ee6da875si7553590ejz.218.2023.07.13.07.11.57; Thu, 13 Jul 2023 07:12:22 -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 S232194AbjGMNzJ (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbjGMNy6 (ORCPT ); Thu, 13 Jul 2023 09:54:58 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B148F19B9; Thu, 13 Jul 2023 06:54:57 -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 F34181576; Thu, 13 Jul 2023 06:55:39 -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 E95573F73F; Thu, 13 Jul 2023 06:54:55 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 4/9] selftests/mm: Enable mrelease_test for arm64 Date: Thu, 13 Jul 2023 14:54:35 +0100 Message-Id: <20230713135440.3651409-5-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771314916714501876 X-GMAIL-MSGID: 1771314916714501876 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 Thu Jul 13 13:54:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1853420vqm; Thu, 13 Jul 2023 07:12:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlEwJL2BvUUTVbtJQB969OesvkI8cj468NL0uMyeWO3rm3Z0ydJ4jhVF1/iFKpT9ZWoobt+A X-Received: by 2002:a05:6512:3710:b0:4fb:7de4:c837 with SMTP id z16-20020a056512371000b004fb7de4c837mr1385577lfr.68.1689257578873; Thu, 13 Jul 2023 07:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257578; cv=none; d=google.com; s=arc-20160816; b=BbLX3WOw2RqGLitGuOtuvSoLBe4mtA0ymJduKYZ5lsIRGNqsAE3P2foPchpIJmYgg3 CifBjuQiwLjoAOKMvyr+VbqHCzeZuRK0prQFOygg2t+x02IujHXCm6aY2oBpaBrVaHUR ernT2JcZepIyg4RXHD+doMQaocsGEo4vY7SdGci+XIJlGF3/MW4OhCvWY4KmUb7gCNoE KDsMroOvCdDXBkqFHwCigwu5XjVzts5FhXU3IPvDNs7bwiIVhiHyI830ea60cKgRgv3v Pd9vkidoXYuECy/rAqaHyzKVTblOanSKfFHw9jUhYbUNAWeqQPnfvxQ8F16CAR1KFzDy 13pw== 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=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=HNRw1e3p/HI8iw+xFwFtgErnES76muD5ttO57dtRdw+XS16KxpZUEQgKJKYz9XgZdd Z3C44KhbxaLhS/1jo3toUFav7kLDM0S5Kw3cMICErYWDMwSds6NW/DR85QX3mq5a43RW nfUKwv+awBzXgfhuwEnbUd12cqyOZI0TfgPuT+eXClLPU+AIfDE/4rR85WOwB0vTGoAH YKnM0clOkWOdHIdm2/lEp/RkDkTkEkSP3w8ssqvPvIWrUun9isWtO30JFlkFYADoxTIy F2l13i+MxRSJ0r20O87SQbyMoPLdWpv9aQH7I1cnVt3pwhj/jkG1iH03rqJ4Nd87dxhc QSIQ== 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 b18-20020a170906d11200b00992ee6da875si7553590ejz.218.2023.07.13.07.12.34; Thu, 13 Jul 2023 07:12:58 -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 S232453AbjGMNzM (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231667AbjGMNzA (ORCPT ); Thu, 13 Jul 2023 09:55:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6DEF71995; Thu, 13 Jul 2023 06:54:59 -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 B6F501595; Thu, 13 Jul 2023 06:55:41 -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 ACC483F73F; Thu, 13 Jul 2023 06:54:57 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 5/9] selftests/mm: Fix thuge-gen test bugs Date: Thu, 13 Jul 2023 14:54:36 +0100 Message-Id: <20230713135440.3651409-6-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771314955113547641 X-GMAIL-MSGID: 1771314955113547641 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 --- 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 Thu Jul 13 13:54:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1852381vqm; Thu, 13 Jul 2023 07:11:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlHV5BWoQR5n+wY2veMcEZjvXgOrR0C77HKDTWoF/Hcd4i48M7v4YUg4y3NMqM7b3aEvFY3b X-Received: by 2002:a17:906:c2ca:b0:98d:4ae:8db9 with SMTP id ch10-20020a170906c2ca00b0098d04ae8db9mr2523912ejb.19.1689257497004; Thu, 13 Jul 2023 07:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257496; cv=none; d=google.com; s=arc-20160816; b=T4C1YAwX+kmKOWQIzPD5usOLo3zVGeSXRXFbbOXDRv3f0rEanXt3gI+7JCP4SY2PAX MqwOlBdj/fn7aO4vnsN/8xC5+Mmwqlu7mUDekTzBTmyI2XICwDUJWCyN3VqbvnQ9PWE1 6QTGU3b4Ir6sKDTDw0C2NfDc9j4onbPUyDY9fsjxT3jU1owwAoVwNUehEJoerVPhOear FwMu6HxzpSJpiTLNBwJFAFWrlS2TatL17s3Rx/LhTkbbsXulcuL3UB5Bbis0c+OrFQC8 p3yjEacZiBpmtejCVXfogSdYacvIV9Hpd9Fv3g8lJUHXrDpSjGOurEd00hSXGVX1jYxn Q+/w== 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=Cz2iEEBGyYF+rSb/J/At2npEIiP2rZZS/45ogfF1Shk=; fh=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=GmaPLADySqgQI8FMB2PFg8INGCpog5OlSLxixB32DN1zbsgCDljQa1ns57IrIyiFgp MSHTJGJtSknC7gdu/DAj1hvG7qrvsmraIueJOp8TYD9do1YVc4vh797pMqAJUftZmBFC AWRFWN1FalUEthjzcyn5FuUPWqAzvM/MpMiPPpgzDUwstilHPQn9kimZwI7ZUD9hjSqs spw/F5nTla6c90VGKiFJiqcNpd7lOh92ad9licm0GCVy+n4nPmzo8cV2nP0p9/aA3OBn Yn/nNnyKcwpLQx2jx+Z/ONQ+tJTrcXlM9vYKFlhCluNAejyNHf54RgLz9k2ihZzI7WyW f9uQ== 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 jt15-20020a170906dfcf00b0098722b28a18si7696359ejc.458.2023.07.13.07.11.12; Thu, 13 Jul 2023 07:11:36 -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 S232488AbjGMNzO (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231920AbjGMNzF (ORCPT ); Thu, 13 Jul 2023 09:55:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C3541FF7; Thu, 13 Jul 2023 06:55:01 -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 7AA1C1576; Thu, 13 Jul 2023 06:55:43 -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 70A523F73F; Thu, 13 Jul 2023 06:54:59 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 6/9] selftests/mm: va_high_addr_switch should skip unsupported arm64 configs Date: Thu, 13 Jul 2023 14:54:37 +0100 Message-Id: <20230713135440.3651409-7-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771314868925617934 X-GMAIL-MSGID: 1771314868925617934 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 | 3 ++- 1 file changed, 2 insertions(+), 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..4b6f62c69a9d 100644 --- a/tools/testing/selftests/mm/va_high_addr_switch.c +++ b/tools/testing/selftests/mm/va_high_addr_switch.c @@ -292,7 +292,8 @@ static int supported_arch(void) #elif defined(__x86_64__) return 1; #elif defined(__aarch64__) - return 1; + size_t page_size = getpagesize(); + return page_size == PAGE_SIZE; #else return 0; #endif From patchwork Thu Jul 13 13:54:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1849028vqm; Thu, 13 Jul 2023 07:07:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlHx4SF+YWWSlqoom0bmiY48npAqH+9G0O9lCpnxCIUyJ/6Vh0ZIgzckwxxiiZ1ubsl9mD/X X-Received: by 2002:a05:6512:34c2:b0:4fb:7618:bac7 with SMTP id w2-20020a05651234c200b004fb7618bac7mr1215477lfr.64.1689257233063; Thu, 13 Jul 2023 07:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257233; cv=none; d=google.com; s=arc-20160816; b=jbyeTlBknwsBlyV60i+v1DBySjqoOJY2FhwCO1t3ViUg+O71yzPnOpnqznDVqRPt31 nlJROM94SQy+M5Tsd7UstKtDDK+k/7VNDnLCToctj5X0kgzbYhASXd6WS+iVAce4cYzu akqG5bheYQwhPSsSGZRoi+oRAByLakMbhHBPkla98TtnUay2yJt5qQtBF4PLfW6j16L1 zOc9FwqKbGZpxWcp84Ud6KEfO/W966Hp9n1mwtkH75rdtJUtqGuEq64nlC25+MSbNGBB suySqwrhjR+M6gdzdETaJtXm9FaP51iAjCUJAWZV4XpQXhln5sszHRYzJ+3o8UjP1tXg 9vZw== 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=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=Q4GQlP1vA+NNyL9a7tQ02mV7yOHreYHdt/iZqpnQke/PIIvUVpsZ3JAiKY0brfaqV8 fqG0O0D0EM95xnOqnJImD1piV96kxJrYed7uPLUEdcG5141bpgikFQTAl7+qQh9V5sV4 /672oIJy8rsirTln0tB6O/cHn/dtSGQ8nswKcokm4A+3z2SRiECVlALlbkWrbIIRu6Rf XO09flIILNhGy1G5jkcOi7XZzTAXjSk4MzWiQ1yesKvlTMFe10SdO5vLV1E0EDyxhmj7 BbUIICpxZMVvQ7po/GWrww0rr+4ST8os/geASdfqQOVP5KHDIL5yqKg3d0iOZZgH+dg6 blvg== 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 i3-20020a056402054300b0051e1616f27esi7430985edx.20.2023.07.13.07.06.48; Thu, 13 Jul 2023 07:07:13 -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 S232543AbjGMNzQ (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231730AbjGMNzG (ORCPT ); Thu, 13 Jul 2023 09:55:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 00205211E; Thu, 13 Jul 2023 06:55:02 -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 3E61C1595; Thu, 13 Jul 2023 06:55:45 -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 341AA3F73F; Thu, 13 Jul 2023 06:55:01 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 7/9] selftests/mm: Make migration test robust to failure Date: Thu, 13 Jul 2023 14:54:38 +0100 Message-Id: <20230713135440.3651409-8-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771314592527851448 X-GMAIL-MSGID: 1771314592527851448 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 Thu Jul 13 13:54:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1855458vqm; Thu, 13 Jul 2023 07:15:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlF8W7IsdQRwiqlk/60KD7EsTgAUgkhn4tLMYB3cW3siCvs4Jk370NrCkSteRBsIfh2rp599 X-Received: by 2002:a05:6512:114e:b0:4f8:5e8b:5ec8 with SMTP id m14-20020a056512114e00b004f85e8b5ec8mr1852269lfg.9.1689257745343; Thu, 13 Jul 2023 07:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257745; cv=none; d=google.com; s=arc-20160816; b=BcoxWz9gWoFdeiyFCtbky2WU57ZG5ksQA0+XAl5SLCGavdNG3Q3PK45CVCcINyK+3u deterIExEjEgtlJmMeVTp8Edgb+QZpxxoQeevG/9E7wWNJu1OuLC51M9m69VTofJSZcZ MWLccedg2QQK2nAVE7AgMH1NkR70GXUY8V/gQSTLl4qgRImVr9nVOzAeM6alB8GBCpHE gggBEvJB+0PAotmKlV326aBprvX6bVIyJgadQWl61M7x4SAVIMO44IvAtVYp8qdVjTfv r0gmbYpfxTNtJNXpClh5Rfw8RicI23W5QMK3aCRloMovQz40ZPBr3gvHf/hK1w7Uov/F ffnw== 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=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=sUPnOSFsYivZYM3yAxgBjhYhbHXi5kzDVfwP6kg35nIoCrqysHDJ6DU4YRwrh7SOmy wj7i4czw/ItcNXUnxGatmXuwfhSjvwW5tfxiXMTKJ3u4p1ZO6Flrseme7DCyDUIiy+NW oo95AySPyY8wlVTRZm80iiJEyBBIkpoXCM6BuT76ZOCZeCfo/kI4P03/nwIGZ24599R1 8LzpyCJ29kPzwUm4VPSctDdH5/4cjAbnSfdZX8w2VL81E02bZgqCBcL8r50cKEcA3mGr mQBoRRSE4Gt6Y5RZNtJloPquF76b8Bo9GFggQh0kKgXwkyZJGXR378D7f5cErOS7YGcL l7tQ== 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 o13-20020a056402038d00b0051df75a5cb3si7456738edv.472.2023.07.13.07.15.20; Thu, 13 Jul 2023 07:15:45 -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 S229986AbjGMNzS (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbjGMNzH (ORCPT ); Thu, 13 Jul 2023 09:55:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B8098270D; Thu, 13 Jul 2023 06:55:04 -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 01FAE1576; Thu, 13 Jul 2023 06:55:47 -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 EC0623F73F; Thu, 13 Jul 2023 06:55:02 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 8/9] selftests/mm: Optionally pass duration to transhuge-stress Date: Thu, 13 Jul 2023 14:54:39 +0100 Message-Id: <20230713135440.3651409-9-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771315129393583341 X-GMAIL-MSGID: 1771315129393583341 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 --- 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 Thu Jul 13 13:54:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 119929 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1855677vqm; Thu, 13 Jul 2023 07:16:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlGcAwcW3D+Oq7iTWHFDEO57Pq8UQFDYTeirsQ831PAvPsA1qBmqGbDuZwRlmPRM/vqu1cOL X-Received: by 2002:a17:906:113:b0:992:345e:831b with SMTP id 19-20020a170906011300b00992345e831bmr1821481eje.50.1689257763249; Thu, 13 Jul 2023 07:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689257763; cv=none; d=google.com; s=arc-20160816; b=PtJ5XjcfQmZVCncl2AsmGzTodTnnCXvIkp0Rn8U0WSDVqq45f7W3TfRUwvQnvII1jI 92rm6EgqHCa5xpqFTLuW/bXUdsiwAj/yO1RJUXsEHDwghkEaG6cCI8z696mGSVYhxjsB 43/mF2U24yWQ9Z3qrvjNvvx3C6okMho+NggdxjYgGtSWUZVO0DrT2E0fZEgxHw54MiOH M+0hp+4y2plBgQNOzxjXiVR19gQrUSxYvcoVI+RP0kuTgbMBk+LqT03Fz4oqGWmgkZol lZADRFoc/LvWVY7tnI/V77y1y1Lbi/yFBoNZJxqbCU1TnIbv5lxdPFWVNK8fhveruROq wSDQ== 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=rgNh+VVG4rnJeUIVls+H/r6KasnE8DWQu2bfgPlapXg=; fh=PBHZcfMfFxGGBVmDESRU6Gjyj3qxzeiTc8DMNv9diCw=; b=pIpUPy6pdMvF7WzodMqvwHkZdKBuNjStj5lpeWzFAU1fXVh/VXUZvuvrTn7kaLDqMk 5EO2y6yL4oz/nrdZTeDGhmd28DxL5FsdHiLlIbjK4+G0NfaJCn0VY5ibVvHvRxLPWORI msgubkXzhKUmfZ+JEZNV5GJobmNDe2PiC9XWd2m6UNuRsbTJGTLLcJ29ZWHKploUVFUH EN3LCVng8a5pCAXBQkyxBdksHAf0SBQtlC4nHlI5G69YAb3da5cHPudpQgYElj4xGHAP +jDqaYpeKaS/CJmntx+M2toBVilDpDYQZEArqfZiMlflWKUTK2jkV3eaOIrP2pfShVHE SCLQ== 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 r11-20020a170906a20b00b0099325282809si7261806ejy.572.2023.07.13.07.15.37; Thu, 13 Jul 2023 07:16:03 -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 S232374AbjGMNzW (ORCPT + 99 others); Thu, 13 Jul 2023 09:55:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232331AbjGMNzL (ORCPT ); Thu, 13 Jul 2023 09:55:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B2F22721; Thu, 13 Jul 2023 06:55:06 -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 BA4191596; Thu, 13 Jul 2023 06:55:48 -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 AFCEC3F73F; Thu, 13 Jul 2023 06:55:04 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Shuah Khan , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , David Hildenbrand , Mark Brown , John Hubbard , Florent Revest , "Liam R. Howlett" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 9/9] selftests/mm: Run all tests from run_vmtests.sh Date: Thu, 13 Jul 2023 14:54:40 +0100 Message-Id: <20230713135440.3651409-10-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230713135440.3651409-1-ryan.roberts@arm.com> References: <20230713135440.3651409-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: 1771315148230489790 X-GMAIL-MSGID: 1771315148230489790 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. 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 66d7c07dc177..881ed96d96fd 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -35,39 +35,39 @@ 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 += 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 +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 += soft-dirty +TEST_GEN_FILES += split_huge_page_test +TEST_GEN_FILES += ksm_tests +TEST_GEN_FILES += ksm_functional_tests +TEST_GEN_FILES += mdwe_test ifeq ($(ARCH),x86_64) CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32) @@ -83,24 +83,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 @@ -112,6 +112,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 3f26f6e15b2a..55fe1d309355 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 @@ -295,6 +306,18 @@ CATEGORY="soft_dirty" run_test ./soft-dirty # 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