From patchwork Mon Jul 17 10:31:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13315418 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 8203BC001DE for ; Mon, 17 Jul 2023 10:32:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A4566B0080; Mon, 17 Jul 2023 06:32:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 052266B0081; Mon, 17 Jul 2023 06:32:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E34358D0001; Mon, 17 Jul 2023 06:32:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D52A66B0080 for ; Mon, 17 Jul 2023 06:32:22 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A660E1A04DC for ; Mon, 17 Jul 2023 10:32:22 +0000 (UTC) X-FDA: 81020739324.18.131EBAD Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf14.hostedemail.com (Postfix) with ESMTP id E6C7310001B for ; Mon, 17 Jul 2023 10:32:20 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf14.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=1689589941; 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=HXaz2BG8nd6sNHnpf1UWxQkbMfGOr+JlGHxrRhsm3QQ=; b=eceFzSI3F7M6LPlf/fv9kfxUjFdJ3O/TALq3HqDuKBK/j/UCQtuhtUUB0jIq+ekTwHS6Yw Ui4SWjvS3tSCsjfaE1CEvhTfAKGb+cM+mOxhf4oXPfIiygd738NHdzyXpX/9CIclkBxa4Y X3r8LUiQMLTssXNHV6BRLCnWM4LQrGY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf14.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=1689589941; a=rsa-sha256; cv=none; b=6SCUzi9793oz3omG+S7bKFmuQBwiJ4F1gOkSaAw3zGqSRaBh9+yldLlqxnDnszhruAdl4u KzzCh+ZecoKghUJKd+0G+DQ6eGawPfs84LYNdse5Xj9FnOw0xUIECbSiKk6b9Z52FjTknE nhwuK5kgeKUinJHQ+mb81lFD9J5u5TA= 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?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 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 X-Rspamd-Queue-Id: E6C7310001B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: i3febqbwdnch9q43jk318g4uwacys3h4 X-HE-Tag: 1689589940-333753 X-HE-Meta: U2FsdGVkX1/PBniZbrYa/9aBtMAdvRGtCTDc0PGZIchHTjA8ejXLfc9niuqo8SKxjxSotDDJY52LKfNX/ZknZIKveZkH5FIHs3hTYKInKrf08UHzSVeAR+goFh6rmTEukb58b1WyTpvTstvevbtliJC6p11dKa1xsQY7DPphm88QJ8bOXD6Ymtgh37rztv9MMWQs8Wa0SRZgEoabniI2dJwI5TNykKwHQ54T0imebBAts+ZoSq+ojsB3Vc4H3Gft7TOuYnFCsw9nzxsA7kU5rNQ8lh0KSXPdQ8roTusO2fu0z6a59nwtpAlhx72x0jeUPfWMCe5N1IEw4myBY2lM93RyLpsdM373Z8vpyLohyA/rSmxci+uaqsOocNZnI6WZNJxNeTyZV+rwGl5bLgd8WHWcAtLCFp5pXMaN02qNr1qAf/mv4dsSIavcyvt9rfxfJQXWVLg70xhFhvjiNZwwzcF7bG+ypxrzrMHrBWnTYlabFYfJ1ZIBgPXyF17qMqR41j3203zzGN70yojfBqqXBoaUzYTcSCs3HPGpIUyxY6Wzyxfl4GrgEXZLVXeQz/FAJ7NYhZsChiVTSf/998bVbliX9wC7TsVeNghr41t1MpwRBGeukN5ZCaHochUn32YbD+aeZH4RPIuLDkI/ouEM37S6WR2rv4VyPuvq2Al+wNTEaverk75DRp5qqiALaju4cL1Uoqm9UB5l9D8lMfRtmPhgrS9YyeYSZwefR6PmX5w+Mogx1yQg9i6D7Hqk7p/TmzBcpMu/whrL7R7UXvBxiHetDzByUHKIXq3YJDJoLr3MHkSdEVSu9jeh6BVPOGT+ouheZK9mDHNATZ0VtjEQzYKl3Uf1ZUx/iMeM0wkKKCojZS/tqTxfLhy1HUx4XNiANKyY0dTIMiS0gLMSRrqsR/5dIZjBi+wjcrJPo6CFHZVpU8PUq72GTbZS/RzSywoyhbEB0zHi5RyEw4Dpgca NZza3zHz l1gBU6u85qYdnntVbA2HvK8D2vcCjGUzjpTHV9c5E4ws2lkhfteiBlQdS9aQEjzkUr1lycQVbxCwIEp8UPDmajTcM0SHb76ucv8RVVsP3Q9K8h7FKxXqrsrNOIkP422GXwJ/mnqyxIXjy0zPxrc3hGluQOq3AazjtC0+8 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: 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 Acked-by: David Hildenbrand --- 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; } }