From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02BF4C04A94 for ; Mon, 24 Jul 2023 08:25:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 955DC6B007E; Mon, 24 Jul 2023 04:25:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8DD976B0080; Mon, 24 Jul 2023 04:25:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CC9B6B0081; Mon, 24 Jul 2023 04:25:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 668266B007E for ; Mon, 24 Jul 2023 04:25:47 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3DCCE1C902E for ; Mon, 24 Jul 2023 08:25:47 +0000 (UTC) X-FDA: 81045821934.26.6765191 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id 828D24000F for ; Mon, 24 Jul 2023 08:25:45 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690187145; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=851WhiQknpUsE4X1CElE53hGZjRb+eoC5oQhWBMUHjk=; b=KOfEDqjLc04CRhZRLeuv3v21JptMf0srbwcmqtF3d1f4TUb9Sywly2bTVk6Dko3odQ0dh/ x9KI8iF30TrjxWYku8goJ6CIX/aXq+ahondDMmkV2HUejv6RVfCFRJvDli2P484S02QVBd jR/G0n+aoI4uelL97QwqwT2PDZm0bac= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690187145; a=rsa-sha256; cv=none; b=SaZmB7MCzOTtztX3su9Tyk2uPniaMFOj4brRyZnafZ1DnnZU00A1UZQPMN8dNNSiv3MOwO YCW8S2m2eicqE2h4bKyVZwgBu4nB6ma0RbT6C0SDVliMh4OFunevYc7jUirVzbjOUyINc+ hSMFUOGn83rpi9+pfZucPDPPaI1yUjQ= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A37E515A1; Mon, 24 Jul 2023 01:26:27 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C45423F67D; Mon, 24 Jul 2023 01:25:42 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , "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 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 828D24000F X-Stat-Signature: tqwdq81oyrq8n8194e14smht6apj74kd X-HE-Tag: 1690187145-415853 X-HE-Meta: U2FsdGVkX1/iQFfUN2U1DoZblEjJOI9xmu73s5MhNkdR0LACN6AGiQhJpYxuDw6qE4nYQE5LDb8HEU5v4y9sBfre4TNk17ZyGMrk4qiG868QRfHx4Y5CzWN3ebJLpB6EEpgtugSG6QsNPSMb4njh9PGDOaU7CZn3d6128h2e2rzmJgioJln7z5cYWA6j6rym4neRWvOrwBbpYIgRzjx59nNdRjpCiQCmpjBtLN2/m8f+m5R6B382vE4CiTV91jqbMOX3STcqeWakQkqqBLo2sckuxbRvCBKYOvevvS2F3UR4seIBYUGe7MW7fPP5FeVJ/OEKZuVWiiX1ADIkopOAnve4K3L4cSGIdktwr13v/98cI5CrXfRyksXNH5Sl1Gv5FSuVKjdbN1qoYKXRBN4La4wH5efU2WVgAfxWjUndYHJUFsUl9J4SdquhA4brW08loRFHXLd5qlZOIkym96EZOyRztirmMzLACKPGARooVt2uKa7rNblrtTqpL5/eLdqY+z/IiYLi/DFi8LZ4zmbGfG6ESkA9ONa+9IbYD4qlHHS4ph+MOxomZFkBS5aO9TNf/yvRgoZZnd1TGHT0tz/BcChmDxNVkJTrr8I+qA5cSlYzstU2a61fLDQJrUOFhrC77fT6VitE3Qs8VRq2c/K9xsSqwBXWkwN4Knuxw4YqKKRVGW8Jw/IHRw+2x+U/bozTgxbe892LphaFT1LViT3khArZxUWgSJxC1A/fuZ0nNmSMCDnToTq4VkiP5iL/PxucVICL+ohAu8Y/mgkI/Ew/5aikoz0onsPI+YB/ztodPViNJvTKH6bcGloMcIVMw8Os6Tlu3KTPWVWp6mDdcEdnIAPmtTutvLOblMvARutQGFfXskt761QKRQvRmUKlH9iJ6tZ8aLG3ja7JkXY05umCJzITzSrr22rwAv9yIYhyVXS3QsBZM0BN9vJGj/dLSQiCwZQ3z9vGpOBZ7X1lcrd B3zYJzYL 62pn0V43dfEdEE9qMEyzPul25EmyJQF1EYDRFp+dlrg0dblmPPhBXVrwCdeCU20Ii5pEK5Vz8ZAtlWz0NpVv2jYWL6jIM0dfp0N+80iAeEUnTFQcw2Ng+KaAJEuHCQwh5cIDenLgg3y9sWbIshOuy9pwcquKPpUeT3B+J X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The `migration` test currently has a number of robustness problems that cause it to hang and leak resources. Timeout: There are 3 tests, which each previously ran for 60 seconds. However, the timeout in mm/settings for a single test binary was set to 45 seconds. So when run using run_kselftest.sh, the top level timeout would trigger before the test binary was finished. Solve this by meeting in the middle; each of the 3 tests now runs for 20 seconds (for a total of 60), and the top level timeout is set to 90 seconds. Leaking child processes: the `shared_anon` test fork()s some children but then an ASSERT() fires before the test kills those children. The assert causes immediate exit of the parent and leaking of the children. Furthermore, if run using the run_kselftest.sh wrapper, the wrapper would get stuck waiting for those children to exit, which never happens. Solve this by setting the "parent death signal" to SIGHUP in the child, so that the child is killed automatically if the parent dies. With these changes, the test binary now runs to completion on arm64, with 2 tests passing and the `shared_anon` test failing. Signed-off-by: Ryan Roberts --- 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 -- 2.25.1