From nobody Sat Feb 7 09:36:55 2026 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EC971F9ED1 for ; Thu, 9 Jan 2025 18:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736448062; cv=none; b=f/2/Nyxeg0bY+uISHnvRyJUpRH7NHjIIK8OHE3MyVNCxfhSe0nRm7cZNvlsXfF7AUY3Dm3IEiwbmT3OJeymO8ydI3qXk+rNYrwyk5Yidnd+7vBWCmJ8MirzN6ivi/0z8swUUA7OCCCc+DQWuTYfBH3zRTCcylIq3/xggGFmKSPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736448062; c=relaxed/simple; bh=94yDeESgARdf6BTx6q8uGdmYCl+Uug81Nad7ZVVSVzc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=eAhDINh4gt7kwZOEUhtB+PtWiThrYUOn1vfVU4iK/jU6q9eJt0PUvnnqTc3BwETzkyVnuXZHb9T/4TUIjXkeEWSVoq437iwoxjmnjo6x5fVELZtILR7Uzl/KAlU6n5T21CuNLNaaT0VeAiZf0isjwUmnvvB54etXJmWL14UPUSY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RJjze8DJ; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RJjze8DJ" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e48beea5778so2893543276.1 for ; Thu, 09 Jan 2025 10:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736448058; x=1737052858; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=bV8GcHcKtuj7GMNesJ0KkhHJkb7OCaruvoF/b4TYI9U=; b=RJjze8DJrewfGNROv3kLrlZjh33BgCG+pJj/YsOWgHPBmP6zXwqCXg59RuITrhsV1F 0bZ5eWOGT9S38OgZ6ZBJAt+p7v+4vd1OiD+hK9OyDMHzawzpdt7ASJFr1ikykbqbnTYL caNtzHfbzbXCixXQTyVQjL6vXqG9WpWmB1lj/Tzbx6sHEeqsY7ovEJzA24jIiSpXpEFp vuxEvSLcQXju2uSnOxJ0Q0MYkZAL0jo+KWp9lfl5koj0K//ssy639fUGbUemw1po6Ayo BmsxpJr7HhLrA36KuVdg8HwmbDwdA0n1V7gNPLwALwtnjci87yCzaaCVZVNsU05sz+oj dnwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736448058; x=1737052858; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bV8GcHcKtuj7GMNesJ0KkhHJkb7OCaruvoF/b4TYI9U=; b=ccJDe3o2RgdvXDl7HayXU27xxcIfEmZibA0ZLBtFyPG2AFEHgxjqpXpc/5GrtQZqwL W7M8J1KemyK6+SNEh7Je9oNNcH/DiSGRlU0Pe0NetwE7DjqMl5Cca1rLjIdMlJJ19Z3c FUMyeFgIt+X5QcbkWxmZUD2+8yOAlj/FCE2yI3xJn7ymdu2pOrEycmuL2WZzPVAhrIWu Dass9o/z1qvBOfbTd1TRe88O1UE6mhm495JBxhyTE5mLxvuYpQuytBdmtbYw6qkTNQxI OVFZfhrCmQJOV4TbWVwCqTtvTOLVIhowzdQnulrFddlS2hYb4ocV/C8S+OfFRxQcaOo1 HcZg== X-Forwarded-Encrypted: i=1; AJvYcCVSzI/0sYsoO5pO6WIpFyP21Z2x47u2qcFXwbgUT9HfoDVP6+dDI40+MqpzP+h1PY1FrIcjYiX5S8PmDbU=@vger.kernel.org X-Gm-Message-State: AOJu0YwAIemISH6pmJRi1F2LQBw9+Jm9x9ciOeDoK4r81FE/q2Jz+1RF 9jbQRjQ30ntzJ7bJMaemjTTgZfF0NHtihe34YWjBnkN0RXtVn4VvbLGSxBYYPTebFeZ+9iSrua7 7Xqma2A== X-Google-Smtp-Source: AGHT+IFg3DTQaMdwxZGCSqbwJsY7QUgVzARMAoFENDrPBpO9GNpfN2JnuS4lJ8aOdPZkSUJMUpzNXhiL9ODo X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:7ea3:d1e5:495a:9a4f]) (user=irogers job=sendgmr) by 2002:a25:684b:0:b0:e48:9cab:d051 with SMTP id 3f1490d57ef6-e54f01e588bmr17250276.9.1736448058531; Thu, 09 Jan 2025 10:40:58 -0800 (PST) Date: Thu, 9 Jan 2025 10:40:45 -0800 In-Reply-To: <20250109184046.193736-1-irogers@google.com> Message-Id: <20250109184046.193736-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250109184046.193736-1-irogers@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Subject: [PATCH v3 4/5] perf test: Add a runs-per-test flag From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To detect flakes it is useful to run tests more than once. Add a runs-per-test flag that will run each test multiple times. Example output: ``` $ perf test -r 3 lbr -v 122: perf record LBR tests : Ok 122: perf record LBR tests : Ok 122: perf record LBR tests : Ok ``` Update the documentation for the runs-per-test option. Signed-off-by: Ian Rogers --- tools/perf/Documentation/perf-test.txt | 9 ++++++++- tools/perf/tests/builtin-test.c | 28 ++++++++++++++++---------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/tools/perf/Documentation/perf-test.txt b/tools/perf/Documentat= ion/perf-test.txt index 8f8a3c367570..85f868c324ff 100644 --- a/tools/perf/Documentation/perf-test.txt +++ b/tools/perf/Documentation/perf-test.txt @@ -33,7 +33,14 @@ OPTIONS =20 -S:: --sequential:: - Run tests one after the other, this is the default mode. + Run all tests one after the other. By default "exclusive" + tests are run sequentially, but other tests are run in + parallel to speed execution. + +-r:: +--runs-per-test:: + Run each test the given number of times, by default once. This + option can be useful to determine if a test is flaky. =20 -F:: --dont-fork:: diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 887f735da900..729740c1e5e5 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -42,6 +42,8 @@ static bool dont_fork; /* Fork the tests in parallel and wait for their completion. */ static bool sequential; +/* Number of times each test is run. */ +static unsigned int runs_per_test =3D 1; const char *dso_to_test; const char *test_objdump_path =3D "objdump"; =20 @@ -485,7 +487,7 @@ static int __cmd_test(struct test_suite **suites, int a= rgc, const char *argv[], len =3D strlen(test_description(*t, i)); if (width < len) width =3D len; - num_tests++; + num_tests +=3D runs_per_test; } } child_tests =3D calloc(num_tests, sizeof(*child_tests)); @@ -549,16 +551,18 @@ static int __cmd_test(struct test_suite **suites, int= argc, const char *argv[], continue; } =20 - test_suite__for_each_test_case(*t, curr_test_case) { - if (!perf_test__matches(test_description(*t, curr_test_case), - curr_suite, argc, argv)) - continue; - - err =3D start_test(*t, curr_suite, curr_test_case, - &child_tests[child_test_num++], - width, pass); - if (err) - goto err_out; + for (unsigned int run =3D 0; run < runs_per_test; run++) { + test_suite__for_each_test_case(*t, curr_test_case) { + if (!perf_test__matches(test_description(*t, curr_test_case), + curr_suite, argc, argv)) + continue; + + err =3D start_test(*t, curr_suite, curr_test_case, + &child_tests[child_test_num++], + width, pass); + if (err) + goto err_out; + } } } if (!sequential) { @@ -698,6 +702,8 @@ int cmd_test(int argc, const char **argv) "Do not fork for testcase"), OPT_BOOLEAN('S', "sequential", &sequential, "Run the tests one after another rather than in parallel"), + OPT_UINTEGER('r', "runs-per-test", &runs_per_test, + "Run each test the given number of times, default 1"), OPT_STRING('w', "workload", &workload, "work", "workload to run for testi= ng, use '--list-workloads' to list the available ones."), OPT_BOOLEAN(0, "list-workloads", &list_workloads, "List the available bui= ltin workloads to use with -w/--workload"), OPT_STRING(0, "dso", &dso_to_test, "dso", "dso to test"), --=20 2.47.1.613.gc27f4b7a9f-goog