From nobody Mon Nov 25 14:56:04 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 95F1B215C49 for ; Fri, 25 Oct 2024 19:21:17 +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=1729884079; cv=none; b=IWN5Xvf+XWEg6XYEpnJwxUyleowb/Kd6FeN20vYUOf5RIJRbb+beg9Ffg8rWXhgCsj8ph/ug6RgejUe/D9jJbjm0406mdL+WILOVLzHk5b3J0jBu/+3A1sE7WTt+NGEoAuw5Mq48tIT8LaeJAKkgqxVIWEqWoCuiW4JnjUSeQSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884079; c=relaxed/simple; bh=k1wh2zeNE6tcCQX3Z6B3EqKklNoAQpiPb5SUkLK5tUw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=UHMf5prf7AventuPXPcuw8xg38RE9/+T1itdmHKwiGQuRUwdzY9UfbVRqej6beXwUNnMNE0+qoFlFWs8ZD1KbcDkBAF6XGQ/slNI6Mi6Vk+cVHV43x9ecc1yR/XHboq0Yyqskny6jwE7GrR1FuhaVBUXEjEFtgR65dq+Y28jWmA= 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=yFipmsPE; 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="yFipmsPE" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e3497c8eb0so29981837b3.0 for ; Fri, 25 Oct 2024 12:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884076; x=1730488876; 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=yFipmsPECKKbS9PTRthvi3omimis4iNVlWnyHxfePLTv4tAY7yJWueTM0CGSX2NWZt e7cbe1+1sJ3HX7mD08Hz3PlRgKgo9YniC9ekx//rGD9sqn/9DyPRh2S6FUco7a348ajP fbXhCzSQ8YuOKiiz3K5O3CetUOFRDDH8Pj1fyDMA6E/CMRlh/xMp/nPTJC5ybFS47RPD Gp8dWBF9HQcgj/IVZOQvm+RsgoAKlklep9Xt9vn3ROwABRgEMWUitR4Hjix3T/ciascZ 1qwTwns457veWJMXqavBMtUYe8i7pEoKHyYJBsxBVNlY2MrFHwloqCqKe4YkjEWSV2iJ Te8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884076; x=1730488876; 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=tZHEarJmBsBGjipa3N7HXGpeJAAVr+xmvy39Y/0+2FJbpaeyeurJ0GtaQoXD4WnuWb FzCsAGCidLL/6G5CYrE87G6b8ypoEgJjClRVyAG5VDv2cJ123CFAGYzSrxBDFmLJnFZM p7ZKGA94BX0FSEu9DtYpRuiIOa/QulRuntu70zeThahUktXizc8Zg5Uw4qnLjzGg4zg0 y1BUo040fO+zsI4vgxwIoeR6kl2sm/ok07L1G83t3H1NmTviSR2mOcSFdX1r0+oJp+60 KprQYPbPi1G3yvMTC1skARHluPf8TVhpN3XpMuPA+7xv1oVRLxteV2jR8dRIDwOA3R6o 3ewQ== X-Forwarded-Encrypted: i=1; AJvYcCVnKVTLEbyp3I46cqpNrInTrlYoWeScrEcDmwTTeUDbDfJBJvAZLdjV0l97PvBP3wnooYkI2QhD8wiwR/s=@vger.kernel.org X-Gm-Message-State: AOJu0YxaYp459qqR79sjdRwkT9wi6LpZ+mbDlpxbLQ4qKjgoxGcS6MGM HKPuHj/f9XXYOKfJrDNqt60idAdVankK3rId51SApfvP4Ctc3ZyY6wZ1k2B6lgtw8GnTamWSRUU gQl4sdg== X-Google-Smtp-Source: AGHT+IGBzSOg56Jmx0yqjJEBlMrue4ovHwcwxVIozmLEkd8y4k4vblAGd88JBuecj3LXmWaCDO2P+HJrpGro X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a05:690c:480a:b0:6e2:ac0a:8982 with SMTP id 00721157ae682-6e842e351demr3044157b3.0.1729884076619; Fri, 25 Oct 2024 12:21:16 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:00 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 14:56:04 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 ED551216204 for ; Fri, 25 Oct 2024 19:21:19 +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=1729884082; cv=none; b=paxcUMwdrUr2Zd6aXCOVLVBJOIizukO4xmMyA0d/kXSVZO8prAS6webDTpVagVhTvUuydLHlDsqDmMBDROGiv6tOVR3LJeNudy3tSXeC8z3Vo74FgzKzrRZkotjRm0MsYXx9oLuzdbWHkRQc3vm/QXprcuilEz/q03JKAiCUJ4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884082; c=relaxed/simple; bh=TSak5ySXPhsLutG7PU4Surkoqp+hdpOAqqLFfKer4U4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=dhTXDyx9QTy0hEeJYf9Ef49w/V4DDJq5TqRrRYmUpwgSDNNt73moBrDzC2I2oFENcan3r3XzgQs0It8O+deWATvr6lTBTve198W4qCIwB25fmOEfB9SMyk18YCL6xOFaIQbhKaeS9oJYY7VnQAw4RQDJb5Wfz9UWyUMpDK4sr20= 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=n0CM3qlx; 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="n0CM3qlx" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0b8fa94718so4608589276.0 for ; Fri, 25 Oct 2024 12:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884079; x=1730488879; 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=n0CM3qlxR7A0VYCh7ZEhhK5cQHXTAhT3zWBhzw8hCNnWocXZ6U4t5sPTpVfsSCKH5n ndFMFk/ZaLW059oVfdPcukUnVFvNfGlOHjz6rgFlfCB/DcCl+rUerGZxbx+0r+a58wJZ t5YSAqen31kh3mP7GfyfT7NP4N+hT+4tcU+l7atiM4CkFfpWIBDUFyV7fo9Ht9Zfn4lD 6n7sYXMgHHK7DsbNGla9MZjdHtpGbjUHQkUA3vo4u6Gix+YltvIZaD1gcqwMvg8YoHR9 V8P8OXUB5Ji13GbVf2AvPzp+QQ7zrxUYOnM/DunOkWn9vtJMDXq1If8dTqxqq3scpAMl rNUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884079; x=1730488879; 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=v/s5J6LTjYKLBm4kjfktCA6iSYSIbpiIWGOJjwrSnRvxwB54bQTXKD9obyg5aWpJDZ qevUL0kQoGGiUeZc5L3q7XgzUS+7wFJi92Pugbmurak8UzLKvbEQ+ZMiaC+ZYg49tGQX ekS5GSHNYWSBVTymeOCOo/hEPkhlpxP5nnFhO+bTz+Lm9wdXvwXWKKwwVLu6el6Roebe 5oqeNq8xW9p18UTHDzNxSzRvF6C0exRuIVHKDnjLOK7jkR1IJcGBXQxw+bYx9DbLWWPa 3WJbY4pkBSubnIwXmVxAYSQaaiZEJZK618oIZNX7Aof1jwHIeCvGyldjB5tDb7GVfB0V Cj8g== X-Forwarded-Encrypted: i=1; AJvYcCW7oCMw0KzOWZYvh7SqcCFihEJuNA9B8PXl8sHOEqSEcnEHNNVJEz6taXq1c7DmMUc2OMdt66o2dZ4oXW8=@vger.kernel.org X-Gm-Message-State: AOJu0YxijyRr8J+SYZ2W3bVQQhoq//JQiahyix7vEODXgQuIphPtl/XV aYBftyfgkq8l57j5dgY8sQ6dZPEBsvSE8nY5K1L3Gx3g6y+UhyeX5dqsDvlKOVi8yK2XE2I9tOr AMlPdZw== X-Google-Smtp-Source: AGHT+IFl8rpmB5FEi/EyN+kh7NSuUq3DxgF+xg/csv+FgCNCtMuNqbfN+F6ZnzymbET6RYToa4IrWf6THyTU X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a05:6902:4ca:b0:e2e:4391:67cc with SMTP id 3f1490d57ef6-e3087a65968mr2038276.4.1729884078818; Fri, 25 Oct 2024 12:21:18 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:01 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 14:56:04 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 EA404216DF7 for ; Fri, 25 Oct 2024 19:21:21 +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=1729884084; cv=none; b=dMcqmMxqrqlxfuyeIhLyL+yX3JmYD4SSmj7E7zfM4viZFqgmhJCcjV00PLEYlO21jGOLFr5oPbxwjo0Z44sPTtE8ZS2HjSkdawGNVcGUIAMeNoielsXK5rydPXKiTQn0XO8P+nrkD6dDtkktU1oNP9J7KRhxNiqgAgrWvRKKpGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884084; c=relaxed/simple; bh=bl0TwbExu4G349NNkk4dquZriD14f6vKBPjGiiViYyk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=L/D4OTL91l6J76qVVZb7O+9j9qxtBLLas0wtN6e+jQa1cHbqIzrL2ETok5KDDQJ9cvhTfueb8v43TdGBt+rnR+G/i+Ohmx+kKJotNw2oaz+XYR+rTjUCPXHbagdFP0CpPYMsgN4d6Wyz9l7zr90wY9cHeyw/gsZOTF/KMYbXtyI= 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=bpjDkPiE; 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="bpjDkPiE" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e38fabff35so50217537b3.0 for ; Fri, 25 Oct 2024 12:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884081; x=1730488881; 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=bpjDkPiEVbqldAK7qFtuGUmE/yqWjEGWL06+Z6X94otan2KK31U/gjgQ1987Mo2bHX MQ/WWUKm1MPk5BAWyBo7T4Py5lbcbKnF7FSHiSl+dyidozDaWKKjR7rXvPDjqR66qj73 3ORiXnSrTQ+OLAuy6IFF2ob5TNZWi34wjqcAwKDkDhHEX7lhM3Rc1Mxypw0peR+jZZRy 6o73/inlcaoIwSIl986YbE/qqLVFHagYhE6z0shTUH9xap9e1Tw5g9WjmEPKpsoNRzwW rZjJL+gvQRvb+oOBoIqLvyKDeA8cwYFnm4pmcXTqdDuO/q4dilSxW4rAVnUNw8s3gCUx OjOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884081; x=1730488881; 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=nr5wEAhLdVnnArhuNTK1oIqVLukNz0S4qIjkcKcDkYGpcFg9AmjaP7NbXheI/V6Uc4 2d3ltbMbyQGZB8Vg/bsOj6ocu9C2HCUeFem66+LrN65UgMQxvlNGYL/wXKuTeYlnrYAK PqNfmWwLTxBxwljozctVOGWwWWT+6wbA3IdKn6ghgE7ChyT9GznGmjm0stpF6Y/girCb XLZBRw6vLrZywOgEIsRLujxqfTrN8DMOFOwgVZ3dK2hkRZaBWLdb3g62I5XS0CM8OcVa Xr1Z7IkKBPxl/NxXncvs9fdb06U+f2C490Sp9EYfJG9Duj1ADD6A224CO9rih7Glpy3z GrTg== X-Forwarded-Encrypted: i=1; AJvYcCUCSRd0qAwQlt2JllozMQp+Xu1D7tUQDK2nnw/TC1mAwMKuW/07Zm5RbMPpWmEAjRt27ovC7Yx88BlnXus=@vger.kernel.org X-Gm-Message-State: AOJu0YwWOB6hk6olavW0E+Y0BiaLWnXA9nJL76lpB49bvm6fvTKD7Xks KQ/aUiXsnW95KmMFlNX076mTD5cpty2QcxC36bdbO67Dx5FDCZ0NARkwBefVYoNtfZtaYbfoP7u iHuHYMw== X-Google-Smtp-Source: AGHT+IGD95Dz7s4SY58TIPO1jaSqaYOrqZkpzNst4Ej+pMqlACgZPWYG4A3kUs+EkUUpEclRsAV7/bDATl4y X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a81:be05:0:b0:6d4:30f0:3a74 with SMTP id 00721157ae682-6e9d8b5ed4emr165137b3.6.1729884080901; Fri, 25 Oct 2024 12:21:20 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:02 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 14:56:04 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 5DBB9216DF4 for ; Fri, 25 Oct 2024 19:21:24 +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=1729884086; cv=none; b=YHyJR3IwHr6izCqVWAVvKyJZtPbL+njIf8RU3Vp/NcaOeCMnGIS8q0DGuyMad9wtlyntFeIKAs1h/+UhzYrJlicY0RNorcskK7cR7i8GTEJe27M42G0isRaLzYMdFlxwbKp0TrXPIMbPVuCnj6WmN5Hv0LZpgbRXZY8NQDGIdHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884086; c=relaxed/simple; bh=0odQGceZNBTkUJ7F9d7VELVpW9gytwTlwU17UG1a/+U=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=L1tNzQIVjBHWlJBY6p5F7kyA0qmcXPExQ3ecFUYxPZbbto3JFlKqS34V0EcdP1g+TZ647OfpNauAXx8VdyCPdHFulyPZgOHjREaDIdjufBAw751TAYlpEW+1Bp2/xNAfQKF3tRluudt9QGsqeLP/fixyuSqE50CPteW9Acpj18E= 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=vwTg0X2D; 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="vwTg0X2D" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e35bdb6a31so49412307b3.1 for ; Fri, 25 Oct 2024 12:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884083; x=1730488883; 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=vwTg0X2Dx3kM3d7SEgo5910+l38O/XPJLu6TpS9i6hs8RfN+PTGQ4DkfdvmFSG2gxG tSAt/AHShbJ3mrMQah6U/B+M59GnW8q0RcQqnNqaU0qEnl/SBWU/ZniOS5Dsyzb+cpna g/q5MEEdehEih/lHTAdJSc3Hi32DzW7yv5OS/2XiOUjuy1B5eTz9JHZQR76LzHQpGaiq SkQ2pWA+se+LJ8B51pyT3zkFYWf+Gy2GL1MiCuVCSDzV+B9+SLaxeyDP4NSvM/PcDC3g xrPtje/eUNW+TINVQvlxymwaOVwT/OI6pWitTY1ZJLdcGBvkAe4o0qNxsq+0/UW/Smm2 JDbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884083; x=1730488883; 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=Ua0xz0iwi8pP1qEYra77P+XcuRh+KH4nxQosf+TXRDpaePpJoc/BAcy7fTdB8PnqfP 9hFg6iTuZ8Et+L0me9epCFS33gx5WV4ogEn/osioVq7xVN/4zr/zigY2k5fEvDm8mITq EchYp20Ley3YDZ3sF4meElNMHa90L0T5s7X1Kons5IbchJY65LS0mHn6MMgqbovhx9g2 C60tvgHEFOqQLKlvW57zmgzMqTYP9hRZEtbl19pW1gWLN/jb1RV2MatvR7m4UeI6Ys+a xmV/D9xd4ubX+759CNLLl9CR6d4EBfif2AnlrRiFuYRUMhcPhNiXeQMfZwF/o3/QCVwO HNDQ== X-Forwarded-Encrypted: i=1; AJvYcCWBYTSlW+CzN2qgNezHcC/t9GGZRopOz/xRV+73tGRAXUw/zUuMaK1QMAPqee/HOFDCTemkUQg6TrsgPk0=@vger.kernel.org X-Gm-Message-State: AOJu0YyMRnixsqhGbBP66UI903jGHWCnt/mdDiw53L67zk7lsaKL6OnG 2xhOFkE5D5fYqagcoqaLb3EdQbKiYHcE6rUiH4FS//lRliK7RUtbdhuBzZFgPOjhn+z2UaJvBBf JMiKkVQ== X-Google-Smtp-Source: AGHT+IEDZ37DkMt6s0xwoVnx5Qc3MmUwVj3yXC0V3R7p+RMPNg9WUZHCFkp1OfqIxCh3LV7U3y3jFq6pf9fH X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a25:b311:0:b0:e2e:2c0c:d02b with SMTP id 3f1490d57ef6-e3087c261c6mr223276.11.1729884083287; Fri, 25 Oct 2024 12:21:23 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:03 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 14:56:04 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 9EE4A21745C for ; Fri, 25 Oct 2024 19:21:26 +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=1729884089; cv=none; b=FkmVNZOCQzdOtHQFSoViMO22t3yOiYK17VATeccIMYg9ulbawshUiW5TNAdpSu7pq58kIcdWPukjyhEIyP7hoObkNG1/hrP9XMLbdrIRfWkF9EibA/N9MH/6bRJnJbcMHWDORHrwkSnWWRwQcDWB7yCL7yKBvWCGHbAUHscGE28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884089; c=relaxed/simple; bh=mzs9bpF6JHwXJ8hIAxSNZGhb19FZ05kQ6DmUcVcuGGM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Ykd7tTJU8CxPnZzlwn6z6sUd9DipBjbeNtbjrRD0G5aOlhASO/XI8byJodrJtTl+qzn9AIsxsJnXDxx/aHKcCiqjxCTe4bwXyXfDhbjGRfnfIzlQFfEW/zi9EzEawU6Faq4ICD+2bv6CLuKL2myMtfd9MpaCkOkKokJ81f28Jvo= 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=NcgnYA/3; 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="NcgnYA/3" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e2bd09d2505so4156654276.2 for ; Fri, 25 Oct 2024 12:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884085; x=1730488885; 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=NcgnYA/3Juf9l57FEfSHaupB6r7yJ1WofpndJp1epAZ1zBPjhIPpP9kFknLTsZC53Y oL6GRupq1EMtVxRe3dbcmZ4cHgOE+UIPEMQtnvBMuzVBXGARTx367Kd2I1x6HyvnUcrD WiL8cSaAi24+iq445eoARIKQPwdn8g2SM6DBNk17dk2fIaLCXIOVJv/UpW9u+VLpipfg FxdDSJFnetUac7I3eMRDG7B/kx807P34mXzZn3lbMJXGE+PjtnM2ssp6+pLnTKP/JxDd ovdJ6fz002zl8P3WWvVzLVP8SIEbWMxZtlzifu3hSYPhxWPy0ySYpY60azda7PNAZ6l8 A8mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884085; x=1730488885; 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=sW+fa1dkyRF5Vk3npipnWjgL4GckjbPnC6rVIdo3j25NYO9Xtgh3FDmTPMSW6vWQq2 boNVz2PN/Zin4BqJSP/39BQfvo4VAOkYyB8jzEHtlfy2sbGzJaHT1iHbM2PqMxdoZgMB /CwUWF7djMWbTxtGh6/hjMdtG2MkzzRJDeUNpMKie3XLvqUXyg9I7i4YFEKUy6CHeOKU MadEyYIOIKWY7ZDnt1nmaXCBvUTz+eu0cLP5QA49dM3Nsw/iPNiZQbGyNfPKqBzCEOTa sTIK7QMAqJTSvx1+YVmCOCqVcVOhCuanExSwDFm7mzdF9hqDde2I2lXQkF5T7RSF3/m5 ySoQ== X-Forwarded-Encrypted: i=1; AJvYcCUOUYzajS+5/XjrpQpAmPCMG5R0cxPASVv+w+qIAPp4fPYIWjqt4MKMDP0a5DKBQQnCCuC5om6sLSStdyo=@vger.kernel.org X-Gm-Message-State: AOJu0YzYwGM96s64MJkn9gsLQLw6P+zMkoSd5s5chUbllkYcfg8Pvxml trT7RyGJNs/kyjK3yM5wJeIQBDp4wZP/jC5T1pyvMYlm4xPTHpNKTP40Bf7bLPTN2ZTYO4pdhmD TEqagIA== X-Google-Smtp-Source: AGHT+IEnw8haeQ9wUAjCKqC8t93R1ErRMfQsitXcwNr1PWhvoLWbGojMxMcJ7lpNL7RulRdemagN0JOXvJU0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a5b:201:0:b0:e2b:d099:1a7c with SMTP id 3f1490d57ef6-e3087a548a1mr279276.3.1729884085319; Fri, 25 Oct 2024 12:21:25 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:04 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 14:56:04 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 BCEC5217644 for ; Fri, 25 Oct 2024 19:21:28 +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=1729884091; cv=none; b=R2VzHijH37Sx3Gg0ouZEwe6ThaOfCeh9azrSJ6mBDxQWnOOAk08p9LLrZ2PH1APQX6glBcOp6QeEkpCGU5sSvPBDTmysnESGoj6Q8leTKjgyn4Ty/hDxY/viMbpFtZFB9zl8jzFLxMtN/TcF27CG/oL82yI486hIXlH/86iUdIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884091; c=relaxed/simple; bh=6/uo9WKPPestWRkUgwt62AoatZhqYZAbu5e4hou0/hQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=OEDCCKWkUbQi5FcixfKm1M6IgRNwCSVQ3whdQlddjex9mfdG2kwogD9TKq/hzo97azhRrO5mm4nQ+6KRVNZEZQTbAB8l6hH74GpxceLV4Yaw/iu2AfxssFhG+YF/OVicLbPAWsY9CIMrjivFxDwmamd4TOT+CXaaaPBEN516AKs= 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=w8u7W6xd; 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="w8u7W6xd" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e7e0093018so42694447b3.3 for ; Fri, 25 Oct 2024 12:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884088; x=1730488888; 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=w8u7W6xdbR17SQkwDtA1nG+yClyFpgnawzBRna7r/Lksk52OeL4zVqEqeqMZXvyIfI kDnH3MHFbxfamzqbFHeUJJmiXqTiNqN2qsJk8iFzXivIJjNTS9XFMf1n31NCzwEWpEgX PDWMfNt5Ny2AVeR1gI3RHghaOo5kVNrkjHfLVcZRCVuHsEgFO4v3vNQr2HHYQC3ElUsf hlcxIiNEq293LiXEj9lIueqpKqKNSlgpasm9C6gQWPGrSUQp7BJ8b8oL9GfGoNCDy5mG OZOztw2EP5JDMK1tN+PZnXY3SWV6LSnqNMjuWMJaap0R8H2W+UKYBVeN/3ZAzkzk5IQq VdSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884088; x=1730488888; 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=TYnl5hEPr/8gIDOqz0vpa6eDVC5xmXSmzGH+lyEbBHgXRUx8dGiLQAqa1WILZsXFfQ ncmPcLwf+jyhE3LugW6CvSsg2x4ah7PB9+79eJUbrhYZLkzOXNR7l68JqM2RpsQoyx61 iQKS1AFxkk66/CL/ymwBmoeScOXHRUC5qPXpKklk9/zq0IbrQP88dYkxfSN06bY2rTtN 9qwRi8WJCMnGpXgjno8DIOjwRoFtPEVjWJJtxpMo/5g+ZWopLZSbZR1biYphesvPXV0r 4dfLpx2qQ+bAWoqETlyo56Bge1TQpebv7HJHbm17Nwyh/dWUPUf7dI0Fa2Vy1GKUigGs MXLg== X-Forwarded-Encrypted: i=1; AJvYcCXoX01a4pk5V6tcFn6NMf20+NOCljlyRo25zq2KraImqaJeKeYaJw0ufRU/4nWuxiq2YA+mzybav88MCyM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxzm0xc1qEOJ9RrKyrjyuRbNDp7W6uDM7hMsFEwDP+Y0YYC4mYW Yp6s8PZYCR2n0zJLPlz0RPVF3iHE8OCKblnOwBltW8pHxXI3vHxbJvlXlot6s/0BzkWN1kImgRE 9APxJoQ== X-Google-Smtp-Source: AGHT+IESVMuv1epsLSkwRc7et6XBTVDRIiFvKtPLgYRjxZnXzGz2p12sGQhNRFH3RMqICzEALMwjgUKG1WUu X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a05:690c:6686:b0:6b2:3ecc:817 with SMTP id 00721157ae682-6e9d8b52a7amr218967b3.8.1729884087794; Fri, 25 Oct 2024 12:21:27 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:05 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 14:56:04 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 564C121766B for ; Fri, 25 Oct 2024 19:21:31 +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=1729884095; cv=none; b=A/TDUKrGT/F26MMB0A3ABXIVaseb8lOjR849vzbuqBmutHIuuv781wd3PISE90vTzSIEbCkcI0Dv6wZQlRPa1BG9uKvV7AopRzVpPEuPq45oXuDd8b6gG3HTJ9/2p5fJ92s3K8Klh0mb7itkzjU5v6qQ4XJRYDaJrTCmpkWo6RY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884095; c=relaxed/simple; bh=h+S7lvjznO6aeDproo7dQHdVN5YR74SQ/ZENnLj7+oI=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=tWGdUA+p3j2MeECFYzYF7n+5R2Dpo0NWX5+8FNsm7vKlTisiUYmSenuKDmWM3oSi08dHaXVoDQ6W9L6Eo+dkfWaR1HRqr2VODoxctoKdZThdKvWKxqv4fpJr2E0GOzQpXU3VnddpbNsgKHhLkaNlm9ueUaMnvVpl8zsdr8SaS2w= 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=Z/2NJzFM; 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="Z/2NJzFM" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e389169f92so46599827b3.0 for ; Fri, 25 Oct 2024 12:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884090; x=1730488890; 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=Z/2NJzFMVCyuuo6WJokTPGjAF1dE1O9FY74apfMdaH6etNJO5CGZevs4mJ0ofksoB1 nQCAwrSMM4Crd2T7FUmDFuTo1FCDkXpkI8NYvg/ZX6NUA8cY3iMvLJIn5xhVPsiFnk3B c24hyinEziQ0t/X4/DmE98HCDslZw3ZBBON1nJyEoP2OnaYx3fqtPLymE1D6IFRwEQYD QuIs8VQIh0CzXSbchgogxJkbalAuEmlLGWc1wkBGmgM6A7C9y8xTJsxaBAmM5SZ5rdk1 kQHIZ2cq2OI2RcJc3tn1rqN1vT3ArqkUAB7bFHV7lV77W10H5sr2udqmpFTDo83+rchm ZLPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884090; x=1730488890; 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=IdkE4cWAL6sWXNsGaP5RbwdRXnpBSXZsQml/GxQgEr962l1gnu+aLc6rOqrba3+cj2 A8acrwKdFWplaUd3n8DmYkqYMuCvLvdBdEHy9UMf0bgKG3caU7STRolQ4sezxu4JEH9V ERSmw6ouFfr1NMuT5yZbF1V1ID0qTcHVkVgf+9YFSuPacFEL/xNBUwukXcZ85KygugQP xuB4CfwMLr+SZzCQUrdj/1hyld81iJ0ltEmNlqG/xjftmnT6UH/EXjOT4o4Hf+QdXTyv KBLlb0xp1/HN3q1oMrvBhA4UID6jdvJ53jhU+j4IlWyW4qpJfwADDzkkCFsrtx6wqVeS j+0w== X-Forwarded-Encrypted: i=1; AJvYcCWdw7maNRg5PfozUF0d/XDRre4n1WCbBdOfg56qZ9K1N31YJwsZ9WhaqepXFVYVX87hf7NiGhgn5GY7ltQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxVp2b3Ax55jpOKFmZVCdm2rdI2UX+vGxkeQrpTFzts9S2RvQKr ilygO37jVihPtwIbeS0AvX8VD/Hu3eSKN6nvFUwDFbdlkr26zwGf/E8exNKSkYhHyGHSYqUrwNH 9/qIW3A== X-Google-Smtp-Source: AGHT+IH8G1Pejx6BA9vj2hHQprjVJkFzlmPXeUNJjxk0MlQSSdot5RN6IZXIER8lTdh7cURruQowv1cmZPO5 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a05:690c:6283:b0:6e3:da91:3e17 with SMTP id 00721157ae682-6e9d88b0da5mr91037b3.2.1729884090210; Fri, 25 Oct 2024 12:21:30 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:06 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 14:56:04 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 8B01821767B for ; Fri, 25 Oct 2024 19:21:33 +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=1729884095; cv=none; b=KtgNIBtlLDKhfLhqw16H553RYoGCU0j/ARD0aHYm2PneAtSOJMne7vaIVaDfqe0OYNOI4wTmmXTmAWUtJJarl9tSJ/Fhxskbr38hkEy1cpbd0lg6kiqfX9dPH0DiESEi2WFu/Lr41SxHO8/rNuuoJcYSS1LZqjCN1Snfir9kZ8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884095; c=relaxed/simple; bh=M0R3zHDAes8blHNNb56eB/dYrJt3dM5C0cEG6y4au10=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=ByxKuPbg+ZoiQP5pUHEPJaWaY7YPjgZZgK3CAcg9X5lB4YxbliA5bM2qTsJ1xLmWpu7bOuJ4Do09peQRMcLM9/DWrwlOLSSg/hyGBpJAvKXS5UvGC6cTm1Q/g+SXe8oH/vaJRJw56AlAKwcXvVhCmdIl+ntHiFC6SMryK9cmSR0= 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=BhxcI1uS; 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="BhxcI1uS" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e29135d1d0cso3904602276.1 for ; Fri, 25 Oct 2024 12:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884092; x=1730488892; 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=BhxcI1uS+vhJyb81zgOgyRIi4fp23e5Vr811vV0JtcQ1HmeXjPDdRJRvCEq+iMVA02 Dg+xPo3x/QHmfMvDeKbXne+46Hl8OZs3rJ4LWWwh0zP3lsG57Je6TWoAPgEA8By4T6n2 sJ4mL/TmnPe71QLCP15adnhE0v04bwbf7TMNsp5lGhBBkk5NQ56eHhj0qbXyVDuAT4Pl Rbr1HWWUZaNAh2YuVJBun+pchjfH7VkFtT8fnmEX0Ah/mXb+11PTI/gGzyn+e1YzFTYs LdQy7nd995to4VIBYUpjWrAdDuJiwRQXhBZIOSazyY+Dy03OSw5ysR4vOwiqZWdv1ptP 3yXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884092; x=1730488892; 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=NqB6cdttFr2bXtfusphhv7KpBnCRSutxsdiV/NKlKp8BV3OYFGFUeyqEafnpR1Lyc5 p6sg0MQVqavI5hScBJmN4mjLdDU2wZ0L1dDkEjvpDp+zn1EUlYoBG+QIFjDFrZ+0M8hY pxedjTDC5LdkWUKdosRCutsc2dLM0Bf5SnhBoxn+tHwV/a81DTeR9IsHEWRvEjMK+56Y BaFJOZvpr09k4GHDPGi2uxQxf7eWAQtmXO99aUNksI3gAQMdW/EjDVlUXWx+R12RcTKw zJZrFVV4cBcv9FcQVWng/AvZ0b3KI+uuEawGwZdtOKC3lnuQnbt9lXTyzG1kw9ZunCwk yw8g== X-Forwarded-Encrypted: i=1; AJvYcCU5kioXmJRmItvao/26QHlomEx/ParRwYDc58I1DqgHc5KeRCbQjJN1mXz1w/0TbZJnHyzb+td0pxhRbYk=@vger.kernel.org X-Gm-Message-State: AOJu0YxvLS0WlsH8KSTCXgd96XZVqWWJjRBPjZ6OG/oXKQcO/jbvq7SQ vnadCU+BtdGLhfa1/JhWJGTA1LbBwuR3UvEQtoY2lzlFwkQv/kpKPtdBu4/LLYYKufVU/kjI7Lj 4g+HjCA== X-Google-Smtp-Source: AGHT+IGJEHY3lpv9skwMpXCghaw8mJEpvCc8FiYb+27sBIOY4jXADQLseKXwEZ5QTsnNU11tYSiM5O7qKwV7 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a05:6902:686:b0:e28:ef6f:3624 with SMTP id 3f1490d57ef6-e3087b82cecmr276276.5.1729884092472; Fri, 25 Oct 2024 12:21:32 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:07 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 14:56:04 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 6219221893E for ; Fri, 25 Oct 2024 19:21: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=1729884098; cv=none; b=Mpbq0rXwPcBBfwnFcNp6zvCuDVPl4ff182d0wjdxm8ozGfZO4mCOa61Icbru/q1ZPVDYTOh7uSXsoi6pV4U1iSH2a59aQiwYRrebyXbValYQuzSnTsP3mCAKZ0gUFn2Bv3DrgdF+SM5SP2dFf/38+bP8/xh9qkz0T94pOPLFEkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884098; c=relaxed/simple; bh=ghMU9Vl1129d7aWePglqRYfdFpvshxaCpGvdUmoT8T8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=qJlhResgyW/J5KZ7mGhU0ul2oajp9SpDuUueYgGGi1cw0fbxoTeHNSKR9WkvCQZBTmON5edju8FGtBETe1cCON2qUqgTdRM+044JdS1TNvkii3yJ834ZuMMBDOahLIjNok7AkeWtOwwEIshHCIhuSLCu+jqwoPO6f7Erp+5qcJE= 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=MwpLy51O; 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="MwpLy51O" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e02b5792baaso4548964276.2 for ; Fri, 25 Oct 2024 12:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884095; x=1730488895; 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=yEEHJhH62aevzqc8qsynaFFtwxKyovj2FfawNsxdzTY=; b=MwpLy51O7t0LbkS/BCrW+ChfTWBYkWWXRnp9DHnn5xPBx4KPL5uAX1U3RTnWJUUyB/ 4jwr8CeZkQwgt3ZzUWmflbJJqFOGbJ34kyQ0xNI7Cp+Ryi02eC3zk2a/Nhx8yc/boc9p BbOWa7CJMzyJHUg4g80tinIUJY5sslmLLky6bWh6K63MpUjWFlLswROiIu4hBzqq6I9y GjWMnLatXJkicOPM50c0tg+80vg3jjJQNH8F0z6RlSPqDBft6H9+P4LZKQtqn9voxxXm 8/OduGo2gwm+k844fdCveLgtI0pxqR0SzBl29rTQlXbuX+CrXLnQt/vGsyNxaWmf8yKS iMMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884095; x=1730488895; 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=yEEHJhH62aevzqc8qsynaFFtwxKyovj2FfawNsxdzTY=; b=HJWNV52Ep2xDjO68uK+daZ9eMy1QC25oy3eBBYndDTVnKXPVHk5mFSk4002r4vLvsx n6yQ8sTBLdA/XEoiJbjESZBG7f297MW1DWUCIcX32GCH5eu2hs377/cG8pmJcGS6wcJs 1CEiQMDXaqZbww8Snvs7/HzkKxibscM8crF0MdbdzANBZwmb6KPoKZe0/wMeAKJlEffB OwGD/BL8Ho+PuPdYdJKQrx4afpYLOs1U6fkIx0P2ZLFGQ6Z3KLoxQ5NbigBobwK2CN3I XlT/TL53L+QRSOqVzGQrSrotKm6SntBn9Uj1y0QpMhj+/untmoudr40QKZtdpL2G9Urq tQcw== X-Forwarded-Encrypted: i=1; AJvYcCW4ySQKCNoAwKonQDPCc3f9/rAQOOpNkvbkh7KBakU/0RLTe1qIa6vyHDOmyW3eCrq9ssdHYiCYprd0mR8=@vger.kernel.org X-Gm-Message-State: AOJu0YyQlDwTzyDFj53/+yp2AxKW0lmZQ4oMwmidv8bWK3GtTodBP1so Rws3Bs/VLWux7Taj2GOj39nv3C00l8A3NZK4WUgqAOFezQH3uJ4PaHgC7tzPeyBjspHM6VdP07k DibyBVQ== X-Google-Smtp-Source: AGHT+IFVYQmqkhyHSys5ICdQO9t19XsKgLF71YdqD9HgQlqwwWQFFEgJMJdd1H5RXJKM8uyKH8UBMdYA9gd6 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a25:b28e:0:b0:e29:6df8:ef58 with SMTP id 3f1490d57ef6-e3087a5bd64mr3201276.4.1729884094762; Fri, 25 Oct 2024 12:21:34 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:08 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- tools/perf/tests/builtin-test.c | 37 ++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index a0a678facc45..2f880f48cdc5 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; + static 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,26 @@ 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("\nSignal (%d) while running tests.\nTerminating tests with the s= ame signal\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 %d pid %d\n", + child_test->test_num + 1, + child_test->process.pid); + kill(child_test->process.pid, err); + } + 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 +591,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 14:56:04 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 0099521B848 for ; Fri, 25 Oct 2024 19:21:38 +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=1729884102; cv=none; b=k2nG5L3qXA9sKxovmURv9cVknYw7sm0MCJcXUAXXj/7bNa3VJDcpgJnuKE2tr39OQSqGmUh9ITi+nZ9+0AfZV5XP4iN7IgkQa9z0uxFIfqabI6hwBWrC/+jPReUuQyltDWi8+4mrKeL1x4LK3gUTgQ0o9WPIy15OlUVV72zxOvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729884102; c=relaxed/simple; bh=rNAcF8wM8gvz4H8uQaNqviqYDP2ME6uNIt9wV+wjHHQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=C2J6Jiumx9yb0Ip3wsQ8GWuN+gB3po1RJudZW4Cc3jQ/Er2cQQpxl5uF0N8A+eT0++nIkOkqreFwUYblQYllOAIOSi0VgbG4oUNekIJAWYfZvAoUnrfMa1zujPXCC5vJXi61zCz6uSPI7aVARr93KwogrXLADL2x8RqNFj8h8vw= 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=2HBFvx0v; 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="2HBFvx0v" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e292dbfd834so4162808276.3 for ; Fri, 25 Oct 2024 12:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729884098; x=1730488898; 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=/dxz2W/8vDBHa448LZ9Sd6x6HeOGt9H5wdrppWaYtKk=; b=2HBFvx0v8xJCI17kERjyrZMzHpPctIb37U77ct8HhkDj+0YJ97Qo8Z6sOxHXPZrTJ8 ca834jwrKT0dwAac7k0vj4gEyxRVfc9wor2VFc0lAjXKQuDBfbcSqiyuA0VYSqPUQhQw zmtHSXha5QCh+DETmk3W92DQme6WPoroRQsF/2VZdwGOMfiYXP8rUt/UCkydHAaybL31 BxPP4fOyQhjNpEVFt/zTBvE+mB9eAXne2I86Dt2ycOeCzgZmeqVjxpn33+o2Je5+JvJQ p8o8VMMnSRgRrR2KpXF4DFgL6nO01F/iKBHkr0OCM+Ie2hjP0CYu9clQCbnNo8kPS4WP zo1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729884098; x=1730488898; 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=/dxz2W/8vDBHa448LZ9Sd6x6HeOGt9H5wdrppWaYtKk=; b=PvGJtpzOYrbiwFLWaR5Cekr42B2FZtC9qQ27pwFNdep/CUn1u4sd3cgTeKOcJ/4eVZ lGlDXFYOPrq2iTwXw4Js9SETSQVQN4Xp7TqGj1Q9ANVyyEhb7orHNvHvp5NNdA/zKsx3 XBLaS1k9LTClYFWX1TVFER4o35AI/8k854faF9/VgQ3BhaWCB/Qyx2gWOdDGLPCivFq8 r8z6VcbLr7tmIXCHLFo+l0K9unkJSmAUiuBKh6cZv+iUqrWO3mMu7iGiX+yMcUIkS7sm AwioXEcsaYWnjFoUllLyX0Z/JPc9nSUr6swwZ+T1vLGJyyqBexqotgqnYf4vT0yXN6+0 J2bw== X-Forwarded-Encrypted: i=1; AJvYcCVRgMdwvVjeflP9S6WhLRJQgDER338EiSSciiQdBIo21SUPNpWYbuqoQ1Ua4MbeJigJ/PwnwWhHYUPTUJc=@vger.kernel.org X-Gm-Message-State: AOJu0YxoHqR+4qbmYIjMeaqauSG6YOhko/apHM101eBJx1K5w8koN9No A4z0BrQMuweD68UYzU7PF9VcNFQPpDRW1jFix+LYGi4fy7j5WPbz0q1cUNo9P9pKS45d71n4pbm NjoezQw== X-Google-Smtp-Source: AGHT+IEUKi5wV3YEZPlz2DurrhYIqR/SpWkQ+hDi0Tx37uRYxgfi+MljIzUcCfqShJ1/JNUl8DrAvdnw/RfC X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:5d42:c43e:5e08:3a85]) (user=irogers job=sendgmr) by 2002:a25:c78a:0:b0:e17:8e4f:981a with SMTP id 3f1490d57ef6-e3087c2d8b1mr1832276.11.1729884097267; Fri, 25 Oct 2024 12:21:37 -0700 (PDT) Date: Fri, 25 Oct 2024 12:21:09 -0700 In-Reply-To: <20241025192109.132482-1-irogers@google.com> Message-Id: <20241025192109.132482-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: <20241025192109.132482-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog Subject: [PATCH v5 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 Tested-by : Athira Rajeev > --- 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 2f880f48cdc5..d2cabaa8ad92 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; static 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++; @@ -540,18 +529,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; } @@ -561,24 +550,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; @@ -602,27 +591,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; @@ -661,6 +648,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 { @@ -688,6 +724,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; @@ -697,10 +734,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); @@ -728,5 +768,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