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