From nobody Tue Nov 26 10:24:01 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 D7C7C16A956 for ; Fri, 18 Oct 2024 05:47: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=1729230453; cv=none; b=oq12r6kqV9GwO7MojKPlhaNOs9FnGYiRUpXEnUjGKZaHyd39YKa5SuTOiINgUHtybXoMEhN01J8mbT0jG/F0/U7NUxU6ngXg06p/ylcP6ClFnZ82buysy7O90jKFaBqZEEJI3btzP9nHs9GAEREbbgQkB+S0Rs4pA8Z1S0T2ijU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230453; c=relaxed/simple; bh=YP95DtVxXZ3m+MQlhugoobD6ADZipWZQ6/Y1bwP+wc8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=a/jDN9qTP7Kd0mloH5YTYRvQFmcHIXUEDq2k/bpEq5Mmkc7gVta9F+42C3LBl7q0PA4YXyTqIk5GZ86KmZRMyLhevibEWxKljwdCoTWzCIz7A9ERprcW5IzQ0KuNonjFuPxFAFKogf9miYqwO3ZLRs12kEmQgVtJXcNSmDEPhXI= 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=zlKinVhF; 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="zlKinVhF" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e38fabff35so33154167b3.0 for ; Thu, 17 Oct 2024 22:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230451; x=1729835251; 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=vGsyk1AzrV7bGd+qNQRt08SgX/qTGBP7C2TEAC3B6es=; b=zlKinVhFKOmSqIT7P8RYozj3VJj3LiNFEYoUKQtApo0Kblp9xxzF+Abk+l2eb8Ue/m of6SRwkEIgilJfH5BEcLxA6f1nNMwCkFQNyDT3nOFLXr3GpwPwrwNBPYcX0M9FxH936x OocpEATgGgzcqh+duxRleXO+/g+HdGZGv7hGibq9CtoCmQnBIrWUSsdt54BMGT/IQDgT zirHdgIUfGYKSmbMqslnpp4J8vz3caqPZPjnAmMtdKpKHIR+RPTkN1oyKBx+/WdOwEgz G7cMcJRkAMntd8mDmjPtq2L6JW9M15HFt9U86pjxKf1gw8cUEdahWUGJmOdn1GI1qsos fKdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230451; x=1729835251; 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=vGsyk1AzrV7bGd+qNQRt08SgX/qTGBP7C2TEAC3B6es=; b=Ov/wEaQWavB0eEC7St56gsRglY7FDCvBVoa8dDE7IfdPP0YIvRcXnGUvqbiI247jka jM577J7T6iX8skfSv2EpxXvIjTDBp4OIXwQBhDm1YRVhNUEukS2pgqH47N82Ucu9dAEM uKNZeA35s1dq/tQUAPOr6l9n7oFG87uNq6EeLHU38XvORc/+4hyjhPVAbWghDbLnu35C O2TuacofA/BQXW1OBX6vewKViKOXj3YGenIg3oLBZIE13NyQ9LD0/Sw+18zhfVqhH7CD x7GjqPmWxZj55u//AUhgQZEm6mkH86xNK5MIziY5klmQn52V1LG1tJuOlm64dlkyQlQX RLJQ== X-Forwarded-Encrypted: i=1; AJvYcCXBliUy+ErfisYORYyCtZHRs6acF/F0sxx7FLq8DPoNB+2bsf/l0FTd0tVX89JgNnyrLXOGWS/snFbIGvo=@vger.kernel.org X-Gm-Message-State: AOJu0YyR0is8rwrhBWHSJsmvFCCu3OYE+iGZHtNnYfWjABBXCMaovbv2 OEV4ycPpQewKMMlv6Y0QRDuYXd6GZbpFgFd24cyKngWZZIRZWwzrEU2oAAXcMX9xx7DBoMkdOWJ qEVOF6Q== X-Google-Smtp-Source: AGHT+IElZxi4gKlHpKHuQcILQunGIrccEF/5kNieA5pjiK5bJX7QyzdVU789CKgaouu+VvSlRqh+Z8wc5LlT X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a05:690c:368d:b0:6e2:12e5:356f with SMTP id 00721157ae682-6e5bfd21dbbmr472747b3.3.1729230450809; Thu, 17 Oct 2024 22:47:30 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:11 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 1/9] 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.105.g07ac214952-goog From nobody Tue Nov 26 10:24:01 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 F0178183CA9 for ; Fri, 18 Oct 2024 05:47:33 +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=1729230455; cv=none; b=LgIPXF4QxmJ5CgoKWzzuhxf6v0J8xHgiO6Oqw5SEvd+VYb1aAXmPPhJYAvY9t531THKT9wVe+yHAdFZy3qDeXD8V8wJE6Q5y4BtgB1UWUP9j+UGrQ6QSdnOpf/8YIT6It0o3Mmnimjuqu0ROBqwlIOBslgdwSpUWoJUzTD0umiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230455; c=relaxed/simple; bh=fFas7LyqSjmG5V26rD2/CFaF2XrJIT7gW3QIZSxUtUU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=SiGOiYDQ88d1eGZD1xvWXKriZo4/yQnViVT8iRnoQMjsdksef7UlVjIv45xRm9cBjQVsQhkCKBzlqwdrbfrAghMbmovKelkw0OVr7jOdhPPcDNZGiflAohB4oYqwr1l7i/vne6WMSEQxatxJms168UFpOTfTpmSv2pifuPzuyTs= 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=Iz/SkRpt; 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="Iz/SkRpt" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-690404fd230so36751667b3.3 for ; Thu, 17 Oct 2024 22:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230453; x=1729835253; 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=7H4716CUp7wRIu/vgNl/76x7htTbrKtb+Q2pljLbUoA=; b=Iz/SkRpt+y9leMN/kflJf+5cBQd0solzwWHd6EnoR8YWI2s6EB8kkd8CXD9dwj7Ty1 KKMMGPDMp9k7SKXk5iHduGU0OjQVUhUDTzP7OihpVEvTUk4Ik60ooKWDvZJBx9By4mfC 9++J/LA2IJRVQPqPsrhObDI4xNH7ICTsoNobtjl0SBVSiVnmHoF5iQJbFlCTkGN8ZnXO 5YgNubzyqoWIhxMVvKRiLI7+GitZq2FMHjdKluvF7XBWN3wUWuET8pLuIsRnxJPfq7Vf 1ipKv31w+Zbkqf7OwUl77oxonjGLGiD9L4XNtL7vBorZkOlnYDz+PKo4dsyTuepQVLVC 7NHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230453; x=1729835253; 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=7H4716CUp7wRIu/vgNl/76x7htTbrKtb+Q2pljLbUoA=; b=jpzfdJwPAiQaXFThAsa379ouP2cPo4tOZPRSPYcKuze9IB60obNCDwjfyAkNCN98/0 Z+yTg1dIBQfm5N+sExP1ICqSeAlEQ1rGmNxFJnPmYUu17Z8si5w3M+qxBPbKkLtOUvli oXJRJnrtHyDJKVfbjZUoVrDSQe8HZqLdTyk3YfYt9EIm7UtxKFJYaCeDcajsFAToWILy bWZLuo9Aso70Y0eIXeQppyEkIil6zqEwX6Yq3tpOCZZFPsT73sHghZWDFx6u6DmLFmAW 7lqjOCKRBANhfgF5may4PQ9MtRGRGhJGd8j/6LoT1g3Q/mgosMgbRntk43uAQPGGoSUk ZzIA== X-Forwarded-Encrypted: i=1; AJvYcCUUBACx+O27G4dT4BPSYohac5c+8wohHYfTsXr7rjpNSE9ZGXjeRF1KIiaEbpBIyJoqHzqku/KbUrh7hto=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1pj7Pm5rHVHaeh05KlS4+qs6fcoYzC7nUerFHEnnS9UQlMYx9 cdwvN+fX8d8EosSGWOflIivThefTgOFNaEE5Xm6vte2AHbVLfuySGIRthbdvSNFdLbmOwMX+DAn 3uKFGvw== X-Google-Smtp-Source: AGHT+IHrNwGQ65miZ1DrqGdwnyD++/1tfu2IOs+mARqDoQe1p6KCckIDzEp1Tmy2Msvr1EzURm1awJvJOTxP X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a05:690c:618a:b0:6e2:1713:bdb5 with SMTP id 00721157ae682-6e5bfd20ea6mr90897b3.5.1729230452936; Thu, 17 Oct 2024 22:47:32 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:12 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 2/9] 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 3b30f258c395..381363fc766a 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -243,7 +243,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; @@ -253,6 +256,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; @@ -274,14 +280,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 /* @@ -295,7 +304,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)) @@ -309,38 +318,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; @@ -356,7 +387,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 @@ -381,7 +412,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) \ @@ -466,7 +497,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 aecf56dae73f..dfc897a6fa20 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h @@ -22,6 +22,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.105.g07ac214952-goog From nobody Tue Nov 26 10:24:01 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 37E3B18755C for ; Fri, 18 Oct 2024 05:47:36 +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=1729230457; cv=none; b=VarEZ5nkpA+CiKX+xBSywx12tJtwx1OGdxSRH2uKj10Cb8sKzxSzSFkNc935G+NNTVvY9V5b30GbCKmPpTU0sddPtaoqU+GhPdvDxS8/KJ5OiIy8uyaCdBXbJ+H5l3hHk3QVhKa+wAcKkoFeh+tbFw8KmwmAwzmKxwO69lMiox8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230457; c=relaxed/simple; bh=AAtaACQPcJ/vEDycDGlrqtwZ+/7iyw1bRicZ1mXbDEs=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=M1OOOXZ4NqrlA0MleBqMYQ+xFUJOYFTSZ7KlZtSpesgV8nMeK73YdUHoZ/EftRSisa/9hjLJ4vDFaqeJrD36dbE+GOtjmT6g2Qoq1SjBy/b/GN5WWd18aOko3QdWNuLm350wZZlnhxUo800O/GBZKjFVH3Pn80qWiPzVwbkeFIU= 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=NKH7YbVs; 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="NKH7YbVs" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e28ef71f0d8so3465072276.0 for ; Thu, 17 Oct 2024 22:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230455; x=1729835255; 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=IzOzjVPX++lTeYMMDuPz7oJrYRHg6W7qrKeeR8mkY0E=; b=NKH7YbVsHHUIRJ3nB6w+/trq0I6Im0mOtQT4IEZvwmybNV3o4LzA6pSUVYC3rVC+cx EFD1KVc5oXe8qmEo7f5VO3aDcMdft0im8etCFsQEF+SvokHjD/DPqeMON/pwGAzUuXqA mcoJciVRTd/k3sQKVg6O/234o8nJsgIACvhWroYCAI2WEKAatrYUUJDORFVtxtsORaMn E6vyTVkqVIPQYNjejPhejuUeqzciVuRyMsNEhVqO28zzuurEz25atFmDBzM6bFSyOKcD 469e168rQfmIKuWw1iqhZobE0CDRcnru2JUuG95dkhp79RG+Qwyib+/HeWn3ONgG0y2y zvtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230455; x=1729835255; 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=IzOzjVPX++lTeYMMDuPz7oJrYRHg6W7qrKeeR8mkY0E=; b=Bq0krjGepwmE0WY753MJA2URIbBQSf3wtHKAsgAtlrJqfso2y5wSBcl+ll5GK3fV9O RfV2nHiNze/d00P2jxD3XMRqworL+CSTaUed8TQl8DM0fSQnVOhDWgjZyn5DBQIxBvW6 gfBQH6rV7thI6iYCfc4JZa4L+U2q5OeGMAJgFZ1Gw3w89I0y8I85v64lJ5zXpbcAOSno EBWGfVuPvEOngaKOO55lZKSFKKawO+yjDpbqhmo68gDDb7sEq5H9eZ0Tfy/ffKo9dtBn Jcm5bh4EUlpg5+cagY6uPixoZ19oj+Tj5/OT3qMQMFtTNl4cRbSMJscN2MZea+fLr03z vtfQ== X-Forwarded-Encrypted: i=1; AJvYcCW+bsIt8DcMcJ3fChAIoib07f0hN5UJL/E/PbPRcV69kuqlGNHrz5/0Y6Ho0/84pS9Tg/paoybkTBAA7QA=@vger.kernel.org X-Gm-Message-State: AOJu0YzkmhJJtXZ+t/s7+g15ulJ+P5EvXg/AaRCmtdCF+spjCE7J4ZFQ FPJeQNhwCoDw20zgj0wCj4yWhkWXa1NOgbpOdUBzQyu7yoxr195Ans7TQQVE02Rw/hkM4kGTkez sUHUyyg== X-Google-Smtp-Source: AGHT+IG2GJKR44wUCxIVr6fn7zKLqbFnjefjdb7hukVEXHDUIcwE1VUYtt4Nc8ZXYmRbJiNsCn+SXgFEeYo/ X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a25:1e87:0:b0:e28:f6b3:3666 with SMTP id 3f1490d57ef6-e2bb158606emr808276.7.1729230455199; Thu, 17 Oct 2024 22:47:35 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:13 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 3/9] 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 381363fc766a..db6cc83ba505 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 @@ -566,6 +563,12 @@ int cmd_test(int argc, const char **argv) }; const char *skip =3D NULL; const char *workload =3D NULL; + /* + * 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.105.g07ac214952-goog From nobody Tue Nov 26 10:24:01 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 6DDB4188010 for ; Fri, 18 Oct 2024 05:47:38 +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=1729230459; cv=none; b=XlbjgTsDcWwEbjOKUMKuhZ2+UMVK5XANCT21zQzddiGmoyRaZgOmt1+FC18Z6lh2ZBGqxDiaZruYXCeMlR9Ctx03us6Vxh09S1oaYV0VkwCay8L6n4aLORy0jdBsRBesHV4TZM3fvw5f3E9GGS0zvhk/EpBi1rIv8HCtjpASJrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230459; c=relaxed/simple; bh=8e+Q4WMgAUC2AFJM3Jw3+2noMVxztKU1eVkUFIbNsps=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=dcnzNI8mHFMFFtSPZhz7DBPf7HvPEjGCx/ZurGVdpDFaNtuCq3IdF8it1lPsBMjWu2q2dQW2rCIzjqI0f+F9WIYSBLjDjufaEdChqUhODNBhKJhIdHZQ68V2v3SyynZdwIJe6Iz0mWZrzFxmCN6b4pLbes325aE7jaH3sOvAlvo= 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=Ps08zssN; 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="Ps08zssN" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e389169f92so36843737b3.0 for ; Thu, 17 Oct 2024 22:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230457; x=1729835257; 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=BsQN3YhU9LCKt/5hTOi9Jor4dADGagl+y4jf9jVpPl4=; b=Ps08zssN5ONC9+CQaSo4wU5tjyplHArMK1p+w5m90xZycfER+KEqskIcNLRjMJaLev Dfj+/47BTpFPIKtjhVoTGmUyr58wnhgE6mnB9mYHkBUuG8aWCk+EyS8VOuy7c3AJvRJB Q1b6giwrgyqPGzfYOuQFy243DFe+C85JTP4oNPhXqrhZAh5XpY4mVQpeec1pZUjJTnhA LAub9wTS4p6ire3V+mX4NMDTYKw4gJMUkX+mX9HxlgrkhJ69B4D6mlP7SqK+o2ux1anZ n0Fj29nUfJYUf7RRQPSStWKkL7A/jo8Su7LYXtZ18bT8qhzKmma8OLFJA6VsFKWTblW3 PBJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230457; x=1729835257; 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=BsQN3YhU9LCKt/5hTOi9Jor4dADGagl+y4jf9jVpPl4=; b=KgW1UHz2n6EqWypR4zjP8Alsju7TSHL+XXtSXsCsLj7ou9DsaS2BOy9w6kdnSlqXSJ SEABXhlx5lL215okN1W0iXjx6zW+4zChjqGnsP5b+NWbMjSDa5oZ46jnos5F/gHwALpJ Cy/bkRsHZ3jI96gT/c673O/Ip8i/R5HR5QuE4g62Guz0z0t+bq8o1AV9HPSrqidn38Gk 9ltQWZt04yNXBio56UbXmGVck7q4BL0goom7AKL+KV+jtr7AwK2ne0emqYhdenhDiTOx 3INA9MdYZhE6qY5kCV+tIlYmQ4u2+fIoIkCZ91tnxROAVkNP4WHMhN4C6TCYWopxHr3F Cwpg== X-Forwarded-Encrypted: i=1; AJvYcCVMvPYFmGN5Pd4fwRo6lx6SqBHEUjwCcO0Jn9NspzYcO3RDGjwk1IzdvSxtX7FkXY6iSL1t7M1aIY0kZrQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4c5T/MMTMQ4g8cf8PmvaraKNxqKS5HbXb6UaelelOdY6k529w +ezFsKPUewTFwbmAmbE85K7un2VSvmt4g1mb/g5yfx0Ck4KjcMblJqL9Exk1YyLtUtV6FU0MYpF kKJd8Ng== X-Google-Smtp-Source: AGHT+IHSV0g8KfPFuSViNtTcPi2t1fku8t5liAXZpggq3Om56o6vHxc+L8l4VTrp8YyleL4IZ9CPDAkYsoM2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a05:690c:680a:b0:6db:89f0:b897 with SMTP id 00721157ae682-6e5bfce3afcmr74567b3.4.1729230457316; Thu, 17 Oct 2024 22:47:37 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:14 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 4/9] 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.105.g07ac214952-goog From nobody Tue Nov 26 10:24:01 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 AA6DD188714 for ; Fri, 18 Oct 2024 05:47:40 +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=1729230462; cv=none; b=s08/QFBBLcbl1vz6rW3deGfk6DSpXCnFlToZEsdxiycLDQo80c3XSqhOzdi5q/RHb6Vq8m6kkBQoSHWZ3KtMCRE5TF2W/M2GYbGKx8U7bd6maEmsdkEd8QWX7uuiiYoBk8QfkHggTQRiBr1iVbXkSIc6tOAaeSlhcimN4IAt/gY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230462; c=relaxed/simple; bh=2DSHvQJwjl1wFfKjv/w/jwdEkN4WtAf2lvlnE8F6Rig=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=I3FZVsVofQE4kOSREoqrQcL9vZRxMV1/ehtuLl/wOom1Kbr6AfdB1Y1WuHTS2Sl8I63jwPWW7iBb5Xdu2L3jxgPPgS+kV2hamB6ZFlyzdmqTGH+/9sCQ1aBtHEUmjsmeSQY+2yWegQaZ3N0l5Oxe75ef2KME5vx4wrMNRbttIAY= 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=S8t3a5K6; 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="S8t3a5K6" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2440969276.1 for ; Thu, 17 Oct 2024 22:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230460; x=1729835260; 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=NzFQzs96ike6gGyVT/bHDa8YVmwHjtoRnijWO4so1qg=; b=S8t3a5K6BmmDpm8MvszcogTix7EI2bLZRuImRHA1YUfC5zucIPQPcWjQjY/03HMy02 WN6NA1f6eGhBEIJ3OXvFokd7KkklJxY24kCEL/SkrcTjBSDm5ltcS66DV/CGViCkbbKw c7cboq+NXbUJWKOvcEB65UAxx94i1mMpwDDacQkm9VkYOUv23YP7bV9EzwT86XW7eQ+J EEsHBoOXNC0XJi5YqCn8rLhxwufX1NqsP5aUWwzjlBxhd1on9jfv88O9HzRIhIpi7x3+ EKBTlFb1Pa9T7yd/nSCl7QcLqp+m7PMPyFcTKuPz6102WxW1283ciDqxQL/BpTO0uHcV Icrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230460; x=1729835260; 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=NzFQzs96ike6gGyVT/bHDa8YVmwHjtoRnijWO4so1qg=; b=dLbNCFpH3LHsStHTrUB0jSGWQ1GxSvzVC8kVIICsMUnLkT7eAlf85kAeiWAuxtbiIT qc6SA1dFL+nTgBlLlb7hYAFiRGSWNHL5uBy4KybZse5O8salzsaZzF+vxNEy9Bd2cJpp jED4yOyPq7PmstWR4FuzI7OiuV97iHddcCW69wx5AtUkY0vrZUJ1G/g366jDG1mwb80v 2AYxS3vOVtrItENnXE2FfpXWSx6XHJn4qR6mE7NC6v/pAbCqXlSmpVYAon9CgJXWFr/W oiHGPSZUFdh0R4yAcZnHybTx3/QZodg5Ubv3LJHlBM7abmOsp9o67upbvumz8u65KO8A cR1Q== X-Forwarded-Encrypted: i=1; AJvYcCX1Ra2/1Nfr+XPfs0TBpfyZqMspINZfWP0i35bH6DUen8Bp58lR+gZ61plY9URgAytYZmgfzooZkpdOkA8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4FHto7Rab3cAp5hnft2kZ0++qSIyWerIwM8queb+JaYu17Ubm baWHsoWY9831z3cH1tGE/WxL0I3qNN8VfBIFcp0WM6oSv/oUWewyWO8pVKZUod0dj5l45wFXVAV JPJeLCA== X-Google-Smtp-Source: AGHT+IEKrV9yTELs7qoCVZTADtDSiWtNXT+PdCmOw7mUzT9kba+jvbeaRieOT318s536rq4CK/0pMJy7UzqF X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a25:81d0:0:b0:e28:eaba:356a with SMTP id 3f1490d57ef6-e2bb16d53e4mr3858276.9.1729230459466; Thu, 17 Oct 2024 22:47:39 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:15 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 5/9] 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 8d6366d96883..f7d8c5b243a4 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 3302ea0b9672..534145778d7b 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 af63e3757cb0..353d0a24f976 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 03d5c7d12ee5..be0fcdadeea8 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 723ec501f99a..660991d17607 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 3146a1eece07..673f09afe937 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.105.g07ac214952-goog From nobody Tue Nov 26 10:24:02 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 D2BA5188901 for ; Fri, 18 Oct 2024 05:47:42 +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=1729230464; cv=none; b=petQAu6AgYnTNO5m3Mmbt1yIf+5e3pGrmYMQjPN8oSx5YJVHO5jt0LeA4d3br38Sz/pSK95FEWIrK+v/CKuTKlFQg+GAIwCXqAlIewkI/QwkO03Nq3cfU74X0yDZmOzlUZ1igWCs4INKc+giKc08wqUy8nbwGyQAJ19phtIfxm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230464; c=relaxed/simple; bh=k0BOXCGZynGmVHFfSxAt15i/jsThHEDa9Z9xA4vwOcU=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=maslqMJuM46z47+TSnPaYHR7p9uf5wu0t4Kkwe89DMjOkdwK2hbGoppp/ZfIO+x90F5MHXXVmupq8haZb/UaUaG4fmK/f7ZWne5W6dDW01asCptv3E4T/MfX4DEjtcQNOqHc9rBgNyL+mH/E2BfPUpSW2rwYIM8vgK+42LgSKNk= 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=Fo1c46Et; 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="Fo1c46Et" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e2904d0cad0so2700729276.1 for ; Thu, 17 Oct 2024 22:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230462; x=1729835262; 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=RlqOyFIbRvuFWfGY7KqjkQMxIKLW0DMuZ9kuTzuxI/g=; b=Fo1c46EtcAO3pPFLwMreKRY2ay0ipVD5UQDqlZfASoYQKxJoyOrssMRFUPOQMQeGr0 2mWx5l6J8qnOyGBN8IvHLOE0Knfvs8lj4NRnHZGSxoXj6G90PN1e8fJPAEJfHzFZWJJO EbcCuCKfLBW8/ypqddvkNCN87hPMgnyjf9ZbC5El7DKWoL84dA54fMEQUiU7iWdCq5XV QSs2abtp4276eqpWAHfdVKlVsKhlQoJ9cVVSwmtOZOFD4Zu2nAjm7IbIv3RdlEu3QAkb eSubFqSw6kcdi2W6Tn9PghwKeiKGKd79ed/Ae8BYFSpMEBY63oeUL2tXdpw05SCdmpe2 1xVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230462; x=1729835262; 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=RlqOyFIbRvuFWfGY7KqjkQMxIKLW0DMuZ9kuTzuxI/g=; b=fgaubHMS5L9m8Nu5qWQOKGNCIlF1Abxz1vob+3T3oSuP4ReeKS998mBJ8MK8sv0geD kKL2x9qIfaMJA/epLOwkMNJ/ZNy+1elCMRtLlmd8MX0CT0e+vP7kzsnLysEtrO7xx4Fj BHO2zziJ8iBJbO3CohGNmzSi2hec9IaInoog9eRgbso4kglNrcKjyad7SPdvdF59DjWI h5oqq7GZIbz14vEx+OAYEoT1+kW4ioaCWsuNiLo7Qw2BxlYqY3Ue+q4DvGKxMw7+lwtN oYddmtTfS6aAE3Cdm7EPV7hI4hcDDUsFxWMU3uDCaDSbqJu3bQZGPPGonmOYSsWjjEjs sruQ== X-Forwarded-Encrypted: i=1; AJvYcCVXnYjRyH1m9DeVVkAOtcZPNSNRxNVTQPj+IuiJghNKKyFXnE+78FLgW6CT++QJQuGzZlg2Ngf3Xq6sFJE=@vger.kernel.org X-Gm-Message-State: AOJu0YwT1LQ8u0bKaDuPWnmzdUUNTcx8O0vhcXYMMM+ODU4b5klTjKZr m2bRhaJNY5ahzV8pJoDM6WBr43DALkya2sOWqMX4LqQ7+/mvg78rWJzn/VZM28qIUT1yQluEuv9 JMPJ5/A== X-Google-Smtp-Source: AGHT+IFEZkKpnOQlkP6vldZgwtko866JrioCfyYPDfy2d1AJe5t/D3hNGzKduhx0GSV7SGg+9mfCQAy0lhQ1 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a25:fc07:0:b0:e29:6e61:3db4 with SMTP id 3f1490d57ef6-e2bb11cea47mr3154276.2.1729230461616; Thu, 17 Oct 2024 22:47:41 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:16 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 6/9] 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 db6cc83ba505..f8d6477c3b0c 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 @@ -227,16 +228,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.105.g07ac214952-goog From nobody Tue Nov 26 10:24:02 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 5BCCF188CA9 for ; Fri, 18 Oct 2024 05:47:45 +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=1729230468; cv=none; b=QW0awc2aZWVyJl9goAhO1LQB24nGSAKXBK4LL6JacgP0oK1ORaklDopUhvpvEMbMUJ7ej77h5MKd4TH0lryk/jszobILbbZ/awsXShewmVWxGl/1xxWDurP2iuv0/jANy3tMF2J6nqTnenPUeZNXSsmxq23hpCfJ2Esp4aTMTeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230468; c=relaxed/simple; bh=lCkpa6ifBn6e1eEDMn0Dmgm+FfjPgcRUHbXRECf1jxY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=EI+EyGjAPqWlmMtp2/0w1KKqNpDyew19a+EI3/Nd/6puj/xwnwf5lEj3zHISu7cTtEHWyFwmq7JJqliN9NnkD4uLHbQY+eW+6J7LQM+A+QldQj6+sLsoXacUJ+SQdIWMiybtdqxUxk45JR3Ya4fmDfiNcfrrkVaMBbCug9gf+3w= 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=v6ko1+v/; 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="v6ko1+v/" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e35199eb2bso30150607b3.3 for ; Thu, 17 Oct 2024 22:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230464; x=1729835264; 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=T2ua1xHiFSqAgCjtvB0jWwTGC44zi/KIvuSMnSpC7Xc=; b=v6ko1+v/rsH20Ac7VzYSs7bOFEYEq3sQFe1iEheUZ2WIGiGWiwh/4pcLgAV09vmuAI mso/ZP43AqZOU1KUYx1/px+/+rVsuNC2yZW7uUmgSu0osWnhXC617CLNag/qUXSRipPU QgFiF0w0FjOIzggaEdSOWpuGlVEXVm5E2HcTCOsh1WECeGCQngJJt6kLw5xj+0B3AOb2 sveixB6vp0K47GVVzWQdRckw+oyECPNyH3TA52YJSLzABAUmkZLEwzRbrEJv/2QSi/bW f5L+ZTzniGDGSMGTCshonL9UveMByt3fIGXKYAch9WvyZWaL7RmMbYdH906pW9XTij67 DsBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230464; x=1729835264; 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=T2ua1xHiFSqAgCjtvB0jWwTGC44zi/KIvuSMnSpC7Xc=; b=W1VG6AYgR/grMJLIafdaWuO0GLfTbiFLcUinOMGxpyrIWC+EGD5xSIFX/V5rWo4Ifp x+0ORYTSEMR4LRTT5cfNURfL1bw6IlegAZkQKnG9L6JE+v/VMx0DFxPJgHb+HgruR84R LU9T/DYwSpbXN54tWRyFft5t5eQe4kPI/p5A4bQDC/GVDJrc77dU8seQbSg7BSlrmUI4 6pkGN8ipaXQ2yNdd69z3JVIfGto979FKF4BQc2j6Znuuu14xPK2LHxmiyR+6c4PYlcB5 W6iUXJTn71sowoiDPxc627Gd5n9rtf43oEnwBDa23+P695vwgYoBA6NkK8rO6fM4Asbx LYkQ== X-Forwarded-Encrypted: i=1; AJvYcCU+RYUVXSeUzpJq+ct+QV9yj28p+Tk7alqanrojEsGS47gTDB7Jr/kPF089gwczGZVygSFdBM2we5u1PHg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9hXWbbUBHd+H+IGngJAYbzp5zNxxjEQ6E0iJ/aUnV3fDo5wv8 J5dWnzg2jXObZZhUPfF8mktWEMaQNGC3vdWnw9q38AQcvpDtA4FT3AoufiPFDHewskcWoqTRFD6 oigYeFw== X-Google-Smtp-Source: AGHT+IHhuRR5hv5tay+lihK0uVAjUvyNqzZnotqV5C1FjV8jFlnYVqw5TOmuR6o3woSUopZWrAX+mqRjVIng X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a05:690c:c06:b0:6e3:ce76:103f with SMTP id 00721157ae682-6e5bfc2e5f4mr651587b3.6.1729230464208; Thu, 17 Oct 2024 22:47:44 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:17 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 7/9] 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 f8d6477c3b0c..258dd97c122b 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -197,6 +197,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; @@ -240,7 +248,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); @@ -250,7 +258,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 @@ -303,19 +310,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. @@ -345,6 +358,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++; } @@ -397,23 +412,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; @@ -432,10 +456,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) \ @@ -445,12 +473,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)); @@ -473,62 +500,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) @@ -638,6 +676,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.105.g07ac214952-goog From nobody Tue Nov 26 10:24:02 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 473C6185B5F for ; Fri, 18 Oct 2024 05:47:48 +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=1729230469; cv=none; b=ILuTFvkjL90Y2j53es91kwvuEN0W0DVeKDRbsmqLb6SPk/aeuiW4ytRy7syt/uUZonBwIExWH4y5I5omZhZB52jALFZ7EHhL8recdyhpGBCgHWz70VyXwWfq9A66XSjgFNkikfj/0fmBYHCYyPY+n+ez8yd1EaahW6jKhO9xOWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230469; c=relaxed/simple; bh=NyBi4ldcotgRIWXy+pyJqk7L/008dIgRW+IaUmHndKE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=aaWLMK+YQtmrgArB5zZV6Qs37/4dD0Ik5ULxcvuLfqMbxCJiXOJLl/4JaeiVTu4pqK/4oy3wv/ywPVBsMB1oMqX0Ylp/3TugxFL0FyeEPK9nDKXVkDQxUQ6xniirctbI7rZ7Rj7ygM2k/a5w7hpkqJT0o/D5HoQzvHzGFer6+QM= 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=czd6LNOg; 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="czd6LNOg" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e31d9c8efcso36080447b3.0 for ; Thu, 17 Oct 2024 22:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230467; x=1729835267; 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=WRFmLYGgcJHBSD8LI17iLRO0wZ/dUkGCXCceddIu4Nc=; b=czd6LNOgd2AiALcqvDeRRgjrPDTaeqk3BWv31pOzU9R9x11JG+6XIUPmdUKrb2935r /5o3MhbN+X2bjOhKybfhjbeLIUaEXkcvUusY616c2/rSc1/BH0MaBevEdqC9Sc27oAzO 3k1hMozzdDd6c14jm28bzmZUwQRQZmd6TH8tqlC3xrClvDgD9xZN2/Z4yte/yx2NI85e iFEykiMcHt1UJDFcndsBdlBNoesX1JC+I6QJyIQZhtGvxjY9PQ/aWBz+8WqzFqd8DGdB smNW8AAT/r1IHWTa3Jg6di5ybV1kcKhcfhgMD/jPjS25cvj9lWZzH/GrE3PkPL0RmH0G 0ayQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230467; x=1729835267; 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=WRFmLYGgcJHBSD8LI17iLRO0wZ/dUkGCXCceddIu4Nc=; b=ifH7jQAsDD8yScLzFV1Hfoo+7bPS32iJKb8NLkIxwDhlGZVY3pbQzQe7wuFMG4YrAy JN7Mn3eaOfsHtg5/WO6XdAy0kCyftk6nlM6AIwiKcBMPlTz0kKjQrxVyjQ75mdKvCXEy DFFOyz727aKkhC+ZSRNmvgIXBfHKxvnf6y/3uYY3hcxN+jPcAlAv1YB0oEtP81jfokn3 yDox/VRXXq3sE+3iNLNwfHWL9/PrmKcyg5mL0cJP97oFPJWW1084bbdX3ruX7XKAUkdr P5nuyaKwKfgSnJ52w1wZjOkYjqi2QrD+Ls//ChXCL6SlRAz41Ra6vbcD9IVwX7hwu5ui UqgA== X-Forwarded-Encrypted: i=1; AJvYcCUES1k1o0T3MeLCVYzCvvenNnYgl/JaOuqT+sEAm8LV/+Tq71TYPGjQEjaF829NKP/Q/JCkZMPeAjXzr4c=@vger.kernel.org X-Gm-Message-State: AOJu0YyRky/ryhtKHt7Xoa3mRn6TAXp8aBRElWy+t3kF8SQBLcWA93ys ig94c/vWSN3cqsG7XvO4Wv113i/EJzD/z+P9mk1UE1VKKur+1q5p7j4PHguBLGg45rtrpkUR5Cj PekDFtQ== X-Google-Smtp-Source: AGHT+IFKrEsf9oi8iVB/8vbj394g4OdfsAGDRVko5LPfw+EWI4ka0AKsPwGUvXWJfCgWkVrCA2e+ufqmm8lm X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a05:690c:640b:b0:6e3:b93:3ae2 with SMTP id 00721157ae682-6e5bfbd5bf7mr108587b3.1.1729230466217; Thu, 17 Oct 2024 22:47:46 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:18 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 8/9] 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 258dd97c122b..78ff7862845a 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 @@ -627,19 +627,12 @@ int cmd_test(int argc, const char **argv) }; const char *skip =3D NULL; const char *workload =3D NULL; - /* - * 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"), @@ -670,8 +663,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.105.g07ac214952-goog From nobody Tue Nov 26 10:24:02 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 C192818A6DD for ; Fri, 18 Oct 2024 05:47:50 +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=1729230472; cv=none; b=qszaA70ofJTj7hnR+b2HkxfbKWKTS4MMNG99cVFitL+E6HmFc4EANJiqpeAXbW4gjsq/xIP7iYtUwPSs03EzO3P0iRMuR9qAUotQwCH4CHR87N9HauN6KR2cS+e28qm3Lt9G70TqvqYkRo3R3Ar186b6OEvXe0j3WzK2mw6hbU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729230472; c=relaxed/simple; bh=5W+gJCgn/iqQR+0OXY2i27BEZMd24fFR3rEA7huJPM4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=gGFP5INCCQHIPNsvSyePGy9/FhsCX5QsWxzyTNgJgOhrk8q4WkjjKl2DHG9IFILY5/pc9Yra+0z7tn07bCAgmSQjvdIjHr2MGrFARyBARWUB59qz09hkGRJhr1KYbs80edivPbreYeWIEzk64b5f+RSQCjG2GALJk6AZmqqJE1I= 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=gN1s6Buh; 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="gN1s6Buh" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e28edea9af6so2482804276.3 for ; Thu, 17 Oct 2024 22:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729230470; x=1729835270; 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=aQvCceMrlghIZnfCb5WUSYCrB9JkcNmVyoorIOTc2vc=; b=gN1s6Buhq8I2Uk2Pt0ZXTFhpmXxlhpxa6Ua/feM1LZI6p+e0fHwmqMM1RFtaPmQPTE p6ak36HaUDSOBD8Pet3lld9AFu5hwtDSm6Q1HoPfa9ZavqbaTmALOHD4dfQltGFY+T34 UBz0+jiDqEwVCl97+zKLitHATZPn950uKi0AygY+kEJ2uMBDYmIQFslezJB6S6NDTUQt ToE6UDaiPvMK1tu/QLymBl49YFscHF70MbqKME4LSxRTDiXdo1QbR/fBsifjinEoAQkh SX0BsR1eYf6fEynM/ujdI4uhrX5mzIo8ABNglP2ExUXNBwvC4ERTiSZ00Zf/eaEU4Nmu /hnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729230470; x=1729835270; 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=aQvCceMrlghIZnfCb5WUSYCrB9JkcNmVyoorIOTc2vc=; b=BIOcX/71A+4XZIT6tBKF0Kvj4qmvOfN1JqegsZvoeGlZzLsLjFZzFqaJOUPOe/GbJs 8vn+THoJJQkV/PFB8afzZUGMUJGMZdy/5SK73fvip2wyJHvG7B3fDb5ssEGe2HORqgyp n7CdEBB6EY8TX+9fgRZPF0mRMBW9KYJxuK/e8TzmRsbArXp8Oh/JHZOyblOynG/srik1 pnLJDUQ8ScCisg0FVxBZLay0y4CNSb27C286L74a/6sYU2XcHU0h5J+5DNWFUBjEv/VT UIcrxIe283ifJfEGwudhfR1Yv0UY/FZd0C1KE0WfcOAcsDqQWk5s9DJRuenAzIwuWwf6 /bRw== X-Forwarded-Encrypted: i=1; AJvYcCVL6kukvzpwzalgsdj/ROWC7JQfsieCc6RERF1WAf/j3f6/1ppsUTVpOtbjjTJ1JLbTCzuwE9kS47mYKWM=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/pyTAKZVguAw8FhicWJ+IQtE3etLy8SLuDa5s7eJw5c/oBBIu RmkLZ+a7e43XbT1NezxYs5ZtAPwdiN4+vXa7SgSCK8an+5SlIDiv2A9Muzwgf8Xbv/ZQgDr8TIp WtkOyXw== X-Google-Smtp-Source: AGHT+IEetzZbv6xKhA7Bjm58oK7gBLuLrdE7VQtAkXXBp2zVdlHbeXhsBPD8UPUb6aKAm0dZbINOr2lcVA4U X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:30c5:9d92:bcd:7977]) (user=irogers job=sendgmr) by 2002:a25:860b:0:b0:e28:f231:1aa8 with SMTP id 3f1490d57ef6-e2bb11b3e9amr3380276.2.1729230469360; Thu, 17 Oct 2024 22:47:49 -0700 (PDT) Date: Thu, 17 Oct 2024 22:47:19 -0700 In-Reply-To: <20241018054719.1004128-1-irogers@google.com> Message-Id: <20241018054719.1004128-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: <20241018054719.1004128-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 9/9] 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 78ff7862845a..c4b6300b0212 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -470,13 +470,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) { @@ -500,6 +509,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 @@ -560,6 +588,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.105.g07ac214952-goog