From nobody Mon Nov 25 22:01:50 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 75B9E18BBAB for ; Thu, 24 Oct 2024 07:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755213; cv=none; b=JkWdd5rMuxbIv1xLqeqTAS2v2RhSjad59Jfb1Dh7NiXOjtArf73jxaopCjYdcPIRCWv4IrRPPXU4SfRL/AprGOW5VufiSBs4F6UAUha4LZ2n4vtzghL8EjISRAtm8yM66EP7qi3U4pu/C5RJBzIrQJbV/A0bhRpzPkw1KxiazzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755213; c=relaxed/simple; bh=k1wh2zeNE6tcCQX3Z6B3EqKklNoAQpiPb5SUkLK5tUw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=GZPuAntRhUbbMI7v6T71awkTGISTNdI0taBGPM/NQTOclo5FQ6d+4SOFwem9yP0ZOJiHbd+5BOS71zG5+kNSmTJeG8HIFI051HOPvayczps3xmYdIHQC+Wiiqflvkd++rmYyqjnuIxMg13/Qfe5i58/MbyuKIQtlF1RJaCRuq6w= 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=CHHmfFt/; arc=none smtp.client-ip=209.85.128.201 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="CHHmfFt/" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e355f1ff4bso11659207b3.2 for ; Thu, 24 Oct 2024 00:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755210; x=1730360010; 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=emVhY31H9kbevrWQVBQDFf3nVCs1KfHQ+C3lVsleo+E=; b=CHHmfFt/+hMzBcghRBLuhGopICpUNb6LGk2JYOvmDg/22Ps7zCDa1PoqT+i38aLQ25 jXLzVbUYTod8jycmXErEZwb2+ja/kAvZKoHCrvmPb6uZdxK/ZcwVFarTiC/On+qiZ0eN QNMXYOmlqpB5/FLrCUGulJU6eCjdG+Une92/BwGxu7r0XuMqlGIK6hL02ZaSsPuvZ8gV 2PtxGiQk2Ctmq2G7ca2YNgtTC3gR2PDw8JjJrvBqufea7QoptGHqgQIEtR0Ex6Wuc8X3 Td/rUh6BggBJQogrNdwqhli6rX6+yizM52hkhKMg9TDHpmbei0JQik/UxGWU0PMCMFOv 80fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755210; x=1730360010; 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=emVhY31H9kbevrWQVBQDFf3nVCs1KfHQ+C3lVsleo+E=; b=Ifex0vtxNBwCvSJPbf1iImMxn/esc9ZpXQEqP3zafm6uduzWx5CC0ZuU+O38AQKzPG 1RYbo1boxsaJH2f2PAo9RnynrUIl911KIcMu6letmR4xdjHj39Pplo5Mfp7DhlBpc1yY hrIZrz6zIsZJXw4zMPcRN7s19OnP4xzHPOLauBd+fhKRd/gIvvATg5sXa0ImFWEDq9n/ e0zny88H4Ml71Pm249oXfVFI5hX1P6IQcIfd1TmWbVuAEd8zgyqIcrC2uQz3EzhNfU09 3hnWQesZmNDMB6CoPq0ZH10kSYpY6IlEtZlNfl6JtYa8kg5GuEx8EtunqJ26lrCHJ7n/ oDMQ== X-Forwarded-Encrypted: i=1; AJvYcCVPdJK2LKVcm60/MxMXj8xbzJr3nd1EZz3bqjhTwOKHucRV9WtRwxzL8RhJp2W5vFQTt6YRLJdGCv866DE=@vger.kernel.org X-Gm-Message-State: AOJu0YyIKxbqzG3Podue1jcunfIybIc46SvfRRmzdhsjmhymkJaAIB+B SRBhlbySfa0Njz0l9RG1vKuSiaF9K6ItwT/8kYilo0F22Dr5BWtP5aKHGYGv+G6pOGS5xaKH/Nq ZO1HBng== X-Google-Smtp-Source: AGHT+IGIdX+9UGh1ipFNzZxImIUQiwAu6jkH0seO0G13+GIts4a3kwmqAN+xljlGfhEuVFEiPznPJdl+Fepv X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a05:690c:968a:b0:6e3:1f46:77a6 with SMTP id 00721157ae682-6e85814c3efmr1102067b3.2.1729755210383; Thu, 24 Oct 2024 00:33:30 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:15 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 01/10] tools subcmd: Add non-waitpid check_if_command_finished() 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Using waitpid can cause stdout/stderr of the child process to be lost. Use Linux's /prod//status file to determine if the process has reached the zombie state. Use the 'status' file rather than 'stat' to avoid issues around skipping the process name. Tested-by: James Clark Signed-off-by: Ian Rogers --- tools/lib/subcmd/run-command.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/lib/subcmd/run-command.c b/tools/lib/subcmd/run-command.c index 4e3a557a2f37..0a764c25c384 100644 --- a/tools/lib/subcmd/run-command.c +++ b/tools/lib/subcmd/run-command.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -217,8 +218,40 @@ static int wait_or_whine(struct child_process *cmd, bo= ol block) =20 int check_if_command_finished(struct child_process *cmd) { +#ifdef __linux__ + char filename[FILENAME_MAX + 12]; + char status_line[256]; + FILE *status_file; + + /* + * Check by reading /proc//status as calling waitpid causes + * stdout/stderr to be closed and data lost. + */ + sprintf(filename, "/proc/%d/status", cmd->pid); + status_file =3D fopen(filename, "r"); + if (status_file =3D=3D NULL) { + /* Open failed assume finish_command was called. */ + return true; + } + while (fgets(status_line, sizeof(status_line), status_file) !=3D NULL) { + char *p; + + if (strncmp(status_line, "State:", 6)) + continue; + + fclose(status_file); + p =3D status_line + 6; + while (isspace(*p)) + p++; + return *p =3D=3D 'Z' ? 1 : 0; + } + /* Read failed assume finish_command was called. */ + fclose(status_file); + return 1; +#else wait_or_whine(cmd, /*block=3D*/false); return cmd->finished; +#endif } =20 int finish_command(struct child_process *cmd) --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 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 80D3E1AC42B for ; Thu, 24 Oct 2024 07:33:33 +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=1729755215; cv=none; b=bUgUpySzU7Q8qbsgaNiKqqOHWo4sxNcL0fxRwzSwr8Q8aLGTHIcQOejpqy2Mm5l0gUXGCNkcwOJZ19Gc2490k9blniCh386cLIAOHZuAKZ3yuTTiO5UTxrxCw9RpwK49W2GJyiDfQ1fFFBeFG4HddPc67X8DTuqI9dp7YidCDnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755215; c=relaxed/simple; bh=TSak5ySXPhsLutG7PU4Surkoqp+hdpOAqqLFfKer4U4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=FYbpkA2Xz5PWaUjuId0dmqy9A9Jbp2YGSJAaYZy1rAopmEOD/0c211r2hHScTioWZVokGT5xkqEE2U78WqdnmCVCwQFMRlyAvRDnFu99+B5M4Z0E112OSqevx84a+mJtvD20ZownVVcriD3iceiX2mdrL0zbJeW7YSoeAQPqg6o= 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=HjV6ZARk; 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="HjV6ZARk" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e290b8b69f8so1212778276.2 for ; Thu, 24 Oct 2024 00:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755212; x=1730360012; 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=6to4NuyfolqiFxIhj4wLEb7fpmyV6YykqeCK5v8XPJY=; b=HjV6ZARk3iO28gS4hkw2iA1qUBY1DREF6cgOORtoIa9BaI2TvaC4CGTQt0a1KOmQ5r GL5aft4CePzM3g9AQAH185LahU5c7AaF9VFx4fVnqoYSl24XHKvCn8vAtP7C96jtjGRY hq99HjD/NPskuHq8dzqedeGH2bGwy7e/HGRc/R4gde2pJnADKBPT9lpPA6xGeHRj53MF Np3+BrPzx08NJPWjMARqBj+waQKLCWL4vFbluho/U2sJrxUzvvNEUevLMHB1d7pWB7qF 8bibLa1likRmXKfdTaqgwEq2anpNAoi0msC9BM1vo1Ya/kZnW61rn2XGb0ecXxMl4hSl 3WUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755212; x=1730360012; 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=6to4NuyfolqiFxIhj4wLEb7fpmyV6YykqeCK5v8XPJY=; b=siXC0y07C/ilt0k28FyO4yU8qz/I2akJ2jDRmKpguPD/qwX+cczhBK+pxg5LspRVH5 FVRqUrfn6P3aClkrRCCjH3ep+1bOVGBt4nEzbcM37ZeIhNt6NRlxfKRc3X2OZUE91fSh eW/+v1S563MLSbDnwY7XsuF8K0tn3YrANwsjAA6MN10w2aM5vE1jKz4+mb3Vogqy0fdE I2fDGySFrudMhWGyxMrLddcvUPHQ8HP/+uHTzuNpvLfvFcsCibdVG3svRxn/zha0VWD6 McKbBk1dXicTVkPNclT6dWz2kvEmkNk1aFbWsSEDRijTiewWBdhYuVLq/KCxiZqHZ7wH 5IqA== X-Forwarded-Encrypted: i=1; AJvYcCVMSime3qfGP3Gixs5d57EdXFtQOM4B1UW6+CYc8yn7uAQOXGK1ez9yHq+7BBFNOEy2yWmnhMcW/JhhSNo=@vger.kernel.org X-Gm-Message-State: AOJu0YwO551RrnYxWfc8m3u/uZncbgFvL2SIVlXtu7O2lZRZqLSxwF4u luGy8qlWeccWyjeU0m52IGxtI50oMzWdeCyxNDPRKJHr2EXsoZ5abhaJnTOY44EpkLj8xRGbJ7h zDmppPw== X-Google-Smtp-Source: AGHT+IE/3pt+QSPw5jo9m6FWclN/3Hb9t2DDd3wM7nv2BGyfys15KEILu/W7GdtX2gbyErfst+UiUJhiWkp5 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a5b:b09:0:b0:e28:e97f:538d with SMTP id 3f1490d57ef6-e2f2fc1ad8dmr609276.6.1729755212347; Thu, 24 Oct 2024 00:33:32 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:16 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 02/10] perf test: Display number of active running tests 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Before polling or sleeping to wait for a test to complete, print out ": Running ( active)" where the number of active tests is determined by iterating over the tests and seeing which return false for check_if_command_finished. The line erasing and printing out only occur if the number of runnings tests changes to avoid the line flickering excessively. Knowing tests are running allows a user to know a test is running and in parallel mode how many of the tests are waiting to complete. If color mode is disabled then avoid displaying the "Running" message as deleting the line isn't reliable. Tested-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 93 ++++++++++++++++++++++----------- tools/perf/util/color.h | 1 + 2 files changed, 63 insertions(+), 31 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 7d27e30d9b2d..57d2e9e03fbc 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -245,7 +245,10 @@ static int run_test_child(struct child_process *proces= s) return -err; } =20 -static int print_test_result(struct test_suite *t, int i, int subtest, int= result, int width) +#define TEST_RUNNING -3 + +static int print_test_result(struct test_suite *t, int i, int subtest, int= result, int width, + int running) { if (has_subtests(t)) { int subw =3D width > 2 ? width - 2 : width; @@ -255,6 +258,9 @@ static int print_test_result(struct test_suite *t, int = i, int subtest, int resul pr_info("%3d: %-*s:", i + 1, width, test_description(t, subtest)); =20 switch (result) { + case TEST_RUNNING: + color_fprintf(stderr, PERF_COLOR_YELLOW, " Running (%d active)\n", runni= ng); + break; case TEST_OK: pr_info(" Ok\n"); break; @@ -276,14 +282,17 @@ static int print_test_result(struct test_suite *t, in= t i, int subtest, int resul return 0; } =20 -static int finish_test(struct child_test *child_test, int width) +static int finish_test(struct child_test **child_tests, int running_test, = int child_test_num, + int width) { + struct child_test *child_test =3D child_tests[running_test]; struct test_suite *t =3D child_test->test; int i =3D child_test->test_num; int subi =3D child_test->subtest; int err =3D child_test->process.err; - bool err_done =3D err <=3D 0; + bool err_done =3D false; struct strbuf err_output =3D STRBUF_INIT; + int last_running =3D -1; int ret; =20 /* @@ -297,7 +306,7 @@ static int finish_test(struct child_test *child_test, i= nt width) * Busy loop reading from the child's stdout/stderr that are set to be * non-blocking until EOF. */ - if (!err_done) + if (err > 0) fcntl(err, F_SETFL, O_NONBLOCK); if (verbose > 1) { if (has_subtests(t)) @@ -311,38 +320,60 @@ static int finish_test(struct child_test *child_test,= int width) .events =3D POLLIN | POLLERR | POLLHUP | POLLNVAL, }, }; - char buf[512]; - ssize_t len; - - /* Poll to avoid excessive spinning, timeout set for 100ms. */ - poll(pfds, ARRAY_SIZE(pfds), /*timeout=3D*/100); - if (!err_done && pfds[0].revents) { - errno =3D 0; - len =3D read(err, buf, sizeof(buf) - 1); - - if (len <=3D 0) { - err_done =3D errno !=3D EAGAIN; - } else { - buf[len] =3D '\0'; - if (verbose > 1) - fprintf(stdout, "%s", buf); - else + if (perf_use_color_default) { + int running =3D 0; + + for (int y =3D running_test; y < child_test_num; y++) { + if (check_if_command_finished(&child_tests[y]->process) =3D=3D 0) + running++; + } + if (running !=3D last_running) { + if (last_running !=3D -1) { + /* + * Erase "Running (.. active)" line + * printed before poll/sleep. + */ + fprintf(debug_file(), PERF_COLOR_DELETE_LINE); + } + print_test_result(t, i, subi, TEST_RUNNING, width, running); + last_running =3D running; + } + } + + err_done =3D true; + if (err <=3D 0) { + /* No child stderr to poll, sleep for 10ms for child to complete. */ + usleep(10 * 1000); + } else { + /* Poll to avoid excessive spinning, timeout set for 100ms. */ + poll(pfds, ARRAY_SIZE(pfds), /*timeout=3D*/100); + if (pfds[0].revents) { + char buf[512]; + ssize_t len; + + len =3D read(err, buf, sizeof(buf) - 1); + + if (len > 0) { + err_done =3D false; + buf[len] =3D '\0'; strbuf_addstr(&err_output, buf); + } } } + if (err_done) + err_done =3D check_if_command_finished(&child_test->process); + } + if (perf_use_color_default && last_running !=3D -1) { + /* Erase "Running (.. active)" line printed before poll/sleep. */ + fprintf(debug_file(), PERF_COLOR_DELETE_LINE); } /* Clean up child process. */ ret =3D finish_command(&child_test->process); - if (verbose =3D=3D 1 && ret =3D=3D TEST_FAIL) { - /* Add header for test that was skipped above. */ - if (has_subtests(t)) - pr_info("%3d.%1d: %s:\n", i + 1, subi + 1, test_description(t, subi)); - else - pr_info("%3d: %s:\n", i + 1, test_description(t, -1)); + if (verbose > 1 || (verbose =3D=3D 1 && ret =3D=3D TEST_FAIL)) fprintf(stderr, "%s", err_output.buf); - } + strbuf_release(&err_output); - print_test_result(t, i, subi, ret, width); + print_test_result(t, i, subi, ret, width, /*running=3D*/0); if (err > 0) close(err); return 0; @@ -358,7 +389,7 @@ static int start_test(struct test_suite *test, int i, i= nt subi, struct child_tes pr_debug("--- start ---\n"); err =3D test_function(test, subi)(test, subi); pr_debug("---- end ----\n"); - print_test_result(test, i, subi, err, width); + print_test_result(test, i, subi, err, width, /*running=3D*/0); return 0; } =20 @@ -383,7 +414,7 @@ static int start_test(struct test_suite *test, int i, i= nt subi, struct child_tes err =3D start_command(&(*child)->process); if (err || !sequential) return err; - return finish_test(*child, width); + return finish_test(child, /*running_test=3D*/0, /*child_test_num=3D*/1, w= idth); } =20 #define for_each_test(j, k, t) \ @@ -468,7 +499,7 @@ static int __cmd_test(int argc, const char *argv[], str= uct intlist *skiplist) } for (i =3D 0; i < child_test_num; i++) { if (!sequential) { - int ret =3D finish_test(child_tests[i], width); + int ret =3D finish_test(child_tests, i, child_test_num, width); =20 if (ret) return ret; diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h index b2f37de305f6..9a7248dbe2d7 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h @@ -23,6 +23,7 @@ #define MIN_GREEN 0.5 #define MIN_RED 5.0 =20 +#define PERF_COLOR_DELETE_LINE "\033[A\33[2K\r" /* * This variable stores the value of color.ui */ --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 A1D041AF0A3 for ; Thu, 24 Oct 2024 07:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755217; cv=none; b=bmiSFgue/0a6So7F5KgbEeKyjugUaEohDEoLqskdSs2W7ZPaZfArsNU2A5y8mt2clDsJydqbTJdDQlvDMuHhY8yRkjyEK/zkEwkml5JZk/U1x+6jR7gcjttkgkz/oT2UqavegeKiY7auCk+lfROQjn7Urqn/rqL9r3y29J3mh6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755217; c=relaxed/simple; bh=bl0TwbExu4G349NNkk4dquZriD14f6vKBPjGiiViYyk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=s0UVqw5Hlb4IE6nijQ4kd/ofq5BndycEUcisCONMQiXNxWcaw5f4sJr2sy6c2jKWuwVpbUmtv4DtD/GgUulvEGHHN6vJR1err79JBb34P8F+U9Otio15PQVQz53d3mg58vpYn6Wa0MH2d+t2av/rZ8iLqhDwoML9f7lJYSt3R9A= 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=ekG/xcrn; arc=none smtp.client-ip=209.85.128.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="ekG/xcrn" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6dbbeee08f0so23142837b3.0 for ; Thu, 24 Oct 2024 00:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755215; x=1730360015; 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=2yVnPqZ8RpP/8r+vCUjKwDzk1QDMtk4+iGqU5/U/LQI=; b=ekG/xcrnDqq9cTA/iiFLKRbhy2VEQpERIDNrGShuwpJYyNxZlcP1hBgNMaWr6Qkp8a 4jzOSM9ZmwSyo2pLq6L68MKpQL1EwyQbhkhecfW6oUni1lD5yyakzmMoZlhVhu4VlWs0 pjXa9yKYRRwWQPPHaA4+g1lfAdzbqD1PgXqjIJFL/YqEacOSM3uUe1tHWkbSHh48KpRu eE1VWd1PR9ZpFIWyDa5akuwPQ7+UzPbgLuVOz8hSGXnoCiTTIUyqHkbJ8p0+xFglvYLi Ols8upXCRFUGC6HD73ZOovnmf/6pdup8YzAHvHSZEQbQc9KJjzEgyOJ9HRRFlSFZR/0R dEVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755215; x=1730360015; 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=2yVnPqZ8RpP/8r+vCUjKwDzk1QDMtk4+iGqU5/U/LQI=; b=rzWblKJzUgjXXwkg66q0O0qzo30H8OQUhl0ST+92MI6fC+ozHWjxraxaiOGYigc9+v h0RrzfG2v+jNohJKo4x3Ru6p8VQn8skXnkdZmUPdZ4I3z74Yesl6n8bKMuQd3XnXlnIg e1bqbUvPdasH1kXipmok10NCL3fZ/q+6hpzsqqMh1aYNMV799APvnmqzj2YXi5F6qb0u KoHNUlnXLuo8z7RmuOP3UEhZXwGxcojFM29sIqqRV0tLauRoUNxTOaISNn2nYClpaYhP ZDCt6LED/wt3I8tW666ufF1vHA+tOGNPJifMetdyqXFEBXejpo4GZkTH7EUUSsofNaiq rNHg== X-Forwarded-Encrypted: i=1; AJvYcCUFqiyMzhZAjQTu1TA2DcYl6kWl4WLsxhga+/5R4LsqkwSa2SP8ssnXShy/3qODGo9YFgQ/mtmaNjVQtY8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy8dijlQOQapbk13kZL0bY6JaIuRhWCqcx4s35pJm2aZEba5Z5Q cLP4EjXbJCz0NnPg6Ta+IXE80hDQVtRhnTxWBPqTmyaeQQawm8KsdnYtvw5mOu4uDBHZCBtFpzY 3gFJPng== X-Google-Smtp-Source: AGHT+IFhAeOq6ksfdCCDp5Gvm3pCls8guQL8J1bSwHwpWmahAPhyCJrGStCtgKeRCOJldq5aosIa1voblhde X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a5b:60c:0:b0:e29:7587:66d6 with SMTP id 3f1490d57ef6-e2ee7b732efmr5876276.4.1729755214276; Thu, 24 Oct 2024 00:33:34 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:17 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 03/10] perf test: Reduce scope of parallel variable 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The variable duplicates sequential but is only used for command line argument processing. Reduce scope to make the behavior clearer. Tested-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 57d2e9e03fbc..0e8f877f4b1f 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -41,9 +41,6 @@ static bool dont_fork; /* Don't fork the tests in parallel and wait for their completion. */ static bool sequential =3D true; -/* Do it in parallel, lacks infrastructure to avoid running tests that cla= sh for resources, - * So leave it as the developers choice to enable while working on the nee= ded infra */ -static bool parallel; const char *dso_to_test; const char *test_objdump_path =3D "objdump"; =20 @@ -578,6 +575,12 @@ int cmd_test(int argc, const char **argv) const char *skip =3D NULL; const char *workload =3D NULL; bool list_workloads =3D false; + /* + * Run tests in parallel, lacks infrastructure to avoid running tests + * that clash for resources, So leave it as the developers choice to + * enable while working on the needed infra. + */ + bool parallel =3D false; const struct option test_options[] =3D { OPT_STRING('s', "skip", &skip, "tests", "tests to skip"), OPT_INCR('v', "verbose", &verbose, --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 E25451AF0C9 for ; Thu, 24 Oct 2024 07:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755219; cv=none; b=QyOs8Vpj2r8RnwqXBsFu6u20ivTyl4Beg1UH+FS8vMycB4kF+XJbhCmmfy550M689SVOm8rHk9sgTPK2shEO9DfwJw3BxDPQCpAb5tVfT7gvk4bppoHdsfXVRsW8AytxHYebVqxO3HXCK1E54sgfRna7kSKkF915mxmKpDq7DMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755219; c=relaxed/simple; bh=0odQGceZNBTkUJ7F9d7VELVpW9gytwTlwU17UG1a/+U=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=o6xvTZ01H7y5+M4IC9Hqj3Su9aXKw4EcDYWC2dzrlQsXVBFwwa2vvu9Td/oBSVprsUWh2ljEybaA7Mk60ezL/HbRlwZlIFlB95WwfMUVFgjc1nTv/dIvAyXpLab6M7Ndp4ENNWtiCOFROiJLAVrQjrR+f5v5IoE7NMJRTqmj5nI= 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=DAhqF73g; arc=none smtp.client-ip=209.85.128.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="DAhqF73g" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e35a643200so12554887b3.0 for ; Thu, 24 Oct 2024 00:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755217; x=1730360017; 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=6iAkrxns4o/btTyHCpeR4AXaTsboqF9Bu2tTm7l0wyc=; b=DAhqF73gMsdPuRr+r90hmQB7GUvP+OwUu4nVIinIp1c3c5cYUQrBT+8BekrsAR9cJw 8qY38NEzOVk4ea4HJEBP/VygbFGZSko/kbLlaymTKZllpsM+jaPp1YX7OfUXMq6Rfnj9 AAmkoPdsewrsBXF5I7wcyDEGSpH7z18fLEwNu1vY4+M45f6KV2hguf4IOM0wh6nc3gDd OIEFqJBJBodc2sVkXD/zL0c5Boe/jg1/LLaXvY7Z9IqxlwJmhWgqcdGES5/n1gutlMuk 5hkDk7vU7UILqGLf3Df5lAe+4MR6/Q64NEGPulkTEPF49jH5EYEQZ4V/Guwy21o0mX2C ZQvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755217; x=1730360017; 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=6iAkrxns4o/btTyHCpeR4AXaTsboqF9Bu2tTm7l0wyc=; b=eDFbHAfPwVJU6n7q995dwie9GLJvlVXALPZOxTSG8l/GzUP+WQ+oZGW7Q/nZkxTSGM WIQmgNzaD6nnxC91r23m/z0dlJKmAgEPjEmnTyshHbgycwY8ypByjHmHtIa5yM/Wdofd tkwlf2FO5aXBzq9z2TEdUXpZlRTCgm2CmtJi0DFJACZuGAiRpGVcvgo7Z07oen+SGeDr eYzA76PIoATH8cQz0w6y4L1OI9iFggSzRKS6xp/cPVTiYdYLjdpPP5gXRSqvcuVZ8Es6 D+JJFJH3/ZiRe6NtvPBcI5f2AdZT8dy5H//YyZ702NmmvF0wA8VXWJeZ1p0jeYlx5rSb AOVQ== X-Forwarded-Encrypted: i=1; AJvYcCUlu0NbwHDqDnK70iUlcV/hOim8vPzaFjUv55sj+p64aS2rJ9LG4yMaQohm5HY34drxRzrCEQrRKoONhkk=@vger.kernel.org X-Gm-Message-State: AOJu0YzmJnEeL+zwZgClUl3z9qg6Q/zKS7vuRCkDnIxvlD6p+T6nooLc r/uIfd6521qt2cbcOSd1PR9X73tKvP425O0j2okJQcIWZAKLDsb4TDW8GqT8CTjLQAaJIL+yRnS 08w9ykQ== X-Google-Smtp-Source: AGHT+IFFtCAXX1qu6Kjrfshreh94FSiauh3ke22NfApbqYF5WQtwb+Vjg397ye8X47fUQ6CqaBJChB4TkWZg X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a05:690c:4804:b0:6e2:1842:c2e9 with SMTP id 00721157ae682-6e8662f961dmr528997b3.4.1729755217042; Thu, 24 Oct 2024 00:33:37 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:18 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-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: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 04/10] perf test: Avoid list test blocking on writing to stdout 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Python's json.tool will output the input json to stdout. Redirect to /dev/null to avoid blocking on stdout writes. Tested-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/tests/shell/list.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/shell/list.sh b/tools/perf/tests/shell/list.sh index 8a868ae64560..76a9846cff22 100755 --- a/tools/perf/tests/shell/list.sh +++ b/tools/perf/tests/shell/list.sh @@ -24,8 +24,11 @@ trap trap_cleanup EXIT TERM INT =20 test_list_json() { echo "Json output test" + # Generate perf list json output into list_output file. perf list -j -o "${list_output}" - $PYTHON -m json.tool "${list_output}" + # Validate the json using python, redirect the json copy to /dev/null as + # otherwise the test may block writing to stdout. + $PYTHON -m json.tool "${list_output}" /dev/null echo "Json output test [Success]" } =20 --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 6D1CB1B0F17 for ; Thu, 24 Oct 2024 07:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755223; cv=none; b=K8ApjjWovSzixgTGOy09nI7RcOiX0ar2eSivzoc64afJwmxUXvGU29OuJhkSkaHpeiAmCzCTE169qOQB+vaT1uJ7K0w6ktYsN+xrg4oxHxzj9B8DIMn/D2viGWc+hBgZ4PW9peqJOI/2X/U6xIhIPmP3iogU4Q5L2rZ7v+uo1MI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755223; c=relaxed/simple; bh=mzs9bpF6JHwXJ8hIAxSNZGhb19FZ05kQ6DmUcVcuGGM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=bglLRY60/sNf6wX8tkREIoISCiDDsVIjD6klV85YZTiGdtqy62khk4siylxPojwOxEFadqZk1GwKsAx5cJPOXfhfooIHr/yaDvfNpxXtlleh8rNcIxUFhOa8XkPYtdJtEWbi9kcg7+tQESZ1ZVAGqcqJZo9uIVwFOcQCqw5m+/g= 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=W63uR3LJ; arc=none smtp.client-ip=209.85.219.201 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="W63uR3LJ" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e28fea2adb6so1004820276.3 for ; Thu, 24 Oct 2024 00:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755219; x=1730360019; 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=yoDrzi0jU1SDEZaATimUzGZrwxZdaWaGm3pLE7ogKGc=; b=W63uR3LJEznTv6uvLVXibK18/sBISfhWdvQgWhFhe1dBqHlH9F0HruuO98Se/1QSnr a8nJTZL+cherxzt/3NKYuiIEEYq+djRwvAJfcs7o6W3EO37HBPqbQ4JVUMmVLhWFiOU7 7mg7rwyyHliMqLC+eWp2j2+bHuqMC0WupMVWIFsUw+jflo7wwNJmGC3BYCLkqG0nc6oi 014PYWYNuv1r0Zpy9SJFVVPqE/lQ3PsgoGVL0XIBWh+4pyTmA7hKwnrwIVA4FjSSqTZe ucyDG9FhF3oB1e86CpqTDoB9bNkFHuPTq3k5fsbBfh4HVmw7H02XeE0ukJRZ6gcwNq9K Fnpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755219; x=1730360019; 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=yoDrzi0jU1SDEZaATimUzGZrwxZdaWaGm3pLE7ogKGc=; b=xL+qk6xHJU5qZZeyO0L0/iDBsi5ifiXJ6Y687BMn1uWPqAc5PRGVPt4h/JhzSpczHK AEBkhTYlBmywZHSIG8HWJU9Clt9WnqPek8TUYxpcmpD3LimS/NPSfugosrL11P8ng3yo oRteUvnzAOJ8q1HbDjyENnok0qX+i27JLZRRn0z0shwa+sIZ3XqJoO1g+cxTVixlskT+ x41Oo6YlrjHQmJsmvrOxBWyXip758u/3GouEytmYLc7HG9cRQ9dbIPwu8TDWP4GP0Knd F8e5AmI1Brse2vVWTXQ5H6y2hmQ7+YWJj1r8b/JFseW/5O+2/ezqxTNk4nqBgbGZqu89 Gwyw== X-Forwarded-Encrypted: i=1; AJvYcCV73wUYI8MzaBBsEgSt0sxv/meYiND6TmNTUr7GTKd4lrWjuedsmYDWZYqS6vZD6iSqUYgqHqhB6Mga1po=@vger.kernel.org X-Gm-Message-State: AOJu0YwIJgICwbeL4K0lUoWeB9N3/uCZXBke2Niq1cgGrX7P16PwEZBQ IyoXa0c55akuW73ZwfylgkZIxv6X7lQEaiZ8AFVKnHLM+uFnA7Ab8yUBW5vi10uSbhUuN166ieh VX7gxBQ== X-Google-Smtp-Source: AGHT+IFfChWNLIB2mUkSnuKKVqSRAHn4XQBzn3+pf1GdHvalOj6torjmW24OVSVViNgdqzFBtdZ3QxP1jdpv X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a25:d810:0:b0:e29:7479:402a with SMTP id 3f1490d57ef6-e2f2fc4964dmr1671276.10.1729755219393; Thu, 24 Oct 2024 00:33:39 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:19 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 05/10] perf test: Tag parallel failing shell tests with "(exclusive)" 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some shell tests compete for resources and so can't run with other tests, tag such tests. The "(exclusive)" stems from shared/exclusive to describe how the tests run as if holding a lock. For ARM/coresight tests: Suggested-by: James Clark Additional failing tests: Suggested-by: Namhyung Kim Tested-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/tests/shell/coresight/asm_pure_loop.sh | 2 +- tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh | 2 +- tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh | 2 +- tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh | 2 +- tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh | 2 +- tools/perf/tests/shell/perftool-testsuite_report.sh | 2 +- tools/perf/tests/shell/probe_vfs_getname.sh | 2 +- tools/perf/tests/shell/record+script_probe_vfs_getname.sh | 2 +- tools/perf/tests/shell/record.sh | 2 +- tools/perf/tests/shell/record_lbr.sh | 2 +- tools/perf/tests/shell/record_offcpu.sh | 2 +- tools/perf/tests/shell/stat_all_pmu.sh | 2 +- tools/perf/tests/shell/stat_bpf_counters.sh | 2 +- tools/perf/tests/shell/test_arm_coresight.sh | 2 +- tools/perf/tests/shell/test_arm_coresight_disasm.sh | 2 +- tools/perf/tests/shell/test_arm_spe.sh | 2 +- tools/perf/tests/shell/test_data_symbol.sh | 2 +- tools/perf/tests/shell/test_intel_pt.sh | 2 +- tools/perf/tests/shell/test_stat_intel_tpebs.sh | 2 +- tools/perf/tests/shell/trace+probe_vfs_getname.sh | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/perf/tests/shell/coresight/asm_pure_loop.sh b/tools/perf= /tests/shell/coresight/asm_pure_loop.sh index 2d65defb7e0f..c63bc8c73e26 100755 --- a/tools/perf/tests/shell/coresight/asm_pure_loop.sh +++ b/tools/perf/tests/shell/coresight/asm_pure_loop.sh @@ -1,5 +1,5 @@ #!/bin/sh -e -# CoreSight / ASM Pure Loop +# CoreSight / ASM Pure Loop (exclusive) =20 # SPDX-License-Identifier: GPL-2.0 # Carsten Haitzler , 2021 diff --git a/tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh b/too= ls/perf/tests/shell/coresight/memcpy_thread_16k_10.sh index ddcc9bb850f5..8e29630957c8 100755 --- a/tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh +++ b/tools/perf/tests/shell/coresight/memcpy_thread_16k_10.sh @@ -1,5 +1,5 @@ #!/bin/sh -e -# CoreSight / Memcpy 16k 10 Threads +# CoreSight / Memcpy 16k 10 Threads (exclusive) =20 # SPDX-License-Identifier: GPL-2.0 # Carsten Haitzler , 2021 diff --git a/tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh b= /tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh index 2ce5e139b2fd..0c4c82a1c8e1 100755 --- a/tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh +++ b/tools/perf/tests/shell/coresight/thread_loop_check_tid_10.sh @@ -1,5 +1,5 @@ #!/bin/sh -e -# CoreSight / Thread Loop 10 Threads - Check TID +# CoreSight / Thread Loop 10 Threads - Check TID (exclusive) =20 # SPDX-License-Identifier: GPL-2.0 # Carsten Haitzler , 2021 diff --git a/tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh b/= tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh index 3ad9498753d7..d3aea9fc6ced 100755 --- a/tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh +++ b/tools/perf/tests/shell/coresight/thread_loop_check_tid_2.sh @@ -1,5 +1,5 @@ #!/bin/sh -e -# CoreSight / Thread Loop 2 Threads - Check TID +# CoreSight / Thread Loop 2 Threads - Check TID (exclusive) =20 # SPDX-License-Identifier: GPL-2.0 # Carsten Haitzler , 2021 diff --git a/tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh b/to= ols/perf/tests/shell/coresight/unroll_loop_thread_10.sh index 4fbb4a29aad3..7429d3a2ae43 100755 --- a/tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh +++ b/tools/perf/tests/shell/coresight/unroll_loop_thread_10.sh @@ -1,5 +1,5 @@ #!/bin/sh -e -# CoreSight / Unroll Loop Thread 10 +# CoreSight / Unroll Loop Thread 10 (exclusive) =20 # SPDX-License-Identifier: GPL-2.0 # Carsten Haitzler , 2021 diff --git a/tools/perf/tests/shell/perftool-testsuite_report.sh b/tools/pe= rf/tests/shell/perftool-testsuite_report.sh index 973012ce92a7..a8cf75b4e77e 100755 --- a/tools/perf/tests/shell/perftool-testsuite_report.sh +++ b/tools/perf/tests/shell/perftool-testsuite_report.sh @@ -1,5 +1,5 @@ #!/bin/bash -# perftool-testsuite_report +# perftool-testsuite_report (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 test -d "$(dirname "$0")/base_report" || exit 2 diff --git a/tools/perf/tests/shell/probe_vfs_getname.sh b/tools/perf/tests= /shell/probe_vfs_getname.sh index 554e12e83c55..0c5aacc446b3 100755 --- a/tools/perf/tests/shell/probe_vfs_getname.sh +++ b/tools/perf/tests/shell/probe_vfs_getname.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Add vfs_getname probe to get syscall args filenames +# Add vfs_getname probe to get syscall args filenames (exclusive) =20 # SPDX-License-Identifier: GPL-2.0 # Arnaldo Carvalho de Melo , 2017 diff --git a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh b/to= ols/perf/tests/shell/record+script_probe_vfs_getname.sh index 9a61928e3c9a..5940fdc1df37 100755 --- a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh +++ b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Use vfs_getname probe to get syscall args filenames +# Use vfs_getname probe to get syscall args filenames (exclusive) =20 # Uses the 'perf test shell' library to add probe:vfs_getname to the system # then use it with 'perf record' using 'touch' to write to a temp file, th= en diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/reco= rd.sh index f0e79200b981..85d512f5a126 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -1,5 +1,5 @@ #!/bin/bash -# perf record tests +# perf record tests (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/= record_lbr.sh index 32314641217e..8d750ee631f8 100755 --- a/tools/perf/tests/shell/record_lbr.sh +++ b/tools/perf/tests/shell/record_lbr.sh @@ -1,5 +1,5 @@ #!/bin/bash -# perf record LBR tests +# perf record LBR tests (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/record_offcpu.sh b/tools/perf/tests/she= ll/record_offcpu.sh index 67c925f3a15a..678947fe69ee 100755 --- a/tools/perf/tests/shell/record_offcpu.sh +++ b/tools/perf/tests/shell/record_offcpu.sh @@ -1,5 +1,5 @@ #!/bin/sh -# perf record offcpu profiling tests +# perf record offcpu profiling tests (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/stat_all_pmu.sh b/tools/perf/tests/shel= l/stat_all_pmu.sh index 42456d89c5da..8b148b300be1 100755 --- a/tools/perf/tests/shell/stat_all_pmu.sh +++ b/tools/perf/tests/shell/stat_all_pmu.sh @@ -1,5 +1,5 @@ #!/bin/bash -# perf all PMU test +# perf all PMU test (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/stat_bpf_counters.sh b/tools/perf/tests= /shell/stat_bpf_counters.sh index f250b7d6f773..a038c1b1a706 100755 --- a/tools/perf/tests/shell/stat_bpf_counters.sh +++ b/tools/perf/tests/shell/stat_bpf_counters.sh @@ -1,5 +1,5 @@ #!/bin/sh -# perf stat --bpf-counters test +# perf stat --bpf-counters test (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/test= s/shell/test_arm_coresight.sh index 6b8c4831eedc..573af9235b72 100755 --- a/tools/perf/tests/shell/test_arm_coresight.sh +++ b/tools/perf/tests/shell/test_arm_coresight.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Check Arm CoreSight trace data recording and synthesized samples +# Check Arm CoreSight trace data recording and synthesized samples (exclus= ive) =20 # Uses the 'perf record' to record trace data with Arm CoreSight sinks; # then verify if there have any branch samples and instruction samples diff --git a/tools/perf/tests/shell/test_arm_coresight_disasm.sh b/tools/pe= rf/tests/shell/test_arm_coresight_disasm.sh index dba086a40d84..be2d26303f94 100755 --- a/tools/perf/tests/shell/test_arm_coresight_disasm.sh +++ b/tools/perf/tests/shell/test_arm_coresight_disasm.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Check Arm CoreSight disassembly script completes without errors +# Check Arm CoreSight disassembly script completes without errors (exclusi= ve) # SPDX-License-Identifier: GPL-2.0 =20 # The disassembly script reconstructs ranges of instructions and gives the= se to objdump to diff --git a/tools/perf/tests/shell/test_arm_spe.sh b/tools/perf/tests/shel= l/test_arm_spe.sh index 6c21fb1f10d8..3258368634f7 100755 --- a/tools/perf/tests/shell/test_arm_spe.sh +++ b/tools/perf/tests/shell/test_arm_spe.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Check Arm SPE trace data recording and synthesized samples +# Check Arm SPE trace data recording and synthesized samples (exclusive) =20 # Uses the 'perf record' to record trace data of Arm SPE events; # then verify if any SPE event samples are generated by SPE with diff --git a/tools/perf/tests/shell/test_data_symbol.sh b/tools/perf/tests/= shell/test_data_symbol.sh index 3dfa91832aa8..c86da0235059 100755 --- a/tools/perf/tests/shell/test_data_symbol.sh +++ b/tools/perf/tests/shell/test_data_symbol.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Test data symbol +# Test data symbol (exclusive) =20 # SPDX-License-Identifier: GPL-2.0 # Leo Yan , 2022 diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/she= ll/test_intel_pt.sh index bf9017b812aa..e6f0070975f6 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Miscellaneous Intel PT testing +# Miscellaneous Intel PT testing (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/t= ests/shell/test_stat_intel_tpebs.sh index 9a11f42d153c..f95fc64bf0a7 100755 --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh @@ -1,5 +1,5 @@ #!/bin/bash -# test Intel TPEBS counting mode +# test Intel TPEBS counting mode (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf= /tests/shell/trace+probe_vfs_getname.sh index 97b4b9cd2378..708a13f00635 100755 --- a/tools/perf/tests/shell/trace+probe_vfs_getname.sh +++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Check open filename arg using perf trace + vfs_getname +# Check open filename arg using perf trace + vfs_getname (exclusive) =20 # Uses the 'perf test shell' library to add probe:vfs_getname to the system # then use it with 'perf trace' using 'touch' to write to a temp file, then --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 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 6399A1B0F2B for ; Thu, 24 Oct 2024 07:33:42 +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=1729755224; cv=none; b=WJABeC2AIyIhBK03tHSovhNT4EmOdpuqxaQIeMRopoQZmXYgHPRQ9yO0Otre+mvlHwcVxc7bHlyvnJV+SppYuGKm0yBU/+z4cao5sqLuxu6Skp7NmxIRVZ9CuJ9J5zM/oA3pMlf31LGwT+6LjSpoL7vVhcm53CutTNXHA9hGiJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755224; c=relaxed/simple; bh=6/uo9WKPPestWRkUgwt62AoatZhqYZAbu5e4hou0/hQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=uF20L4kROXdmqc6TxHMD+J8GNCiNbwIphha1B9y9gwCGojJUA1w+xYcj2VC9d1W6mWYatnUMVCrYarX+0ESKZ2Yib9tyMfOBRpxclkSc2Fm0IdAHNs9nCoCQ2WFqSojnh5UxSWlJM7A0PrtPeyp5EmVlejcYMMphZRT8PDdSzA4= 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=eck84fS4; 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="eck84fS4" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e28fc60660dso1159216276.0 for ; Thu, 24 Oct 2024 00:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755221; x=1730360021; 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=2kvdOK9w8weA25EuFrzrtnTE25b0PHQYq3wUq/HkXk0=; b=eck84fS4vVSlGAP0esBAjZMgo93AAlneIJ8NwzKv4t2YeTSM7h8dw2tKO/Nu1lH90J MXhQd6i54EGUsR3tJVXrrQe1jKKKu3cyEJW7tdOIcFDljSjgtl/GxlvFlj55ICn+lTmZ 6cdX5QDUoeU/tX8B705osNc3sr9cvuLALUonIixegeMCb7pFqt6jR15xYkOErPNfkzov ln33ates0tPdnodsa8iMN8ha8mg82ZcCQ5gLTH8HjoPnrIcKSe0TJxNnnyNE9yORnPL0 wUKy6GDix9tkKwkUKwXizF8oD8xjFNwhl4q3RKvrTti64fg2CfgqYfbbbDwvomj2e/IF 93uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755221; x=1730360021; 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=2kvdOK9w8weA25EuFrzrtnTE25b0PHQYq3wUq/HkXk0=; b=m7rjHBn0p5gArf8/U93QK5k30vFrWnsJk11MOU7xLrk5SvAiCSBszgXRVkQw5kV1zo Qst6lDOw0IIX9mx7neXFm79sjGQawQ9nawBJq/3Wwk96erCUf/Q8Hc7LOcYf2N+c4DpF 2bco+JhXGzytKs5wydpprFJrLoIxE4Dh5FN7A9ye2KwNK/18tI6G7gJmwFiqwc9sdsA+ rt+oyAXTqNDTYlM16NOZcVCXZso1ajC94JjCbONUFD01Ty5CZtZXjMCqiKgVTel7h7Et o9+QexUoDua4DYBscVAgGcfBLeg8CR9tswmo6Y9cdTBL9hUSFc8kYySmssZXqUiA8sOQ bVbA== X-Forwarded-Encrypted: i=1; AJvYcCXT09XtDvw5sEdC9/YUjoOxJYo05CzCUumAMImmHyaVH9V4/i+p+/5u6soIYvJtQFQMvQX6meUDkYhOSAc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4WCwoWnMGnlSjwMQTygyKzt1B0zKnGVlZLCIwEtQVcyLF+BuX l0pOdduPhjyUF4PrNRkZ5XcpOoj7iXRybNyIoh2RvuEjxj3S50VgwlHMtg4jlaknf8SW9t+dS9s WJr7IFA== X-Google-Smtp-Source: AGHT+IHvVhoLjSV/7Ehy0wg8Ell26mA87x4lSc80f2KbQivA+THZc1RcttmFOtpSuGHAWG7IOxNGowTUFmWT X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a25:26cc:0:b0:e29:7587:66db with SMTP id 3f1490d57ef6-e2f22f26112mr4178276.2.1729755221368; Thu, 24 Oct 2024 00:33:41 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:20 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-7-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 06/10] perf test: Add a signal handler around running a test 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a signal handler around running a test. If a signal occurs during the test a siglongjmp unwinds the stack and output is flushed. The global run_test_jmp_buf is either unique per forked child or not shared during sequential execution. Tested-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 0e8f877f4b1f..8a720ddb0396 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -229,16 +230,41 @@ struct child_test { int subtest; }; =20 +static jmp_buf run_test_jmp_buf; + +static void child_test_sig_handler(int sig) +{ + siglongjmp(run_test_jmp_buf, sig); +} + static int run_test_child(struct child_process *process) { - struct child_test *child =3D container_of(process, struct child_test, pro= cess); + const int signals[] =3D { + SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGINT, SIGPIPE, SIGQUIT, SIGSEGV, SIGT= ERM, + }; + static struct child_test *child; int err; =20 + err =3D sigsetjmp(run_test_jmp_buf, 1); + if (err) { + fprintf(stderr, "\n---- unexpected signal (%d) ----\n", err); + err =3D err > 0 ? -err : -1; + goto err_out; + } + + child =3D container_of(process, struct child_test, process); + for (size_t i =3D 0; i < ARRAY_SIZE(signals); i++) + signal(signals[i], child_test_sig_handler); + pr_debug("--- start ---\n"); pr_debug("test child forked, pid %d\n", getpid()); err =3D test_function(child->test, child->subtest)(child->test, child->su= btest); pr_debug("---- end(%d) ----\n", err); + +err_out: fflush(NULL); + for (size_t i =3D 0; i < ARRAY_SIZE(signals); i++) + signal(signals[i], SIG_DFL); return -err; } =20 --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 6C54D1B2183 for ; Thu, 24 Oct 2024 07:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755228; cv=none; b=Qj18idJA+vobeHnqJHfjqYfbuNTPulkvYuIy28It0hxqQRD6hrM8J6M2ZrKUng4itHm6CAjfFyaSuOz0rXyJ1XljWFXjDItzFLdWMWp3EkCT12hHPfiI4WkSfRcpa2CKKl1UnOUwzy8X2fRCl1fJgoyZSHjy4lFbWFCHt62auTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755228; c=relaxed/simple; bh=h+S7lvjznO6aeDproo7dQHdVN5YR74SQ/ZENnLj7+oI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=BjuPeA7lz68yZg4lbjTHJg+/wG7Cp86mh9TU5xu/y9zVY9JFJ1h4IDcSWi44ejgZ/AFrMqOrFNoIoA5YHISjs2NYcNYLlEvmXgpEPX2qQ78bOEgekSq+1DmIhOh//kglBHHtTKpjzh1K15FSN7hnaNzrgXN+E3wQqkqGbVG72Zw= 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=MEcxbvpt; arc=none smtp.client-ip=209.85.128.201 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="MEcxbvpt" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e3705b2883so12319377b3.3 for ; Thu, 24 Oct 2024 00:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755223; x=1730360023; 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=x7hM2wwF2vu4Jxi4L+kQlwZyT/L+0QugQwYnGtLXglM=; b=MEcxbvptkA8T3+xeJh9pRL/vh7F6kc2tr5fZXGR92wBsNXUpXOfpXWiCu8igtQpDVI 7wpJpvnX0FqGHOuGtKmvYH1tpjEjJPu4gyMGkJ7Z8relp7OP6XjbJB4lEuDnn7KzqpYU 5HIg8H38tzpv/WY9+HMui3xSHRODFejghu1I7Or7DCsFUZVeBQXdjT6Qdk05Z3swMom/ Bx26zpc4/dhq5Igk6sy6mgjCi8kvR838EZLCtz5JnXIxRL0zPIMNrr8k9ZsgCL7flKD6 4YLEQoYQ9Z2AlBJSEIH2kqxbVTDZ+eZufRDqVNBgbfyXf800uj/bESFYE72H1PDZ1EkM AQCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755223; x=1730360023; 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=x7hM2wwF2vu4Jxi4L+kQlwZyT/L+0QugQwYnGtLXglM=; b=wv+U36jm/iJupy8L5ttNBmrfehBfV3mwcGcEcc/NG/3jJOuN+/w31LeB10jJPaEkzy 1PNE5DOVV3a1p+3Xh/3mozTDwCOn5dWtiUdLqL4gm6ZMql1GMOcHXVRwy7onn41hezMP pYJfn3XlTInuXibUUlUJS9UY3flx3YpICwsxvZXfbCUMEprsSjurXiKKkrMCjl/41/ig w57FkcjPvgLwIXaE9oBX01wA4kGdpo6OP/1VCxoF3ONRBnqqSsbnvhrsRQF2ffFW39Cq rt+C0uNaqlrAHj3nAH+Hq80skDkgZk7DV/HJXn4l6hnJmTewFW0lhLimRvaqosdDTCUF kLag== X-Forwarded-Encrypted: i=1; AJvYcCXAPdihaVeqwHJlBB2kUzFchkk3jAlcOIjDWQqYnNtwvZfWJI0CCKBM/bpKeibPIVHmqlPVROC4LTAJCdU=@vger.kernel.org X-Gm-Message-State: AOJu0YyBslyxkG4fXJpNiLpaN2jdIHAkTIPOci6mtFJvqdGmNCnLajLt HuUXY7VcSMN6wq6RSzOcOCHYQbNxR345WxzHGaglOE2tGTDDNyLhXVl4GTAkKwgiwSBMbAYZNny kM+KuCA== X-Google-Smtp-Source: AGHT+IFR1hSJGp+PtSCO+wqdiDMALECfN1b8oV82snaVHd952V/BD1M+iklsAG3xBjIi+4d6azzSc8MqlfDn X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a05:690c:3605:b0:6e2:1ab6:699a with SMTP id 00721157ae682-6e8701db190mr376087b3.7.1729755223437; Thu, 24 Oct 2024 00:33:43 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:21 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 07/10] perf test: Run parallel tests in two passes 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In pass 1 run all tests that succeed when run in parallel. In pass 2 sequentially run all remaining tests that are flagged as "exclusive". Sequential and dont_fork tests keep to run in pass 1. Read the exclusive flag from the shell test descriptions, but remove from display to avoid >100 characters. Add error handling to finish tests if starting a later test fails. Mark the task-exit test as exclusive due to issues reported-by James Clark. Tested-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 157 +++++++++++++++++++------------ tools/perf/tests/task-exit.c | 9 +- tools/perf/tests/tests-scripts.c | 7 +- tools/perf/tests/tests.h | 9 ++ 4 files changed, 121 insertions(+), 61 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 8a720ddb0396..b997d0a68ca2 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -199,6 +199,14 @@ static test_fnptr test_function(const struct test_suit= e *t, int subtest) return t->test_cases[subtest].run_case; } =20 +static bool test_exclusive(const struct test_suite *t, int subtest) +{ + if (subtest <=3D 0) + return t->test_cases[0].exclusive; + + return t->test_cases[subtest].exclusive; +} + static bool perf_test__matches(const char *desc, int curr, int argc, const= char *argv[]) { int i; @@ -242,7 +250,7 @@ static int run_test_child(struct child_process *process) const int signals[] =3D { SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGINT, SIGPIPE, SIGQUIT, SIGSEGV, SIGT= ERM, }; - static struct child_test *child; + struct child_test *child =3D container_of(process, struct child_test, pro= cess); int err; =20 err =3D sigsetjmp(run_test_jmp_buf, 1); @@ -252,7 +260,6 @@ static int run_test_child(struct child_process *process) goto err_out; } =20 - child =3D container_of(process, struct child_test, process); for (size_t i =3D 0; i < ARRAY_SIZE(signals); i++) signal(signals[i], child_test_sig_handler); =20 @@ -305,19 +312,25 @@ static int print_test_result(struct test_suite *t, in= t i, int subtest, int resul return 0; } =20 -static int finish_test(struct child_test **child_tests, int running_test, = int child_test_num, - int width) +static void finish_test(struct child_test **child_tests, int running_test,= int child_test_num, + int width) { struct child_test *child_test =3D child_tests[running_test]; - struct test_suite *t =3D child_test->test; - int i =3D child_test->test_num; - int subi =3D child_test->subtest; - int err =3D child_test->process.err; + struct test_suite *t; + int i, subi, err; bool err_done =3D false; struct strbuf err_output =3D STRBUF_INIT; int last_running =3D -1; int ret; =20 + if (child_test =3D=3D NULL) { + /* Test wasn't started. */ + return; + } + t =3D child_test->test; + i =3D child_test->test_num; + subi =3D child_test->subtest; + err =3D child_test->process.err; /* * For test suites with subtests, display the suite name ahead of the * sub test names. @@ -347,6 +360,8 @@ static int finish_test(struct child_test **child_tests,= int running_test, int ch int running =3D 0; =20 for (int y =3D running_test; y < child_test_num; y++) { + if (child_tests[y] =3D=3D NULL) + continue; if (check_if_command_finished(&child_tests[y]->process) =3D=3D 0) running++; } @@ -399,23 +414,32 @@ static int finish_test(struct child_test **child_test= s, int running_test, int ch print_test_result(t, i, subi, ret, width, /*running=3D*/0); if (err > 0) close(err); - return 0; + zfree(&child_tests[running_test]); } =20 static int start_test(struct test_suite *test, int i, int subi, struct chi= ld_test **child, - int width) + int width, int pass) { int err; =20 *child =3D NULL; if (dont_fork) { - pr_debug("--- start ---\n"); - err =3D test_function(test, subi)(test, subi); - pr_debug("---- end ----\n"); - print_test_result(test, i, subi, err, width, /*running=3D*/0); + if (pass =3D=3D 1) { + pr_debug("--- start ---\n"); + err =3D test_function(test, subi)(test, subi); + pr_debug("---- end ----\n"); + print_test_result(test, i, subi, err, width, /*running=3D*/0); + } + return 0; + } + if (pass =3D=3D 1 && !sequential && test_exclusive(test, subi)) { + /* When parallel, skip exclusive tests on the first pass. */ + return 0; + } + if (pass !=3D 1 && (sequential || !test_exclusive(test, subi))) { + /* Sequential and non-exclusive tests were run on the first pass. */ return 0; } - *child =3D zalloc(sizeof(**child)); if (!*child) return -ENOMEM; @@ -434,10 +458,14 @@ static int start_test(struct test_suite *test, int i,= int subi, struct child_tes (*child)->process.err =3D -1; } (*child)->process.no_exec_cmd =3D run_test_child; - err =3D start_command(&(*child)->process); - if (err || !sequential) - return err; - return finish_test(child, /*running_test=3D*/0, /*child_test_num=3D*/1, w= idth); + if (sequential || pass =3D=3D 2) { + err =3D start_command(&(*child)->process); + if (err) + return err; + finish_test(child, /*running_test=3D*/0, /*child_test_num=3D*/1, width); + return 0; + } + return start_command(&(*child)->process); } =20 #define for_each_test(j, k, t) \ @@ -447,12 +475,11 @@ static int start_test(struct test_suite *test, int i,= int subi, struct child_tes static int __cmd_test(int argc, const char *argv[], struct intlist *skipli= st) { struct test_suite *t; - unsigned int j, k; - int i =3D 0; int width =3D 0; + unsigned int j, k; size_t num_tests =3D 0; struct child_test **child_tests; - int child_test_num =3D 0; + int err =3D 0; =20 for_each_test(j, k, t) { int len =3D strlen(test_description(t, -1)); @@ -475,62 +502,73 @@ static int __cmd_test(int argc, const char *argv[], s= truct intlist *skiplist) if (!child_tests) return -ENOMEM; =20 - for_each_test(j, k, t) { - int curr =3D i++; - - if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) { - bool skip =3D true; + /* + * In parallel mode pass 1 runs non-exclusive tests in parallel, pass 2 + * runs the exclusive tests sequentially. In other modes all tests are + * run in pass 1. + */ + for (int pass =3D 1; pass <=3D 2; pass++) { + int child_test_num =3D 0; + int i =3D 0; + + for_each_test(j, k, t) { + int curr =3D i++; + + if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) { + /* + * Test suite shouldn't be run based on + * description. See if subtest should. + */ + bool skip =3D true; + + for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { + if (perf_test__matches(test_description(t, subi), + curr, argc, argv)) + skip =3D false; + } =20 - for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { - if (perf_test__matches(test_description(t, subi), - curr, argc, argv)) - skip =3D false; + if (skip) + continue; } =20 - if (skip) + if (intlist__find(skiplist, i)) { + pr_info("%3d: %-*s:", curr + 1, width, test_description(t, -1)); + color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); continue; - } - - if (intlist__find(skiplist, i)) { - pr_info("%3d: %-*s:", curr + 1, width, test_description(t, -1)); - color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); - continue; - } - - if (!has_subtests(t)) { - int err =3D start_test(t, curr, -1, &child_tests[child_test_num++], wid= th); + } =20 - if (err) { - /* TODO: if !sequential waitpid the already forked children. */ - free(child_tests); - return err; + if (!has_subtests(t)) { + err =3D start_test(t, curr, -1, &child_tests[child_test_num++], + width, pass); + if (err) + goto err_out; + continue; } - } else { for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { - int err; - if (!perf_test__matches(test_description(t, subi), curr, argc, argv)) continue; =20 err =3D start_test(t, curr, subi, &child_tests[child_test_num++], - width); + width, pass); if (err) - return err; + goto err_out; } } - } - for (i =3D 0; i < child_test_num; i++) { if (!sequential) { - int ret =3D finish_test(child_tests, i, child_test_num, width); - - if (ret) - return ret; + /* Parallel mode starts tests but doesn't finish them. Do that now. */ + for (size_t x =3D 0; x < num_tests; x++) + finish_test(child_tests, x, num_tests, width); } - free(child_tests[i]); + } +err_out: + if (err) { + pr_err("Internal test harness failure. Completing any started tests:\n:"= ); + for (size_t x =3D 0; x < num_tests; x++) + finish_test(child_tests, x, num_tests, width); } free(child_tests); - return 0; + return err; } =20 static int perf_test__list(int argc, const char **argv) @@ -656,6 +694,7 @@ int cmd_test(int argc, const char **argv) symbol_conf.priv_size =3D sizeof(int); symbol_conf.try_vmlinux_path =3D true; =20 + if (symbol__init(NULL) < 0) return -1; =20 diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index d33d0952025c..8e328bbd509d 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c @@ -152,4 +152,11 @@ static int test__task_exit(struct test_suite *test __m= aybe_unused, int subtest _ return err; } =20 -DEFINE_SUITE("Number of exit events of a simple workload", task_exit); +struct test_case tests__task_exit[] =3D { + TEST_CASE_EXCLUSIVE("Number of exit events of a simple workload", task_ex= it), + { .name =3D NULL, } +}; +struct test_suite suite__task_exit =3D { + .desc =3D "Number of exit events of a simple workload", + .test_cases =3D tests__task_exit, +}; diff --git a/tools/perf/tests/tests-scripts.c b/tools/perf/tests/tests-scri= pts.c index ed114b044293..cf3ae0c1d871 100644 --- a/tools/perf/tests/tests-scripts.c +++ b/tools/perf/tests/tests-scripts.c @@ -175,6 +175,7 @@ static void append_script(int dir_fd, const char *name,= char *desc, struct test_suite *test_suite, **result_tmp; struct test_case *tests; size_t len; + char *exclusive; =20 snprintf(link, sizeof(link), "/proc/%d/fd/%d", getpid(), dir_fd); len =3D readlink(link, filename, sizeof(filename)); @@ -191,9 +192,13 @@ static void append_script(int dir_fd, const char *name= , char *desc, return; } tests[0].name =3D strdup_check(name); + exclusive =3D strstr(desc, " (exclusive)"); + if (exclusive !=3D NULL) { + tests[0].exclusive =3D true; + exclusive[0] =3D '\0'; + } tests[0].desc =3D strdup_check(desc); tests[0].run_case =3D shell_test__run; - test_suite =3D zalloc(sizeof(*test_suite)); if (!test_suite) { pr_err("Out of memory while building script test suite list\n"); diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 1ed76d4156b6..af284dd47e5c 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -36,6 +36,7 @@ struct test_case { const char *desc; const char *skip_reason; test_fnptr run_case; + bool exclusive; }; =20 struct test_suite { @@ -62,6 +63,14 @@ struct test_suite { .skip_reason =3D _reason, \ } =20 +#define TEST_CASE_EXCLUSIVE(description, _name) \ + { \ + .name =3D #_name, \ + .desc =3D description, \ + .run_case =3D test__##_name, \ + .exclusive =3D true, \ + } + #define DEFINE_SUITE(description, _name) \ struct test_case tests__##_name[] =3D { \ TEST_CASE(description, _name), \ --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 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 DACD71B21A6 for ; Thu, 24 Oct 2024 07:33:46 +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=1729755229; cv=none; b=nzIqbOrlLbo7VgI14wAJi3nYtzaGIXprUz1mqenvOdCUZmMBgFOHuRnGDcnVEB/FX8THsWbDArJY5iS6WR0CsWhqB/3Vk35/N4CAceWjS/4oreFuhxix52QzMRx5n+HVcUa8ow8uyp8dlPdR2rur8+AIZZmcJA7Uh17ApO2yT1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755229; c=relaxed/simple; bh=M0R3zHDAes8blHNNb56eB/dYrJt3dM5C0cEG6y4au10=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=FVX+iybsg8gl8fwRLZVqnN+4P9Xa82kadLvceUgIhrhaKj79VttKrrPMMJmDyFBQUZxBlCvvyCwWwKjKpoXkPzHyAG8CG5Jt3bKucZ77LB16SDGvxAneYTmDtjBAOrd2RVTojYIKg64tjvBG9DW2ugz5BzFiZ2vbavnRkCG6uxo= 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=u1QXGdYh; 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="u1QXGdYh" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e2939e25402so1191801276.2 for ; Thu, 24 Oct 2024 00:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755226; x=1730360026; 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=2We4CvxKfLkecfrv/oDL8pHcCSPB/kc+5ogezpwpnuw=; b=u1QXGdYh51wCk4m5cIy2szxKpMSn8cOQm196pTl+DdOTqYiDTpnCJRt1wOutVyBo2F 0jwqY5DEb2JOc4G2Paq8AfW3DiLbtrL9mNuaJ0NFQJxROMJF2aen8H0v285OrSGqnb0F AtV7QE4Uc16/c/021T2wLck1lMg4BTGowg7d2jSTqZrIaVqFJ9TxOPrh+vbPmr7CuSxP twwi4XjVT3F55224P4jjt3CJgrpkXL+9Kw68738+eqXEUWxISPg+zntp2GleDjXErFKh 9AKWmGhS2FZo2dOuZqWH+Zufy9irpKWI6xBPExr54MmqOBB+Z7JNGlSviJ3HBRePkffE 9XMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755226; x=1730360026; 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=2We4CvxKfLkecfrv/oDL8pHcCSPB/kc+5ogezpwpnuw=; b=E86miIfmXjwNXb/tEubBNoDTqfLdSg3cSWE1dkQwIvFY9bnjsNWJM3YqpQArXccf4p U/Cv5JzFt3IvpyDZa1QTuM39u3kLyyDUKJeA31axK6qx4H0SsXGeJbiCiKRFUQKyRULJ gJE0F28+8bp15g611bfkd7cArpPormFVuH8DpN1eQmncYUXqspZwDz45Sf5jI66hkPK3 jbtL+JAzCAFnrLvADC9m4F/ZWbpx6F7dfQFRtot4+fY/BTKAaenMGi9Pu+Y4OCbyUeYS LSZo/gIKy7hsr33cXRibtrkmpBhFIW29HvkA5UpTysjFpVc0GOZ0RihQ5sPhWryy5P6d qt0A== X-Forwarded-Encrypted: i=1; AJvYcCVRXtWhz4VtMw0wLhO6WLxs7+02/jyYv/iQAdSmJVLG1/WSfGx4TyVm1qbLB+Z2/on9WoGtimB3V0tqVOU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy+/WEy5P+S4euZxqlE5phnGvs1zGegAuMhqv3VvGmtWmfYBZQj El4ZAUiWisbAsxdrWG9DiSzA9d3S5wgzsVXlF9JU/O8Q3YSz6wN861x8sFVKGy4qjw0mXOrcGbM YSlFb8A== X-Google-Smtp-Source: AGHT+IEQF3XmUMfnQFWXLgOqMIZJcZqb0suCDYaD0YRwhNPawy5pg39Y3574SaLRcZwU19FWRca8TDWM5lw2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a25:bbcd:0:b0:e29:76b7:ed37 with SMTP id 3f1490d57ef6-e2f2fc0f2c6mr17376276.9.1729755225660; Thu, 24 Oct 2024 00:33:45 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:22 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-9-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 08/10] perf test: Make parallel testing the default 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now C tests can have the "exclusive" flag to run without other tests, and shell tests can add "(exclusive)" to their description, run tests in parallel by default. Tests which flake when run in parallel can be marked exclusive to resolve the problem. Non-scientifically, the reduction on `perf test` execution time is from 8m35.890s to 3m55.115s on a Tigerlake laptop. So the tests complete in less than half the time. Tested-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index b997d0a68ca2..a0a678facc45 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -40,8 +40,8 @@ * making them easier to debug. */ static bool dont_fork; -/* Don't fork the tests in parallel and wait for their completion. */ -static bool sequential =3D true; +/* Fork the tests in parallel and wait for their completion. */ +static bool sequential; const char *dso_to_test; const char *test_objdump_path =3D "objdump"; =20 @@ -639,19 +639,12 @@ int cmd_test(int argc, const char **argv) const char *skip =3D NULL; const char *workload =3D NULL; bool list_workloads =3D false; - /* - * Run tests in parallel, lacks infrastructure to avoid running tests - * that clash for resources, So leave it as the developers choice to - * enable while working on the needed infra. - */ - bool parallel =3D false; const struct option test_options[] =3D { OPT_STRING('s', "skip", &skip, "tests", "tests to skip"), OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('F', "dont-fork", &dont_fork, "Do not fork for testcase"), - OPT_BOOLEAN('p', "parallel", ¶llel, "Run the tests in parallel"), OPT_BOOLEAN('S', "sequential", &sequential, "Run the tests one after another rather than in parallel"), OPT_STRING('w', "workload", &workload, "work", "workload to run for testi= ng, use '--list-workloads' to list the available ones."), @@ -688,8 +681,6 @@ int cmd_test(int argc, const char **argv) =20 if (dont_fork) sequential =3D true; - else if (parallel) - sequential =3D false; =20 symbol_conf.priv_size =3D sizeof(int); symbol_conf.try_vmlinux_path =3D true; --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 8F7A31ABEB8 for ; Thu, 24 Oct 2024 07:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755231; cv=none; b=UzuWOFJjApdojB5b0e5CyRNz50bBsX5+owox4vafhWX+guB9aHvWW5U8gB+zxK/bGZTJxKplLkr1ApCeDnuELBiEC5ISMnC089nrZiC2W+Etf+DVnZWs2dD8HMl9jOtphDRrgXuVuFCa26o/V7xQUGhVk9qeBguVY/amzEvqk4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755231; c=relaxed/simple; bh=0dbC+RaKdnXsIuzKstqRrgk9vgSNwCpbsbK3CmdWFOM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=PxRT6Is8o24SmPB/elTbUdUtxBMgbEIO8wLA1zSxLpJnMyWiXC546kE0XR5MyCF3GYaYAKY7UbP9MSdyHn6yhTNC7+X2rn3WXVxmdq8Ua6dLRYyQrOMiuXK4sB84nDwLObDR1fgAekdepXJ/VDfsonS0VvW63nlw4A1OVs4Sogw= 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=0aMabW+d; arc=none smtp.client-ip=209.85.128.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="0aMabW+d" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e315a5b199so11801937b3.2 for ; Thu, 24 Oct 2024 00:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755228; x=1730360028; 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=hzA55k1i5KBhNuyGUjIcGDdjfOELqkQQIEY92Z4/408=; b=0aMabW+dX5dcxpc8+a7KMV8gLy4337U5cZTEZvPfWq7ZFdKFZql7Lm8AyyQLhW1xVI KPH8voqWlB1b61Od7v7Mu9+SKYVB2X/oy5t0chYE1ZpgGNUXMUBwdxwrSDdH/IOUVsjM azXG+EbGm0zXiOg2f/3JlgOzhuUXLqmEtsAPe0O5jWKRFNfQ/duDViNyzMayuztVKdLS e0YAPr8RsU5d5xsXLqu1iIojB3FomZmrbEpIDtMR1loddBpVSVsTHSyxrep8DasbBJwh EWYEP6R1EimoQLRWIqBuhv1zSgVbrzsTPojKKInMaDk20tVYHEAaptbpLZaHa0nGUzrS qu2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755228; x=1730360028; 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=hzA55k1i5KBhNuyGUjIcGDdjfOELqkQQIEY92Z4/408=; b=VCryVcVVsO1dGTZG/nIcY8ZpZ7ehCaaw++lyixtX7tOUioYTrRlNqOq4GJ9eJbaHhl QpdI8kFnc1MHpSbJJsBYnOfqM0m1ZO5UOF7xcZEsCVMa9R3xaEXo8FpjgPZnG3lMn91H h/7FQam4pZ62Q2Ydk1hcYp97AhEfj2mLcjEq89H5OEZgZgM+0JBPpAfIKAlO2ANK30YU lbWX6IWGcA+8Vf4VbXZtW0Kbf5gVSRqjtX0NgsDxR7vIePomlQE5KbSzgtMLgtVqcfiZ zSOYxqpvwY+oanKuW1fvVUawAQgA2Y2g3+pTGyYFG3VDWaDRsYBkW5yN1c03OIL9qDtQ s7/g== X-Forwarded-Encrypted: i=1; AJvYcCUqedMJCVLPVTA44foejT6l605tn2h12YOITl4exQ1qsM+nFm64RydzMzWlmAABigVwgNLgNddXySHmfNE=@vger.kernel.org X-Gm-Message-State: AOJu0YyVwTPEQPQyXSEvqJoIz5VxV2e+Zqv3wx6nvyDqoNR9S84xvVcu 8IB/cyXsadqnJpBjGf6H4k9TD42KMbPMzT3GnAOljK/JSp+29fCUCfhvyTkk2QGxMevsESGvGbO n9QklFQ== X-Google-Smtp-Source: AGHT+IEqIg41JDb2+znglXqj+7LVxCtedSDwoe22Mk9wZTuT+OYqe9v7oCYf/mqBdD5tDXGnCHdiMVg8b18W X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a05:690c:23c6:b0:6e3:f12:1ad3 with SMTP id 00721157ae682-6e86635e441mr502117b3.6.1729755228029; Thu, 24 Oct 2024 00:33:48 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:23 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-10-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 09/10] perf test: Add a signal handler to kill forked child processes 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the `perf test` process is killed the child tests continue running and may run indefinitely. Propagate SIGINT (ctrl-C) and SIGTERM (kill) signals to the running child processes so that they terminate when the parent is killed. Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 34 +++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index a0a678facc45..f5c5b82d3b61 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -472,13 +472,22 @@ static int start_test(struct test_suite *test, int i,= int subi, struct child_tes for (j =3D 0, k =3D 0; j < ARRAY_SIZE(tests); j++, k =3D 0) \ while ((t =3D tests[j][k++]) !=3D NULL) =20 +/* State outside of __cmd_test for the sake of the signal handler. */ + +static size_t num_tests; +static struct child_test **child_tests; +static jmp_buf cmd_test_jmp_buf; + +static void cmd_test_sig_handler(int sig) +{ + siglongjmp(cmd_test_jmp_buf, sig); +} + static int __cmd_test(int argc, const char *argv[], struct intlist *skipli= st) { struct test_suite *t; int width =3D 0; unsigned int j, k; - size_t num_tests =3D 0; - struct child_test **child_tests; int err =3D 0; =20 for_each_test(j, k, t) { @@ -502,6 +511,25 @@ static int __cmd_test(int argc, const char *argv[], st= ruct intlist *skiplist) if (!child_tests) return -ENOMEM; =20 + err =3D sigsetjmp(cmd_test_jmp_buf, 1); + if (err) { + pr_err("Signal while running tests. Terminating tests with signal %d\n",= err); + for (size_t x =3D 0; x < num_tests; x++) { + struct child_test *child_test =3D child_tests[x]; + + if (!child_test) + continue; + + pr_debug3("Killing %3d pid %d\n", + child_test->test_num + 1, + child_test->process.pid); + kill(child_test->process.pid, SIGTERM); + } + goto err_out; + } + signal(SIGINT, cmd_test_sig_handler); + signal(SIGTERM, cmd_test_sig_handler); + /* * In parallel mode pass 1 runs non-exclusive tests in parallel, pass 2 * runs the exclusive tests sequentially. In other modes all tests are @@ -562,6 +590,8 @@ static int __cmd_test(int argc, const char *argv[], str= uct intlist *skiplist) } } err_out: + signal(SIGINT, SIG_DFL); + signal(SIGTERM, SIG_DFL); if (err) { pr_err("Internal test harness failure. Completing any started tests:\n:"= ); for (size_t x =3D 0; x < num_tests; x++) --=20 2.47.0.163.g1226f6d8fa-goog From nobody Mon Nov 25 22:01:50 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 2DC4E1AC420 for ; Thu, 24 Oct 2024 07:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755235; cv=none; b=dmW/al5e6qtiFAQ8bBzBxNCjWzIIghBdA3y2pHMNpUmIbNaxVASaEPT1IxGH+dXrGGa5UmF6PWdbxTEGFrLW1GDp9cDQSxxOxduYkTDbuZ4kA3W1sk64ycCAxzeg0lzwZKWl5wucYPw2tN+ImmrHSyoPU1vc0bnTqjBlH4FKMSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729755235; c=relaxed/simple; bh=Oi8yNVa2wiiY6Ywh5UlHXbQB0L+hHag0iAWHPMmicIA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=krVlY6j5OXeOKptIxyAnKknS6El8zsOtRnevqIgmD3VSyuZZZMHz/YkZ0nOP3iIn0o4HJe4FaNyljPy//7a1HJjuUoppQZhJDn8rEp5qj+GioSQWJY63mtPVQVovJun2/58yeLzu2CYSU6PWOSPG6TYYCB70wVoig3SPSom5kPQ= 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=D2n1e++9; arc=none smtp.client-ip=209.85.128.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="D2n1e++9" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6d9e31e66eeso13060077b3.1 for ; Thu, 24 Oct 2024 00:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729755231; x=1730360031; 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=yxy4GtW9n2s/XLPksaSuChJLGWTx8//e0wBhnjnFtvo=; b=D2n1e++9ejyRGxo2hNENnKpI/Cu3CAlc4I3/Sj9ny4OJCdzTrJWX7A+0diwTqznthy vjbd8zIBanxLldvLHKH1qM+Xz7gvJHy3ZYHQYaBQz+rzGHYHJnC2TlpBGlrSJL+eCh8g sAQKoP719q7JcP/KAPIu7XgLvhY4H9edXRp0incG4WBTrBZc8IvYv6Ew7Yq8Hk7TvNP1 9cg8qWec4By18zG3hE8KLYEYAIluWAAgjrYYELO61xKLYTzZjgl4dgotHRMMmML7XyrS 3gRuzVlBckIQwdi6U+T3G6rNLlvwJjTFvHahxy1M+8AxR+s0UxPh8g8k4pCGoe1RipxN tmbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729755231; x=1730360031; 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=yxy4GtW9n2s/XLPksaSuChJLGWTx8//e0wBhnjnFtvo=; b=h4Gt3CcW0ppwWxATJqbqrrjxHLMNtQoS78VC0tvlmakKz67nJ7fH5D2Sr/TKLFe/Y3 QJLltYRqdGQZovusXenQrPwGbiUF+dGvXIVBE4HiKz5ym1pzJ57BCvpnZnb8Uc7RC5/5 nFKenHU1K0qJ2h/YoceV5AO0oEFCM3XKmnj4I5o530mEQZPzAmuJiQkJOk3ref5MLAtZ s1RiHrjProChGC7ci29fEGv1LrxgWZLEFGiM8RPNzZ62WPFEiZrCaMO+IWyUEbmimJPc 8x4edJMRmBpho4W7CPYIbVi4P94EUeEGPUGAny8w2lF8F8plibryjkWf9FrJQHlwQotj 6I/g== X-Forwarded-Encrypted: i=1; AJvYcCW7SwLEiMWQtVHuSzUSHySN4iGQaet372iWb8lml739ODv/JCcYapTCs4cv84qhHeQgx6x9fs22lTdJyEE=@vger.kernel.org X-Gm-Message-State: AOJu0Yyp71hIvP/RANtX6pkIVoQjkDxTH6usy5Jjh025jzwUCkKTN4KL aeFrrrr6fiB/5EItVeg5aJC2N1BF3ogSeZJNpkFpGMpyKZNIrxqk8h2Ma+eYncbur/eaAUnZTEg fIFd8mg== X-Google-Smtp-Source: AGHT+IG2rU9ew71mU3VZAWwi/5uzcexhk9OmzX2TeEyewRA8jn1uf09N3Encw+uhmwgskCMKMBJKZGWpKzT/ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:2391:e0be:5394:f85d]) (user=irogers job=sendgmr) by 2002:a05:690c:3683:b0:663:ddc1:eab8 with SMTP id 00721157ae682-6e866334e48mr431597b3.4.1729755230911; Thu, 24 Oct 2024 00:33:50 -0700 (PDT) Date: Thu, 24 Oct 2024 00:33:24 -0700 In-Reply-To: <20241024073324.1513433-1-irogers@google.com> Message-Id: <20241024073324.1513433-11-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241024073324.1513433-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v4 10/10] perf test: Sort tests placing exclusive tests last 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 , Howard Chu , Athira Jajeev , Michael Petlan , Veronika Molnarova , Dapeng Mi , Thomas Richter , Ilya Leoshkevich , Colin Ian King , Weilin Wang , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This allows a uniform test numbering even though two passes are used to execute them. Signed-off-by: Ian Rogers --- tools/perf/tests/builtin-test.c | 125 +++++++++++++++++++++----------- 1 file changed, 84 insertions(+), 41 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index f5c5b82d3b61..2acb0dd5851b 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -137,12 +137,6 @@ static struct test_suite *generic_tests[] =3D { NULL, }; =20 -static struct test_suite **tests[] =3D { - generic_tests, - arch_tests, - NULL, /* shell tests created at runtime. */ -}; - static struct test_workload *workloads[] =3D { &workload__noploop, &workload__thloop, @@ -468,10 +462,6 @@ static int start_test(struct test_suite *test, int i, = int subi, struct child_tes return start_command(&(*child)->process); } =20 -#define for_each_test(j, k, t) \ - for (j =3D 0, k =3D 0; j < ARRAY_SIZE(tests); j++, k =3D 0) \ - while ((t =3D tests[j][k++]) !=3D NULL) - /* State outside of __cmd_test for the sake of the signal handler. */ =20 static size_t num_tests; @@ -483,22 +473,21 @@ static void cmd_test_sig_handler(int sig) siglongjmp(cmd_test_jmp_buf, sig); } =20 -static int __cmd_test(int argc, const char *argv[], struct intlist *skipli= st) +static int __cmd_test(struct test_suite **suites, int argc, const char *ar= gv[], + struct intlist *skiplist) { - struct test_suite *t; int width =3D 0; - unsigned int j, k; int err =3D 0; =20 - for_each_test(j, k, t) { - int len =3D strlen(test_description(t, -1)); + for (struct test_suite **t =3D suites; *t; t++) { + int len =3D strlen(test_description(*t, -1)); =20 if (width < len) width =3D len; =20 - if (has_subtests(t)) { - for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { - len =3D strlen(test_description(t, subi)); + if (has_subtests(*t)) { + for (int subi =3D 0, subn =3D num_subtests(*t); subi < subn; subi++) { + len =3D strlen(test_description(*t, subi)); if (width < len) width =3D len; num_tests++; @@ -539,18 +528,18 @@ static int __cmd_test(int argc, const char *argv[], s= truct intlist *skiplist) int child_test_num =3D 0; int i =3D 0; =20 - for_each_test(j, k, t) { + for (struct test_suite **t =3D suites; *t; t++) { int curr =3D i++; =20 - if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) { + if (!perf_test__matches(test_description(*t, -1), curr, argc, argv)) { /* * Test suite shouldn't be run based on * description. See if subtest should. */ bool skip =3D true; =20 - for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { - if (perf_test__matches(test_description(t, subi), + for (int subi =3D 0, subn =3D num_subtests(*t); subi < subn; subi++) { + if (perf_test__matches(test_description(*t, subi), curr, argc, argv)) skip =3D false; } @@ -560,24 +549,24 @@ static int __cmd_test(int argc, const char *argv[], s= truct intlist *skiplist) } =20 if (intlist__find(skiplist, i)) { - pr_info("%3d: %-*s:", curr + 1, width, test_description(t, -1)); + pr_info("%3d: %-*s:", curr + 1, width, test_description(*t, -1)); color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); continue; } =20 - if (!has_subtests(t)) { - err =3D start_test(t, curr, -1, &child_tests[child_test_num++], + if (!has_subtests(*t)) { + err =3D start_test(*t, curr, -1, &child_tests[child_test_num++], width, pass); if (err) goto err_out; continue; } - for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { - if (!perf_test__matches(test_description(t, subi), + for (int subi =3D 0, subn =3D num_subtests(*t); subi < subn; subi++) { + if (!perf_test__matches(test_description(*t, subi), curr, argc, argv)) continue; =20 - err =3D start_test(t, curr, subi, &child_tests[child_test_num++], + err =3D start_test(*t, curr, subi, &child_tests[child_test_num++], width, pass); if (err) goto err_out; @@ -601,27 +590,25 @@ static int __cmd_test(int argc, const char *argv[], s= truct intlist *skiplist) return err; } =20 -static int perf_test__list(int argc, const char **argv) +static int perf_test__list(struct test_suite **suites, int argc, const cha= r **argv) { - unsigned int j, k; - struct test_suite *t; int i =3D 0; =20 - for_each_test(j, k, t) { + for (struct test_suite **t =3D suites; *t; t++) { int curr =3D i++; =20 - if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) + if (!perf_test__matches(test_description(*t, -1), curr, argc, argv)) continue; =20 - pr_info("%3d: %s\n", i, test_description(t, -1)); + pr_info("%3d: %s\n", i, test_description(*t, -1)); =20 - if (has_subtests(t)) { - int subn =3D num_subtests(t); + if (has_subtests(*t)) { + int subn =3D num_subtests(*t); int subi; =20 for (subi =3D 0; subi < subn; subi++) pr_info("%3d:%1d: %s\n", i, subi + 1, - test_description(t, subi)); + test_description(*t, subi)); } } return 0; @@ -660,6 +647,55 @@ static int perf_test__config(const char *var, const ch= ar *value, return 0; } =20 +static struct test_suite **build_suites(void) +{ + /* + * TODO: suites is static to avoid needing to clean up the scripts tests + * for leak sanitizer. + */ + static struct test_suite **suites[] =3D { + generic_tests, + arch_tests, + NULL, + }; + struct test_suite **result; + struct test_suite *t; + size_t n =3D 0, num_suites =3D 0; + + if (suites[2] =3D=3D NULL) + suites[2] =3D create_script_test_suites(); + +#define for_each_test(t) \ + for (size_t i =3D 0, j =3D 0; i < ARRAY_SIZE(suites); i++, j =3D 0) \ + while ((t =3D suites[i][j++]) !=3D NULL) + + for_each_test(t) + num_suites++; + + result =3D calloc(num_suites + 1, sizeof(struct test_suite *)); + + for (int pass =3D 1; pass <=3D 2; pass++) { + for_each_test(t) { + bool exclusive =3D false; + + if (!has_subtests(t)) { + exclusive =3D test_exclusive(t, -1); + } else { + for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { + if (test_exclusive(t, subi)) { + exclusive =3D true; + break; + } + } + } + if ((!exclusive && pass =3D=3D 1) || (exclusive && pass =3D=3D 2)) + result[n++] =3D t; + } + } + return result; +#undef for_each_test +} + int cmd_test(int argc, const char **argv) { const char *test_usage[] =3D { @@ -687,6 +723,7 @@ int cmd_test(int argc, const char **argv) const char * const test_subcommands[] =3D { "list", NULL }; struct intlist *skiplist =3D NULL; int ret =3D hists__init(); + struct test_suite **suites; =20 if (ret < 0) return ret; @@ -696,10 +733,13 @@ int cmd_test(int argc, const char **argv) /* Unbuffered output */ setvbuf(stdout, NULL, _IONBF, 0); =20 - tests[2] =3D create_script_test_suites(); argc =3D parse_options_subcommand(argc, argv, test_options, test_subcomma= nds, test_usage, 0); - if (argc >=3D 1 && !strcmp(argv[0], "list")) - return perf_test__list(argc - 1, argv + 1); + if (argc >=3D 1 && !strcmp(argv[0], "list")) { + suites =3D build_suites(); + ret =3D perf_test__list(suites, argc - 1, argv + 1); + free(suites); + return ret; + } =20 if (workload) return run_workload(workload, argc, argv); @@ -727,5 +767,8 @@ int cmd_test(int argc, const char **argv) */ rlimit__bump_memlock(); =20 - return __cmd_test(argc, argv, skiplist); + suites =3D build_suites(); + ret =3D __cmd_test(suites, argc, argv, skiplist); + free(suites); + return ret; } --=20 2.47.0.163.g1226f6d8fa-goog