From patchwork Mon Jul 24 08:25:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1657680vqg; Mon, 24 Jul 2023 01:39:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFBR98qaWBwtyZTAn8rvsAKZPqGOu5s15meDXDIxCVxbOH7mg+j7KOyshG98iWk2bdgVHBS X-Received: by 2002:a05:6358:52c1:b0:134:ec9d:ef18 with SMTP id z1-20020a05635852c100b00134ec9def18mr5637677rwz.28.1690187981585; Mon, 24 Jul 2023 01:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690187981; cv=none; d=google.com; s=arc-20160816; b=hhpz2K7ZuwDof/42Z2++z0NEDFA9M0bq2VMGzVm2dYRJN7luc+9g/UQCPNoXElCvNG fhFkjtrki+EcTYA4T3qSE0nkFDSOPq1E8vCkC0glDSjGM9mqFd3acIhvXwAhHpKkanWF FqV42aoRnslSpcT0g9h5NQygNRQDmTOZzxh4WjriVLXDHRZufeTcnSU1b9PmIQUYkLEs /bBICWzN9owKK5ar09r9UKXEZmO4BlSbYon+8sh2KI4Z7PynkXAxSuZQiFenGv79xOhS K3KjRcjLIT/vVOyMJgBcopPjPD19CShI5uMt0VhdQYsqSWjS+At6utsR/bI5eRtv28e+ 8tGA== 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=XlRIL9y77l4hUsgR6WNGVesaqf711bWwIXAfz4ZM0r8=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=bmJ4CmBD5OQaYtoFo/lrTP27Er+16YRW7e0niDWesty0US/96Jrh2+QijLiTGIzWnL xebqe4SlHijY2o19XqQAWmzSyOBI+bPz4oo0TKuXJ7eOu7Gui4CrtJF8lDCP1r2gqxO9 hjunlRKvDccLmaCYCpoG/Y27+CGB0T34R0fiLBI5rLjrTttebQcjXkRpETS+7qK4FAuq AMWOR2zJQsMHap4Y0CJJ5+pafBePwC8SqwS+D8TiKh93jWcSfNW3Tz2l+P/Gl/YvKzan CazxaVrOADYBFEDg+SGzYp6h9fJbt1a8E61w00++3SeW6vfj9CFww4yKWX6eAbHwQ3iX 0tog== 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 h126-20020a636c84000000b00563b0cbe7fcsi2025535pgc.854.2023.07.24.01.39.28; Mon, 24 Jul 2023 01:39: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 S231454AbjGXIZl (ORCPT + 99 others); Mon, 24 Jul 2023 04:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231424AbjGXIZh (ORCPT ); Mon, 24 Jul 2023 04:25:37 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED6771B8; Mon, 24 Jul 2023 01:25:34 -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 DB53EFEC; Mon, 24 Jul 2023 01:26:17 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 081BE3F67D; Mon, 24 Jul 2023 01:25:32 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 1/8] selftests: Line buffer test program's stdout Date: Mon, 24 Jul 2023 09:25:15 +0100 Message-Id: <20230724082522.1202616-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772290552859660967 X-GMAIL-MSGID: 1772290552859660967 The selftests runner pipes the test program's stdout to tap_prefix. The presence of the pipe means that the test program sets its stdout to be fully buffered (as aposed to line buffered when directly connected to the terminal). The block buffering means that there is often content in the buffer at fork() time, which causes the output to end up duplicated. This was causing problems for mm:cow where test results were duplicated 20-30x. Solve this by using `stdbuf`, when available to force the test program to use line buffered mode. This means previously printf'ed results are flushed out of the program before any fork(). Additionally, explicitly set line buffer mode in ksft_print_header(), which means that all test programs that use the ksft framework will benefit even if stdbuf is not present on the system. Reviewed-by: Mark Brown Signed-off-by: Ryan Roberts --- tools/testing/selftests/kselftest.h | 9 +++++++++ tools/testing/selftests/kselftest/runner.sh | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index 829be379545a..529d29a35900 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -113,6 +113,15 @@ static inline int ksft_get_error_cnt(void) { return ksft_cnt.ksft_error; } static inline void ksft_print_header(void) { + /* + * Force line buffering; If stdout is not connected to a terminal, it + * will otherwise default to fully buffered, which can cause output + * duplication if there is content in the buffer when fork()ing. If + * there is a crash, line buffering also means the most recent output + * line will be visible. + */ + setvbuf(stdout, NULL, _IOLBF, 0); + if (!(getenv("KSFT_TAP_LEVEL"))) printf("TAP version 13\n"); } diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh index 1c952d1401d4..261c73cab41b 100644 --- a/tools/testing/selftests/kselftest/runner.sh +++ b/tools/testing/selftests/kselftest/runner.sh @@ -105,15 +105,18 @@ run_one() echo "# Warning: file $TEST is missing!" echo "not ok $test_num $TEST_HDR_MSG" else + if [ -x /usr/bin/stdbuf ]; then + stdbuf="/usr/bin/stdbuf --output=L " + fi eval kselftest_cmd_args="\$${kselftest_cmd_args_ref:-}" - cmd="./$BASENAME_TEST $kselftest_cmd_args" + cmd="$stdbuf ./$BASENAME_TEST $kselftest_cmd_args" if [ ! -x "$TEST" ]; then echo "# Warning: file $TEST is not executable" if [ $(head -n 1 "$TEST" | cut -c -2) = "#!" ] then interpreter=$(head -n 1 "$TEST" | cut -c 3-) - cmd="$interpreter ./$BASENAME_TEST" + cmd="$stdbuf $interpreter ./$BASENAME_TEST" else echo "not ok $test_num $TEST_HDR_MSG" return From patchwork Mon Jul 24 08:25:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1659439vqg; Mon, 24 Jul 2023 01:43:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlFsN1HDp6cpbuDBYTpITOS+0Pz1/nQOhHD01njm7ao17wZil7kweBrpzoQG4rzpfOJYSLZM X-Received: by 2002:a05:6870:d109:b0:1ba:59da:31dc with SMTP id e9-20020a056870d10900b001ba59da31dcmr10117417oac.24.1690188225037; Mon, 24 Jul 2023 01:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188225; cv=none; d=google.com; s=arc-20160816; b=QBxUIGA5p0UAr7SVdgFCb09kqZFDwxndlaX8ukLVkPcK8tSseSV9y21gxIFXXYSqyx OkvPg8DKZmLlM3+qmga58vsk4ENiF0djO6CbJ9fFUm6q+UcPA/DWRvPJjQ1lrmaFn6th Rx2zXL1aHP0zmbXEV5XAVMIf/88JUZ/gl2kysWk/Sualz776uCAI7W4+tdBjd9+3xgF3 ioH4YfG7nc0pAAUW2i9pa3loSxFa5zqliXv6Q/uS132WOh+5mboTCWG3tkq8B087toTn bXGP6zSG4xOfFDzD8ETFU8pTANfKCQo+r0wfPCybdWElkQvjkFjoHP3oC+fsvLhos8Av 6jZA== 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=Pv8pF/WPDvj1kM4ae908pjU7ySgq/Sv6xLJvnAf6h4E=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=az6zM9ujzo78cq3sBlZXyadlrryoee0kbEZXTuLxK5KnJPKsSYaQYLDKxoT7ypo76x 44T81kUPGLm28i7bqTdULhNvz1SrDtVYpMsQEq4nV8Jy5CdNfRZA3B6Jg2PEID6LV5F2 3Tk68CUJVD3UneS8JG2qiiC+CMjCEQlrSKgggKFeiefgEHlfObhDaUsxpZhzQNk8jel2 Hrh9R8cjekYW0GQBgLAywepOkY/PpyQdlxosV6rhgACk6cDXIrgi6pd4fP5GUOvfXEYX 2D9uerGgltxYBoEP++oEqYlMrcNCClU6XUcITnZHwGedZV+02c6qJUO/9kWZFd+D4Y7Y ui4A== 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 n4-20020a635904000000b0055c95ab2367si7841141pgb.247.2023.07.24.01.43.32; Mon, 24 Jul 2023 01:43:44 -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 S231465AbjGXIZp (ORCPT + 99 others); Mon, 24 Jul 2023 04:25:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbjGXIZi (ORCPT ); Mon, 24 Jul 2023 04:25:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E5031BE; Mon, 24 Jul 2023 01:25:36 -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 D18A411FB; Mon, 24 Jul 2023 01:26:19 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0D383F67D; Mon, 24 Jul 2023 01:25:34 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 2/8] selftests/mm: Skip soft-dirty tests on arm64 Date: Mon, 24 Jul 2023 09:25:16 +0100 Message-Id: <20230724082522.1202616-3-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772290808071704808 X-GMAIL-MSGID: 1772290808071704808 arm64 does not support the soft-dirty PTE bit. However, the `soft-dirty` test suite is currently run unconditionally and therefore generates spurious test failures on arm64. There are also some tests in `madv_populate` which assume it is supported. For `soft-dirty` lets disable the whole suite for arm64; it is no longer built and run_vmtests.sh will skip it if its not present. For `madv_populate`, we need a runtime mechanism so that the remaining tests continue to be run. Unfortunately, the only way to determine if the soft-dirty dirty bit is supported is to write to a page, then see if the bit is set in /proc/self/pagemap. But the tests that we want to conditionally execute are testing precicesly this. So if we introduced this feature check, we could accedentally turn a real failure (on a system that claims to support soft-dirty) into a skip. So instead, do the check based on architecture; for arm64, we report that soft-dirty is not supported. Acked-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/Makefile | 5 ++++- tools/testing/selftests/mm/madv_populate.c | 26 ++++++++++++++++++++-- tools/testing/selftests/mm/run_vmtests.sh | 5 ++++- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 66d7c07dc177..3514697fc2db 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -63,12 +63,15 @@ TEST_GEN_PROGS += thuge-gen TEST_GEN_PROGS += transhuge-stress TEST_GEN_PROGS += uffd-stress TEST_GEN_PROGS += uffd-unit-tests -TEST_GEN_PROGS += soft-dirty TEST_GEN_PROGS += split_huge_page_test TEST_GEN_PROGS += ksm_tests TEST_GEN_PROGS += ksm_functional_tests TEST_GEN_PROGS += mdwe_test +ifneq ($(ARCH),arm64) +TEST_GEN_PROGS += soft-dirty +endif + ifeq ($(ARCH),x86_64) CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32) CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c) diff --git a/tools/testing/selftests/mm/madv_populate.c b/tools/testing/selftests/mm/madv_populate.c index 60547245e479..17bcb07f19f3 100644 --- a/tools/testing/selftests/mm/madv_populate.c +++ b/tools/testing/selftests/mm/madv_populate.c @@ -264,14 +264,35 @@ static void test_softdirty(void) munmap(addr, SIZE); } +static int system_has_softdirty(void) +{ + /* + * There is no way to check if the kernel supports soft-dirty, other + * than by writing to a page and seeing if the bit was set. But the + * tests are intended to check that the bit gets set when it should, so + * doing that check would turn a potentially legitimate fail into a + * skip. Fortunately, we know for sure that arm64 does not support + * soft-dirty. So for now, let's just use the arch as a corse guide. + */ +#if defined(__aarch64__) + return 0; +#else + return 1; +#endif +} + int main(int argc, char **argv) { + int nr_tests = 16; int err; pagesize = getpagesize(); + if (system_has_softdirty()) + nr_tests += 5; + ksft_print_header(); - ksft_set_plan(21); + ksft_set_plan(nr_tests); sense_support(); test_prot_read(); @@ -279,7 +300,8 @@ int main(int argc, char **argv) test_holes(); test_populate_read(); test_populate_write(); - test_softdirty(); + if (system_has_softdirty()) + test_softdirty(); err = ksft_get_fail_cnt(); if (err) diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 3f26f6e15b2a..9e4338aa5e09 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -290,7 +290,10 @@ then CATEGORY="pkey" run_test ./protection_keys_64 fi -CATEGORY="soft_dirty" run_test ./soft-dirty +if [ -x ./soft-dirty ] +then + CATEGORY="soft_dirty" run_test ./soft-dirty +fi # COW tests CATEGORY="cow" run_test ./cow From patchwork Mon Jul 24 08:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1657092vqg; Mon, 24 Jul 2023 01:38:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlGgtXvy2Xh8ClVk9OSoiba5pSaY7ibsykj+oFJTtmSMTNIOCqYRB4ke3EqlHxMFjdZ/ud9E X-Received: by 2002:a05:6a20:2453:b0:137:9622:17d1 with SMTP id t19-20020a056a20245300b00137962217d1mr7876793pzc.27.1690187905318; Mon, 24 Jul 2023 01:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690187905; cv=none; d=google.com; s=arc-20160816; b=0TfoUKUvnevp49dn7pgB6Zt3AMKruyq4ZzzqNwCRWzoo4ZkAbzvdtNAf9BKRUuNUlD M2wZ6s0iqDqxmDxgJEVo1mCVo6i3eh02tIzi6wOfuRGeSSQhqxEWtFmoIVtnnhvh5S7H XaMWGzu0LNldKCM/IU1Kjfl3vGJuldYwNw4Otd2T8jgvgWcAxuH5C0V3ws89ih2MhE4C u8KnMKeEJyeHODQQlIOJ56WmP45r9SIlQCjUfmu4tQCovCTTccennFsHqSjOxOBNbTfN bash2w2AAhA4nChUZY9Jw37y1lx41E8xw+wXONMOoiP+oOp2JlG3HZ7d7Of+QAAUVIkg 08Nw== 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=+gbe2Lov6qmOHVSUu3pkHDpd9c8tQzyYAgTsJk6v9w0=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=PDDK9UQx5tr+4Yp6R4SZ4rHKaZNAPqQsgHjX69HUtT1RXpBEefdxPo7KkagVcBlK+7 TIcHdP85Pli1M2DfqM7+6vci9OQdunRXkrZK20x4n0OIcoGQQ4m/OkAUTpTvN0d3+YIR htEV9ehBFFY1LUAfaHOeS8roJ4hYYfzuCBRKLP8xvfFpeKjFzEeM+xMlpvZ59wFbfCMv q73+21fhtEKxYaXjvd6Qr0DEaP5WGZ5FIo/dFws1kt3hmomTrJfUbeJBrjoWAzffSRii q+rY0wZB5GOhBJvicPjEh/wgOcvER+Q0t0wWYU405SHiDYy9Xoj5EbNFmKPxi9/2msMF 6DZg== 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 x63-20020a638642000000b0054fd35b2dbcsi8203838pgd.350.2023.07.24.01.38.11; Mon, 24 Jul 2023 01:38:25 -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 S231473AbjGXIZr (ORCPT + 99 others); Mon, 24 Jul 2023 04:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbjGXIZk (ORCPT ); Mon, 24 Jul 2023 04:25:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D4C13134; Mon, 24 Jul 2023 01:25:38 -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 C54A715A1; Mon, 24 Jul 2023 01:26:21 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E5F693F67D; Mon, 24 Jul 2023 01:25:36 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 3/8] selftests/mm: Enable mrelease_test for arm64 Date: Mon, 24 Jul 2023 09:25:17 +0100 Message-Id: <20230724082522.1202616-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772290472925688353 X-GMAIL-MSGID: 1772290472925688353 mrelease_test defaults to defining __NR_pidfd_open and __NR_process_mrelease syscall numbers to -1, if they are not defined anywhere else, and the suite would then be marked as skipped as a result. arm64 (at least the stock debian toolchain that I'm using) requires including to pull in the defines for these syscalls. So let's add this header. With this in place, the test is passing on arm64. Reviewed-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/mrelease_test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/mm/mrelease_test.c b/tools/testing/selftests/mm/mrelease_test.c index dca21042b679..d822004a374e 100644 --- a/tools/testing/selftests/mm/mrelease_test.c +++ b/tools/testing/selftests/mm/mrelease_test.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include From patchwork Mon Jul 24 08:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1655814vqg; Mon, 24 Jul 2023 01:35:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlExSrWw+954T4IGE/KzHCB+bSl+VCHGYIACbpjuAg4vPJZF6oZJ10rEZJRLAk7tm1I+76am X-Received: by 2002:a05:620a:22d3:b0:767:f14f:ea29 with SMTP id o19-20020a05620a22d300b00767f14fea29mr7524509qki.75.1690187710737; Mon, 24 Jul 2023 01:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690187710; cv=none; d=google.com; s=arc-20160816; b=pnV0jwmt1sCKJpw3dBOvvKeIkz3M+UyfKqL7AZSlHcuaRIVMB795I56sxyS398oBx/ cDebwG8bJviE1gVtIJGNV01bPY43bH+M4EIN+5aSYtHbvCOPGtL0S2s9DenSNR4CNf5i pBLnZjUkPiu2VeMqSvh67R6iSki/dcY5orr1lvMqET7kw4UHuqToFEKxP6GIiOxAcvzZ wBKDYrm2r6GkuvWOj/tY5aNTC7apeSlCgnm+zYpolKH60ymsCA5XT3AIN6DZx3Tmi8xN vJff/kV6RClgSfeg+v6z1LHyI8XjqZ1nInIq9+LOe3weqpMbO2LI/qY4ijrUzyTDclfi 8PPA== 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=RlF+OWSt7Xg4Y8gUX/1pDNyyb2oDlnFwm/E3+/VsYzs=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=itEgx7LF9TM2mm/V0M1KuUM6k1p9INLNwW94ui9hDtlzZe/kNNsuMBZjkpHU6b3i3U o29TtPygdvgo/f3Vfl4d6sRsfyPmZ3qEVCGeNaA0T3VC4//JDj+dbdSXOZ1b4SUf/Kn6 37kr6rZG+2g2fcuGJxSLHAHDhb8IWtzKSKLoye+UixB2sIvG7s2fwbdPaQPoUr7NaLEr HZJfoBYw+mJZCmDIctjh1gmdNxdTCVjd5EKJvveHNvEVbgPaNkE8sEhOee4jOaXeTL0e Ja2ZZv7cYfusHc4+yLspgYzdFDI698qHX8o41X1BU8bWlg1zetKE5ZHdyygIuwJXVks/ UQFg== 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 nv9-20020a17090b1b4900b00263a99b8448si9390563pjb.113.2023.07.24.01.34.57; Mon, 24 Jul 2023 01:35:10 -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 S231484AbjGXIZw (ORCPT + 99 others); Mon, 24 Jul 2023 04:25:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231460AbjGXIZl (ORCPT ); Mon, 24 Jul 2023 04:25:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA30B133; Mon, 24 Jul 2023 01:25:40 -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 BDAAB11FB; Mon, 24 Jul 2023 01:26:23 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA6DE3F67D; Mon, 24 Jul 2023 01:25:38 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 4/8] selftests/mm: Fix thuge-gen test bugs Date: Mon, 24 Jul 2023 09:25:18 +0100 Message-Id: <20230724082522.1202616-5-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772290268877569652 X-GMAIL-MSGID: 1772290268877569652 thuge-gen was previously only munmapping part of the mmapped buffer, which caused us to run out of 1G huge pages for a later part of the test. Fix this by munmapping the whole buffer. Based on the code, it looks like a typo rather than an intention to keep some of the buffer mapped. thuge-gen was also calling mmap with SHM_HUGETLB flag (bit 11 set), which is actually MAP_DENYWRITE in mmap context. The man page says this flag is ignored in modern kernels. I'm pretty sure from the context that the author intended to pass the MAP_HUGETLB flag so I've fixed that up too. Reviewed-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/thuge-gen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/thuge-gen.c b/tools/testing/selftests/mm/thuge-gen.c index 380ab5f0a534..16ed4dfa7359 100644 --- a/tools/testing/selftests/mm/thuge-gen.c +++ b/tools/testing/selftests/mm/thuge-gen.c @@ -139,7 +139,7 @@ void test_mmap(unsigned long size, unsigned flags) before, after, before - after, size); assert(size == getpagesize() || (before - after) == NUM_PAGES); show(size); - err = munmap(map, size); + err = munmap(map, size * NUM_PAGES); assert(!err); } @@ -222,7 +222,7 @@ int main(void) test_mmap(ps, MAP_HUGETLB | arg); } printf("Testing default huge mmap\n"); - test_mmap(default_hps, SHM_HUGETLB); + test_mmap(default_hps, MAP_HUGETLB); puts("Testing non-huge shmget"); test_shmget(getpagesize(), 0); From patchwork Mon Jul 24 08:25:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1654845vqg; Mon, 24 Jul 2023 01:32:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlEZ8BS4yG83Gh6vNinBURpc4Ypd38Znpr1uLu1XV91CpMQagVKixtxr45FXy6DfDLDDBtUf X-Received: by 2002:a17:902:7897:b0:1bb:9357:8b76 with SMTP id q23-20020a170902789700b001bb93578b76mr4285295pll.50.1690187577711; Mon, 24 Jul 2023 01:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690187577; cv=none; d=google.com; s=arc-20160816; b=oKXMLziapWiKjohTSsurPKLHtpLm0DiwyMQsxBwiQ9yY71bsSLvIl8M2OArmRbu0iF nrtIbH0EwG41aeRF8hlzcJQiu8VZykB76qioREz+XtrgRRKxKAdYBaae2XEtfMoW3tYl Bj0WFkBo5GNth9kFcQZ4IkrVWpxW8TBkJFBTwnD0ihWJ6xWkyHAxKf038nm7B3O62jHQ 3vNsu+8gWzKLGoAwXao4W5oLKGIOTpO3G72CBt0CVVAtj0nZDqAlhSDQQ7ywPSfbjZwn 7DRoznvRmyHWYgZLwGYwFzgKoQql+onYOcilet0v3zN38m3hFX9bRNxvmyXo5nWb+xQ6 SSVw== 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=IStgpvB/AxFXY+gD4sZN5L7DJnID4eqcXYh0yWnPJzA=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=ujqJUPxZgRQhiVsfsknqit19MxH0qDkIlphSsyZ0uEgh6ue0WAg1Xf+V7DQ458FA6i WeaDGLOgEOPzXA8kn7nbJUKec20gqe8ZCI56w/iuYpf9uVAlm5lC0DaHh/sJKBae4+NI Zfb9tOArVeondwwqfKa6Ejs5eggYS4E7d5PFT69bgRn0cRDIRCeeIRuZU15pnfgZcH5K 2QT5Ofm0I2+/9QT/DrF2ArLQNtAqHWo/pz3k0dKwV66w0SzpCEq9pLH7y4rN0tpSObBF 9pe+OPT9K0GU+2O0HLFXzXdfK2d9nR3MiJZhOPSrifEJTmddmSDuNAv+EY9iqLd4o+SV 7ONQ== 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 f17-20020a170902ce9100b001b8ae5d825bsi9747275plg.612.2023.07.24.01.32.38; Mon, 24 Jul 2023 01:32:57 -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 S231464AbjGXIZ5 (ORCPT + 99 others); Mon, 24 Jul 2023 04:25:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbjGXIZo (ORCPT ); Mon, 24 Jul 2023 04:25:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BBCF01AD; Mon, 24 Jul 2023 01:25:42 -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 AF3D9DE0; Mon, 24 Jul 2023 01:26:25 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D04CD3F67D; Mon, 24 Jul 2023 01:25:40 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 5/8] selftests/mm: va_high_addr_switch should skip unsupported arm64 configs Date: Mon, 24 Jul 2023 09:25:19 +0100 Message-Id: <20230724082522.1202616-6-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772290129556079052 X-GMAIL-MSGID: 1772290129556079052 va_high_addr_switch has a mechanism to determine if the tests should be run or skipped (supported_arch()). This currently returns unconditionally true for arm64. However, va_high_addr_switch also requires a large virtual address space for the tests to run, otherwise they spuriously fail. Since arm64 can only support VA > 48 bits when the page size is 64K, let's decide whether we should skip the test suite based on the page size. This reduces noise when running on 4K and 16K kernels. Reviewed-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/va_high_addr_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/va_high_addr_switch.c b/tools/testing/selftests/mm/va_high_addr_switch.c index 7cfaf4a74c57..cfbc501290d3 100644 --- a/tools/testing/selftests/mm/va_high_addr_switch.c +++ b/tools/testing/selftests/mm/va_high_addr_switch.c @@ -292,7 +292,7 @@ static int supported_arch(void) #elif defined(__x86_64__) return 1; #elif defined(__aarch64__) - return 1; + return getpagesize() == PAGE_SIZE; #else return 0; #endif From patchwork Mon Jul 24 08:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1659834vqg; Mon, 24 Jul 2023 01:44:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmoOcfQqUCzgRu2xk9q9sJmqaN3Yo0tpuz7UEXOelgB1cmHHC5278Nc/AOjo+EgG+WtKCn X-Received: by 2002:a92:c5a7:0:b0:346:7038:8506 with SMTP id r7-20020a92c5a7000000b0034670388506mr5054494ilt.2.1690188283635; Mon, 24 Jul 2023 01:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690188283; cv=none; d=google.com; s=arc-20160816; b=FGUcT2F1xwBwOv1iLRYHK7RZ/i02FKqwdWQlgvrqnEnd64w6KMndiGH0rFWSxUccgC GkuUAg2JGFqk0Imi/hycIBQraiK3CN+GJmGmthLiKhw4ZteDU9bA/ErruZMhIaCFyPou yMBSA9sfAEdAEMaukM6djfbboX1w2X3RjT55DK9vbJbmu+OXZIwM4lJWrL/7fnCRQtIp 8AMCugyNnq2ldnm+kEAW69e51EmB6HD5eznhZp4XNAtqpRsseVCGb4yTJxCaR3b7YRvW 3Nhd09rEyemqXvgSozOUqAap8LtoVULEaoTlr86DTs1UxCq73vmEjbgj/1Bd7sW3jZ5N zcRA== 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=851WhiQknpUsE4X1CElE53hGZjRb+eoC5oQhWBMUHjk=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=rPszVOpIBNf8lwyceOysFU/gy+UuKnjF7tuEHn7xpVDRm3xzO4tpNHNn2jKPMHI4g+ /GKV3MEw1A2m6tQlu/grQ0BujxVXuu2wpdXwuFS5+gExstWOFFTxXWoKsAfKoR8qGZIe yadPLjvmAHqDAAImHKA20LVvBs5CRJwRZDDZ+l4qvGGpkLch6swVNWyBnybFWH3lj4hn NiATxzxHhuAyNogyn2AdxzRDeqOJKstf4dCK7TgQVv4dZvJorO829QPQj6LI2EUR/oc1 Nx1s4k+Qbi1N1AOqzZvTMtqEiz37cItXCHgrfHdL3I7xPKn1tpad4pEN5+4CB2fQApWJ y4pQ== 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 cd20-20020a056a00421400b0068255360b93si8417402pfb.332.2023.07.24.01.44.31; Mon, 24 Jul 2023 01:44:43 -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 S231429AbjGXI0D (ORCPT + 99 others); Mon, 24 Jul 2023 04:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbjGXIZ6 (ORCPT ); Mon, 24 Jul 2023 04:25:58 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E700A1A1; Mon, 24 Jul 2023 01:25:44 -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 A37E515A1; Mon, 24 Jul 2023 01:26:27 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C45423F67D; Mon, 24 Jul 2023 01:25:42 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 6/8] selftests/mm: Make migration test robust to failure Date: Mon, 24 Jul 2023 09:25:20 +0100 Message-Id: <20230724082522.1202616-7-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772290869474408370 X-GMAIL-MSGID: 1772290869474408370 The `migration` test currently has a number of robustness problems that cause it to hang and leak resources. Timeout: There are 3 tests, which each previously ran for 60 seconds. However, the timeout in mm/settings for a single test binary was set to 45 seconds. So when run using run_kselftest.sh, the top level timeout would trigger before the test binary was finished. Solve this by meeting in the middle; each of the 3 tests now runs for 20 seconds (for a total of 60), and the top level timeout is set to 90 seconds. Leaking child processes: the `shared_anon` test fork()s some children but then an ASSERT() fires before the test kills those children. The assert causes immediate exit of the parent and leaking of the children. Furthermore, if run using the run_kselftest.sh wrapper, the wrapper would get stuck waiting for those children to exit, which never happens. Solve this by setting the "parent death signal" to SIGHUP in the child, so that the child is killed automatically if the parent dies. With these changes, the test binary now runs to completion on arm64, with 2 tests passing and the `shared_anon` test failing. Signed-off-by: Ryan Roberts Reviewed-by: David Hildenbrand --- tools/testing/selftests/mm/migration.c | 12 +++++++++--- tools/testing/selftests/mm/settings | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c index 379581567f27..6908569ef406 100644 --- a/tools/testing/selftests/mm/migration.c +++ b/tools/testing/selftests/mm/migration.c @@ -10,12 +10,13 @@ #include #include #include +#include #include #include #include #define TWOMEG (2<<20) -#define RUNTIME (60) +#define RUNTIME (20) #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1))) @@ -155,10 +156,15 @@ TEST_F_TIMEOUT(migration, shared_anon, 2*RUNTIME) memset(ptr, 0xde, TWOMEG); for (i = 0; i < self->nthreads - 1; i++) { pid = fork(); - if (!pid) + if (!pid) { + prctl(PR_SET_PDEATHSIG, SIGHUP); + /* Parent may have died before prctl so check now. */ + if (getppid() == 1) + kill(getpid(), SIGHUP); access_mem(ptr); - else + } else { self->pids[i] = pid; + } } ASSERT_EQ(migrate(ptr, self->n1, self->n2), 0); diff --git a/tools/testing/selftests/mm/settings b/tools/testing/selftests/mm/settings index 9abfc60e9e6f..ba4d85f74cd6 100644 --- a/tools/testing/selftests/mm/settings +++ b/tools/testing/selftests/mm/settings @@ -1 +1 @@ -timeout=45 +timeout=90 From patchwork Mon Jul 24 08:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1669006vqg; Mon, 24 Jul 2023 02:06:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFEhDz3Sp28N4Ezx+soK5AqRmozr0Y56fakm8+SutWitOLKpOIloTEaPJvX9E2hYaUrZVJG X-Received: by 2002:a05:6a20:b715:b0:130:661c:613d with SMTP id fg21-20020a056a20b71500b00130661c613dmr7962911pzb.5.1690189614692; Mon, 24 Jul 2023 02:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690189614; cv=none; d=google.com; s=arc-20160816; b=s9L73OX6NWFKsy3lLjHIdb6OnWokO5bSPNoeZkquy2/bsIMFMJkzgQwY/6UKz+5mUw VzJAJbtgcqViEVpme8fU6210u5tUHVvLrLo99oafB+F/x+gyco9oWmsFUPPcrXVHwInO PTJJSfeW8+HT1i6UCtKk0aqfGINiUXAl7wgz4rc6GmuOBZhBODzfQtN6E8MvUktaQgJ0 g5/SPZ9bq2PhrsTSQqV+vu4EHQAlbbHVabxXZmb1RCpmk7PreYc9a/GNySueahGAdBFe vkOjZAzzugf8x4ZuHAOxn/pR5H1i7rModf1F8NV7KKPaDbTWgoWpVwla7pV1oz8Pp+eD Zgxg== 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=c+gqtMtT71E+QHqOq+JqAAJ/D08SVzIjdaWzP+X/2vY=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=ALuz/hUWiqbk/ufmjaD1zKyqLPzQhQpcVFjZ6MNJPl/HqNegUA2Wuoza/lQ1ByXLmO ouRjxnj1cswQKlS36W6cm48UJMVSNmRTZaPineW85THkk42GnNOLpfWIQMp4arBP5BGQ Nvxac9ccBhKg741OWNV56yfBnASdi+IiAkhDxEJyBZVrMUKd8vxkksVewpvBSlGzZnF/ sC0r5EnIydH3pLztzug8IX27OBE6VkpTsJ3nMuJqu/KBuQGOMlY1aWJviqYuwgsfffOs xKpnnv7EqyM3V8msH0bdLV+hulsx0xIkc0Pvv/A+wbcOfOkES6yqlViqquF38DE/C8Dt Kqeg== 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 b4-20020a170902650400b001bbab41391esi878205plk.327.2023.07.24.02.06.41; Mon, 24 Jul 2023 02:06:54 -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 S231521AbjGXI0G (ORCPT + 99 others); Mon, 24 Jul 2023 04:26:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbjGXIZ7 (ORCPT ); Mon, 24 Jul 2023 04:25:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1FADDE6C; Mon, 24 Jul 2023 01:25:46 -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 97F62DE0; Mon, 24 Jul 2023 01:26:29 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B8B9E3F67D; Mon, 24 Jul 2023 01:25:44 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 7/8] selftests/mm: Optionally pass duration to transhuge-stress Date: Mon, 24 Jul 2023 09:25:21 +0100 Message-Id: <20230724082522.1202616-8-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772292265339053587 X-GMAIL-MSGID: 1772292265339053587 Until now, transhuge-stress runs until its explicitly killed, so when invoked by run_kselftest.sh, it would run until the test timeout, then it would be killed and the test would be marked as failed. Add a new, optional command line parameter that allows the user to specify the duration in seconds that the program should run. The program exits after this duration with a success (0) exit code. If the argument is omitted the old behacvior remains. On it's own, this doesn't quite solve our problem because run_kselftest.sh does not allow passing parameters to the program under test. But we will shortly move this to run_vmtests.sh, which does allow parameter passing. Acked-by: David Hildenbrand Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/transhuge-stress.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/transhuge-stress.c b/tools/testing/selftests/mm/transhuge-stress.c index ba9d37ad3a89..c61fb9350b8c 100644 --- a/tools/testing/selftests/mm/transhuge-stress.c +++ b/tools/testing/selftests/mm/transhuge-stress.c @@ -25,13 +25,14 @@ int main(int argc, char **argv) { size_t ram, len; void *ptr, *p; - struct timespec a, b; + struct timespec start, a, b; int i = 0; char *name = NULL; double s; uint8_t *map; size_t map_len; int pagemap_fd; + int duration = 0; ram = sysconf(_SC_PHYS_PAGES); if (ram > SIZE_MAX / psize() / 4) @@ -42,9 +43,11 @@ int main(int argc, char **argv) while (++i < argc) { if (!strcmp(argv[i], "-h")) - errx(1, "usage: %s [size in MiB]", argv[0]); + errx(1, "usage: %s [-f ] [-d ] [size in MiB]", argv[0]); else if (!strcmp(argv[i], "-f")) name = argv[++i]; + else if (!strcmp(argv[i], "-d")) + duration = atoi(argv[++i]); else len = atoll(argv[i]) << 20; } @@ -78,6 +81,8 @@ int main(int argc, char **argv) if (!map) errx(2, "map malloc"); + clock_gettime(CLOCK_MONOTONIC, &start); + while (1) { int nr_succeed = 0, nr_failed = 0, nr_pages = 0; @@ -118,5 +123,8 @@ int main(int argc, char **argv) "%4d succeed, %4d failed, %4d different pages", s, s * 1000 / (len >> HPAGE_SHIFT), len / s / (1 << 20), nr_succeed, nr_failed, nr_pages); + + if (duration > 0 && b.tv_sec - start.tv_sec >= duration) + return 0; } } From patchwork Mon Jul 24 08:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 124726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1680954vqg; Mon, 24 Jul 2023 02:35:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlG0UB/yii0rklalqonHNh0kpd80ufY7TLAUxDgPK9CWhZG8CBOB3qI5FiCDNdukkD+7v7ey X-Received: by 2002:a05:6358:6f09:b0:134:eed0:3bc5 with SMTP id r9-20020a0563586f0900b00134eed03bc5mr2706671rwn.9.1690191351499; Mon, 24 Jul 2023 02:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690191351; cv=none; d=google.com; s=arc-20160816; b=pERn1GX8xQMNhKENWyQqAYl6BvuLwmEdNwTLrLd8+tBVuKV6Af7oeWsr8oWfO+QU0D wXz+WH+bAOq0ogKpPcrl8Mw/NFW3hbgWCHLI4U4+RX1kKO+uyg9z3NjOSSpIuQYitLy5 6IjH5L+EnFq5zyYouGmYWOjTRhk1DPltlXcQA1RuoSKuAIBoZhiYsZj3RPwOHcy0F62m RypabsBVYiyoZACTMa0gjVQwMzswCkUmShAN0gufCmzxPMG2YQvQ/JCa1YOQuvvIWXaJ Lkygs6Ptlpfzc+gJqtvGuK0amRcF7B7oyVEh4JZIgI2X1XI+/JxkUl09DyvvraROdWwv bU9Q== 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=P38aKxBNTwdPxsWii2NJDfq7k7dgyHj7yDkmvWqAUjA=; fh=6rhI9kvwCMo+fckRKZYXD+Cg7edipvyuIhlyok3MppU=; b=PqGc9br9KVRCK1vzSBJjqNk5+cSRDJ6z0V1Cv/V9uUx7m/P0ggCQuxx5MyD+Fo64Q2 0i7jtKd5JvxgM8alNLohp7z5zRx36UP8p9dFmB141w4sio3+mZ0t8Yp5hoztUYqbGnzF Dyp/hzs+xAD/m/HNsQM2staU93vJvXqXNpwpS94139vPkwNBxX+d5B3NiSb2G05xbiKN zNe196u+R4BKFsW2U8Y81AWRZQlpJJpJBH3qnkXJoASgcbYYqayLJ9TpOOtEjtiJ9YFM QBAAw3S4513Ggmi2PnybjovGATNtK0UD6ZoTtnMIGKeY4ARSOlOV1Jl4WYltL9jiAMJO MSNg== 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 h2-20020a635302000000b00548e140a1a6si6819365pgb.66.2023.07.24.02.35.38; Mon, 24 Jul 2023 02:35:51 -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 S231562AbjGXI0V (ORCPT + 99 others); Mon, 24 Jul 2023 04:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231553AbjGXI0F (ORCPT ); Mon, 24 Jul 2023 04:26:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E13E10D5; Mon, 24 Jul 2023 01:25:48 -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 AAB3E11FB; Mon, 24 Jul 2023 01:26:31 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AD6E83F67D; Mon, 24 Jul 2023 01:25:46 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "David Hildenbrand" , "Mark Brown" , "John Hubbard" , "Florent Revest" , "Peter Xu" Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH v3 8/8] selftests/mm: Run all tests from run_vmtests.sh Date: Mon, 24 Jul 2023 09:25:22 +0100 Message-Id: <20230724082522.1202616-9-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230724082522.1202616-1-ryan.roberts@arm.com> References: <20230724082522.1202616-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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: 1772294086692024989 X-GMAIL-MSGID: 1772294086692024989 It is very unclear to me how one is supposed to run all the mm selftests consistently and get clear results. Most of the test programs are launched by both run_vmtests.sh and run_kselftest.sh: hugepage-mmap hugepage-shm map_hugetlb hugepage-mremap hugepage-vmemmap hugetlb-madvise map_fixed_noreplace gup_test gup_longterm uffd-unit-tests uffd-stress compaction_test on-fault-limit map_populate mlock-random-test mlock2-tests mrelease_test mremap_test thuge-gen virtual_address_range va_high_addr_switch mremap_dontunmap hmm-tests madv_populate memfd_secret ksm_tests ksm_functional_tests soft-dirty cow However, of this set, when launched by run_vmtests.sh, some of the programs are invoked multiple times with different arguments. When invoked by run_kselftest.sh, they are invoked without arguments (and as a consequence, some fail immediately). Some test programs are only launched by run_vmtests.sh: test_vmalloc.sh And some test programs and only launched by run_kselftest.sh: khugepaged migration mkdirty transhuge-stress split_huge_page_test mdwe_test write_to_hugetlbfs Furthermore, run_vmtests.sh is invoked by run_kselftest.sh, so in this case all the test programs invoked by both scripts are run twice! Needless to say, this is a bit of a mess. In the absence of fully understanding the history here, it looks to me like the best solution is to launch ALL test programs from run_vmtests.sh, and ONLY invoke run_vmtests.sh from run_kselftest.sh. This way, we get full control over the parameters, each program is only invoked the intended number of times, and regardless of which script is used, the same tests get run in the same way. The only drawback is that if using run_kselftest.sh, it's top-level tap result reporting reports only a single test and it fails if any of the contained tests fail. I don't see this as a big deal though since we still see all the nested reporting from multiple layers. The other issue with this is that all of run_vmtests.sh must execute within a single kselftest timeout period, so let's increase that to something more suitable. In the Makefile, TEST_GEN_PROGS will compile and install the tests and will add them to the list of tests that run_kselftest.sh will run. TEST_GEN_FILES will compile and install the tests but will not add them to the test list. So let's move all the programs from TEST_GEN_PROGS to TEST_GEN_FILES so that they are built but not executed by run_kselftest.sh. Note that run_vmtests.sh is added to TEST_PROGS, which means it ends up in the test list. (the lack of "_GEN" means it won't be compiled, but simply copied). Acked-by: David Hildenbrand Acked-by: Peter Xu Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/Makefile | 79 ++++++++++++----------- tools/testing/selftests/mm/run_vmtests.sh | 23 +++++++ tools/testing/selftests/mm/settings | 2 +- 3 files changed, 64 insertions(+), 40 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 3514697fc2db..f39ba27d15fa 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -35,41 +35,41 @@ MAKEFLAGS += --no-builtin-rules CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) LDLIBS = -lrt -lpthread -TEST_GEN_PROGS = cow -TEST_GEN_PROGS += compaction_test -TEST_GEN_PROGS += gup_longterm -TEST_GEN_PROGS += gup_test -TEST_GEN_PROGS += hmm-tests -TEST_GEN_PROGS += hugetlb-madvise -TEST_GEN_PROGS += hugepage-mmap -TEST_GEN_PROGS += hugepage-mremap -TEST_GEN_PROGS += hugepage-shm -TEST_GEN_PROGS += hugepage-vmemmap -TEST_GEN_PROGS += khugepaged -TEST_GEN_PROGS += madv_populate -TEST_GEN_PROGS += map_fixed_noreplace -TEST_GEN_PROGS += map_hugetlb -TEST_GEN_PROGS += map_populate -TEST_GEN_PROGS += memfd_secret -TEST_GEN_PROGS += migration -TEST_GEN_PROGS += mkdirty -TEST_GEN_PROGS += mlock-random-test -TEST_GEN_PROGS += mlock2-tests -TEST_GEN_PROGS += mrelease_test -TEST_GEN_PROGS += mremap_dontunmap -TEST_GEN_PROGS += mremap_test -TEST_GEN_PROGS += on-fault-limit -TEST_GEN_PROGS += thuge-gen -TEST_GEN_PROGS += transhuge-stress -TEST_GEN_PROGS += uffd-stress -TEST_GEN_PROGS += uffd-unit-tests -TEST_GEN_PROGS += split_huge_page_test -TEST_GEN_PROGS += ksm_tests -TEST_GEN_PROGS += ksm_functional_tests -TEST_GEN_PROGS += mdwe_test +TEST_GEN_FILES = cow +TEST_GEN_FILES += compaction_test +TEST_GEN_FILES += gup_longterm +TEST_GEN_FILES += gup_test +TEST_GEN_FILES += hmm-tests +TEST_GEN_FILES += hugetlb-madvise +TEST_GEN_FILES += hugepage-mmap +TEST_GEN_FILES += hugepage-mremap +TEST_GEN_FILES += hugepage-shm +TEST_GEN_FILES += hugepage-vmemmap +TEST_GEN_FILES += khugepaged +TEST_GEN_FILES += madv_populate +TEST_GEN_FILES += map_fixed_noreplace +TEST_GEN_FILES += map_hugetlb +TEST_GEN_FILES += map_populate +TEST_GEN_FILES += memfd_secret +TEST_GEN_FILES += migration +TEST_GEN_FILES += mkdirty +TEST_GEN_FILES += mlock-random-test +TEST_GEN_FILES += mlock2-tests +TEST_GEN_FILES += mrelease_test +TEST_GEN_FILES += mremap_dontunmap +TEST_GEN_FILES += mremap_test +TEST_GEN_FILES += on-fault-limit +TEST_GEN_FILES += thuge-gen +TEST_GEN_FILES += transhuge-stress +TEST_GEN_FILES += uffd-stress +TEST_GEN_FILES += uffd-unit-tests +TEST_GEN_FILES += split_huge_page_test +TEST_GEN_FILES += ksm_tests +TEST_GEN_FILES += ksm_functional_tests +TEST_GEN_FILES += mdwe_test ifneq ($(ARCH),arm64) -TEST_GEN_PROGS += soft-dirty +TEST_GEN_FILES += soft-dirty endif ifeq ($(ARCH),x86_64) @@ -86,24 +86,24 @@ CFLAGS += -no-pie endif ifeq ($(CAN_BUILD_I386),1) -TEST_GEN_PROGS += $(BINARIES_32) +TEST_GEN_FILES += $(BINARIES_32) endif ifeq ($(CAN_BUILD_X86_64),1) -TEST_GEN_PROGS += $(BINARIES_64) +TEST_GEN_FILES += $(BINARIES_64) endif else ifneq (,$(findstring $(ARCH),ppc64)) -TEST_GEN_PROGS += protection_keys +TEST_GEN_FILES += protection_keys endif endif ifneq (,$(filter $(ARCH),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64)) -TEST_GEN_PROGS += va_high_addr_switch -TEST_GEN_PROGS += virtual_address_range -TEST_GEN_PROGS += write_to_hugetlbfs +TEST_GEN_FILES += va_high_addr_switch +TEST_GEN_FILES += virtual_address_range +TEST_GEN_FILES += write_to_hugetlbfs endif TEST_PROGS := run_vmtests.sh @@ -115,6 +115,7 @@ TEST_FILES += va_high_addr_switch.sh include ../lib.mk $(TEST_GEN_PROGS): vm_util.c +$(TEST_GEN_FILES): vm_util.c $(OUTPUT)/uffd-stress: uffd-common.c $(OUTPUT)/uffd-unit-tests: uffd-common.c diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 9e4338aa5e09..cc2cbc4405ff 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -55,6 +55,17 @@ separated by spaces: test soft dirty page bit semantics - cow test copy-on-write semantics +- thp + test transparent huge pages +- migration + invoke move_pages(2) to exercise the migration entry code + paths in the kernel +- mkdirty + test handling of code that might set PTE/PMD dirty in + read-only VMAs +- mdwe + test prctl(PR_SET_MDWE, ...) + example: ./run_vmtests.sh -t "hmm mmap ksm" EOF exit 0 @@ -298,6 +309,18 @@ fi # COW tests CATEGORY="cow" run_test ./cow +CATEGORY="thp" run_test ./khugepaged + +CATEGORY="thp" run_test ./transhuge-stress -d 20 + +CATEGORY="thp" run_test ./split_huge_page_test + +CATEGORY="migration" run_test ./migration + +CATEGORY="mkdirty" run_test ./mkdirty + +CATEGORY="mdwe" run_test ./mdwe_test + echo "SUMMARY: PASS=${count_pass} SKIP=${count_skip} FAIL=${count_fail}" exit $exitcode diff --git a/tools/testing/selftests/mm/settings b/tools/testing/selftests/mm/settings index ba4d85f74cd6..a953c96aa16e 100644 --- a/tools/testing/selftests/mm/settings +++ b/tools/testing/selftests/mm/settings @@ -1 +1 @@ -timeout=90 +timeout=180