Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5411570rwp; Mon, 17 Jul 2023 03:51:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlEjpedVf7QGJr6Mwdz1F9xyr4cKUzrsLcwvk5q/DqZr4+dOYRQWQziib1byca+SxFkk2jGY X-Received: by 2002:a17:902:dac2:b0:1b6:a37a:65b7 with SMTP id q2-20020a170902dac200b001b6a37a65b7mr12874426plx.23.1689591097066; Mon, 17 Jul 2023 03:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689591097; cv=none; d=google.com; s=arc-20160816; b=nODP1lItG7DkVlvoLJ46C3em6LPM2tlVH+eP6zCgbS1N7tLfmqTvUBOUo17A+/Y7HS X1GrDJauQyb43Q92uTJM1CEVTf9ZfJfML767TDqR48S6rlVvOTnUvJ4bi993TcghHTlU dFX5L+ECahPMRqB4VSoeClUxRM5KbT6Agx9lcmS4Oah3gJLS0QzuWvS5Dh5gt6V8zuru uC3jhmCaCXzykTYM4pemU6zYa7Fygzz4lQDFNBGHz7pBB21Zh0AyLpZjBgtANuqaTHRD YKF2qiH6MB+d4Cb7Y2Y/i9a6MSZhh0Crj+16blIqoJLfCBs8i/a2PC6ZzJJw3bmZA3/e 8N4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HXaz2BG8nd6sNHnpf1UWxQkbMfGOr+JlGHxrRhsm3QQ=; fh=OUPfCZjK3Gm4uAxJmzTYkNGoALdOI9ZG4q/pkSTXiCE=; b=fcGVzXajmflntKYv8A5MCIHm2I9cJaaAn1SlhttS6hQNtnAxtGr03LinR9Ufw8eiMu VV1nw7fkOuDaTuBavcVinoOUMBkfQmK4jiMA5gd+DWERNI0EcEP/StkGgWdETLsNT5IZ u8YjnF5VmVBsiJTBtZ39fZBZIeHozhbkzbMWVloT2oIAyS/rKBkAAq2tSf3nRMO5i2H0 Yk+pwG5gjpZkjhmgwVwBqYNjTkRmRwamahAQkFp4rbcn2rKGwf/lKSUIitsNRQ/s4nnd cxeRK+aTT2b/nqIH49XBbqRfLQVlwPAjEidRJbjKbczJ8/FmYVp1LfAMDmleZpg95Vs+ adHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020a170903404400b001a94b91f402si11156136pla.218.2023.07.17.03.51.24; Mon, 17 Jul 2023 03:51:37 -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 S231320AbjGQKcn (ORCPT + 99 others); Mon, 17 Jul 2023 06:32:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjGQKc2 (ORCPT ); Mon, 17 Jul 2023 06:32:28 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BBB14E7F; Mon, 17 Jul 2023 03:32:20 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 50AD12F4; Mon, 17 Jul 2023 03:33:03 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 578983F67D; Mon, 17 Jul 2023 03:32:18 -0700 (PDT) From: Ryan Roberts To: "Andrew Morton" , "Shuah Khan" , =?UTF-8?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 v2 7/8] selftests/mm: Optionally pass duration to transhuge-stress Date: Mon, 17 Jul 2023 11:31:51 +0100 Message-Id: <20230717103152.202078-8-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230717103152.202078-1-ryan.roberts@arm.com> References: <20230717103152.202078-1-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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; } } -- 2.25.1