From nobody Wed Nov 27 10:45:22 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 4B47120A5EE for ; Fri, 11 Oct 2024 07:36:17 +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=1728632178; cv=none; b=ee8vt1DULkvbdjB/dCGJMUXQXYvJ56oPqQ3AO6SypMARLQ0REIpKQzacfv1uri7m+rnjQuW/D3rudhcpc7hG89gahtAWy3uigbNORvb3YflD8aj72dyV3VtUUtva4ad7xm6uNKybuXqumvcwRg12dTmZqEKXDQMDLIeZK08l0eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728632178; c=relaxed/simple; bh=SmpiIpnUWYoiRCYzpyrD0v+faU3GRnHg9tc37AXmxqY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Ah5Utzc+jQKUIofAbe11+Jcr8ARCRSPe2fYQh39MsgnRJMsojP5dBgXaVQ5w52SisfJ4EsJ4SLy7EjMizcz7WthhdseY4372+tVUKR+xNpgI/iNaAU/LvQKzAkfDi5VWjo/HnjktJoQrBBBhltM+55l0V4Jcf44uEFhCLCJ6Gzg= 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=YHEOXQX4; 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="YHEOXQX4" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e2b049b64aso27390697b3.3 for ; Fri, 11 Oct 2024 00:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728632176; x=1729236976; 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=UTikmnLZHT5WgNcn9pW7z+UTTTWWWy5CFH/F9nc3UAE=; b=YHEOXQX4p+C9eHbWzHSyzy3VRrQmCRLd04vwVT9JoZLGTDAB1i5ZtQziurpB+Z2TTR j43AcB9Zgi9WTt7zplJpSmuh+rB1i3xGpzUIt9/rLApdeNMpKALuAISgntaSOEL1MB5h jc1q7cjaLaM2w4no3VvRyK9PGtwLeDYiLxsYRcihbwwCe/yrOgLG1vlSB7uxw6FaDszS qUfV4wujfhyDYKWvCsToHe7DUcd7ldTlP5oWXKdTP3La9epFh/8Ns1dTrp777yQu5dRr DrhmVwkqJGAGhE+pzesjXc08zsbwND4jCFIWnZSPFNXhfnVTX6TOkDy1JUMr5RhYGQIq fgTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728632176; x=1729236976; 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=UTikmnLZHT5WgNcn9pW7z+UTTTWWWy5CFH/F9nc3UAE=; b=T1OjRoLrIHxgYXGtsEJGDv1usuquWEu5wnh+ZHlBpMwxawrP0E8I0iesZA1wDHUy9h QBA5HmUIxt3w/HxqdEsgR5jaHCnBgUyAuD6ihU4/OHY2zcfn/6QURp0ePhwwcZiAJemS ovBLAZYqf+UPefn3xsJ92bE6MJvIYAGGUI5pnAXCY/mRYN5W8DQNouf3Kkiu9tT7ysHo 5jWnJSofItrAOBc9XDt8kcdUott1yvbSBLtvRkk1fHblqIXaobU7GfRWjHuL64W6R+5w F7QSrU1b75hh+fJ8ANQLjAB/F2X68TkMoHpLTjODx0s/RCe6RDq5IbL8pSDS1qCSI++p elEw== X-Forwarded-Encrypted: i=1; AJvYcCVHHUNM6XRx8Qvn654WYMEqYasRyAW1kBJg/DsvvUZmaBFDgiT6S2l2PL/FiYPuINGDtBz0Pn0113/VSUM=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4jNDI2/7dLas1xTNJWN/x36fAApFAjgjKRbw8HZT1gEyI1yKU /3vhQPZA3+zUJDLLM7OUqI4CHQ8j9ivm/qsZ/EI/TuTJtCPE9K+xOvvg32/aJp2zoYrOnOWT1m1 zrIxbYw== X-Google-Smtp-Source: AGHT+IFO3vGSve2BHEqIsjtIYtblvU2ArE9I3x6DOBoXg/VkFfGLTy08MldXB4ghZvHmDIsfNIHFvI4K9D4Z X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8144:56f:2e1e:4db]) (user=irogers job=sendgmr) by 2002:a05:690c:4982:b0:6dd:bcce:7cd4 with SMTP id 00721157ae682-6e3477b4505mr701737b3.2.1728632176121; Fri, 11 Oct 2024 00:36:16 -0700 (PDT) Date: Fri, 11 Oct 2024 00:35:52 -0700 In-Reply-To: <20241011073559.431302-1-irogers@google.com> Message-Id: <20241011073559.431302-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: <20241011073559.431302-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v1 1/8] 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. Signed-off-by: Ian Rogers Tested-by: James Clark --- 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..ec06683e77a0 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'; + } + /* Read failed assume finish_command was called. */ + fclose(status_file); + return true; +#else wait_or_whine(cmd, /*block=3D*/false); return cmd->finished; +#endif } =20 int finish_command(struct child_process *cmd) --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Wed Nov 27 10:45:22 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 65A6B20ADD5 for ; Fri, 11 Oct 2024 07:36:19 +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=1728632181; cv=none; b=igFCSS75c8kFuQBbULM5BC+kr72HaDqh07ozixqg3HZWU37QGCLUw8mqB70bNmgQytX6vMIc+/ZuZ7HPChCL1ysOMZPyNye1xWISbVOOZKTQWFsZ0F6Lhov8U+bUxTZFE5z+8NWoPQhaRt2PmHwW8eIQ9BGQZ6wW2NWSJOrw9Y4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728632181; c=relaxed/simple; bh=BE71A4+W6in6OwHiqTPbNMyMV9/lD4f0WqGEUCVsUYQ=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=YjF3AKsYtuEO4LRP2h2WFaYHJoWxqUNI8fYHbjmw349CR+zQY+rIfHgRn9917A+PYnkWRJzslnzYamhRW4hOy38FUNKD6uSk2E+HmCpHvSZnLRWynSVEd6snbYeMaNRBn943MLJVCdiBfBNmeo2atzAaCUImUzlpCjwM+gyybpQ= 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=0xxs9S83; 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="0xxs9S83" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e2e5e376fcso36956887b3.2 for ; Fri, 11 Oct 2024 00:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728632178; x=1729236978; 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=+gloykLWNJIS7hYRxIxhrcOUu11SUMIFR6gR0myrd+Q=; b=0xxs9S83YJkv81OetXTEoaHBetfCIJtKh0YLIFv9Yq03GYy2guWentTDO14Y1za6ND fR6BEFbvdoSMh7S5rbvXM1jRJOt8v2pb5aX+A0VKcOTcnewiNYL6/BvQSfjVy7f5R68o aCtgl39+kvNj4q38/bcq7qkY+xtBoarGApMzK5+6+qLDrsY013MZulS1f7oRuPtpXmGC OYtT0V8sypjoeieIMXLqTZLrbn+gifRDTij7GPoZS41OkXNPjED09RjMrO5WdxHJGovd 90bkhR1Z8vJQJJk8cNjt/ik18PuzCkdpoKm1wXGg65DV7jWWuQpW7Lp/coZoirgbx7fp grng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728632178; x=1729236978; 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=+gloykLWNJIS7hYRxIxhrcOUu11SUMIFR6gR0myrd+Q=; b=QIYIXwh47HYFB64HhuqHCUqjLRuZomMtOhcKN13Y87h41xa9BAlCwz3HJMqVv9dY27 kI9+di8hcLWkms38v4QzkxR/xxo0WVoBbAjqMKLlO7bfCbkVkiQW+H5fG9v/xqFtP89r 7rCcrxeE8zpgkgtH8vgMTqIHrmK3keCFbErq2v+X4gmSUEqoy8doehhMYuO85+czkRcA K6f/FtFMMK2mI2E91sQFjj7OZSShSXAQEs1n/6OCVhimfvNef9AItCcFFebI5YAWzwyG /4qmC3U9/b2dEqdR6vrsVjiMiVZ7No/kkK6xN7Sw037MbtufMVe0wDBxcLR9CQwE1w3Z EzUw== X-Forwarded-Encrypted: i=1; AJvYcCX4d4uembGLyEIxbu5VdVVzuHkQlZcUE9ZnmUoVkeTZj0xMgMaSu06ZSw9GhXFuvfQFhyjP6x9Th4+OrS4=@vger.kernel.org X-Gm-Message-State: AOJu0YxGBBA+GsrbbGvHcWZH1pG1quZdI2pS8k+21zUsQMU6Zl4Xl4bE rY0i1EU6fsxAp1pnZaLbqtSYRiuLmuZAuNvVIJzOx+NW/xu26afyE1Hv/zjKeR7MV+Fx0wl/4ho X713YkQ== X-Google-Smtp-Source: AGHT+IFYMA3DLH38O9T3fJNzW1JyevwOdHaC5UQ340R2tC+oOSQhzpqT9U/uWhRGS1xK4D9caQ1extcgyIJa X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8144:56f:2e1e:4db]) (user=irogers job=sendgmr) by 2002:a05:690c:c09:b0:6e3:1702:b3e6 with SMTP id 00721157ae682-6e347b368d2mr367447b3.4.1728632178512; Fri, 11 Oct 2024 00:36:18 -0700 (PDT) Date: Fri, 11 Oct 2024 00:35:53 -0700 In-Reply-To: <20241011073559.431302-1-irogers@google.com> Message-Id: <20241011073559.431302-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: <20241011073559.431302-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v1 2/8] perf test: Display number of remaining 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 ( remaining)" where the number of remaining tests is determined by iterating over the remaining tests and seeing which return true 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. Signed-off-by: Ian Rogers Tested-by: James Clark --- tools/perf/tests/builtin-test.c | 94 ++++++++++++++++++++++----------- tools/perf/util/color.h | 1 + 2 files changed, 64 insertions(+), 31 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 470a9709427d..df0466d3def6 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -242,7 +242,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 remaining) { if (has_subtests(t)) { int subw =3D width > 2 ? width - 2 : width; @@ -252,6 +255,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 remaining)\n", re= maining); + break; case TEST_OK: pr_info(" Ok\n"); break; @@ -273,14 +279,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_tests_in_progress =3D -1; int ret; =20 /* @@ -294,7 +303,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)) @@ -308,38 +317,61 @@ 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 tests_in_progress =3D running_test; + + for (int y =3D running_test; y < child_test_num; y++) { + if (check_if_command_finished(&child_tests[y]->process)) + tests_in_progress++; + } + if (tests_in_progress !=3D last_tests_in_progress) { + if (last_tests_in_progress !=3D -1) { + /* + * Erase "Running (.. remaining)" line + * printed before poll/sleep. + */ + fprintf(debug_file(), PERF_COLOR_DELETE_LINE); + } + print_test_result(t, i, subi, TEST_RUNNING, width, + child_test_num - tests_in_progress); + last_tests_in_progress =3D tests_in_progress; + } + } + + 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_tests_in_progress !=3D -1) { + /* Erase "Running (.. remaining)" 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, /*remaining=3D*/0); if (err > 0) close(err); return 0; @@ -355,7 +387,7 @@ static int start_test(struct test_suite *test, int i, i= nt subi, struct child_tes pr_debug("--- start ---\n"); err =3D test_function(test, subi)(test, subi); pr_debug("---- end ----\n"); - print_test_result(test, i, subi, err, width); + print_test_result(test, i, subi, err, width, /*remaining=3D*/0); return 0; } =20 @@ -380,7 +412,7 @@ static int start_test(struct test_suite *test, int i, i= nt subi, struct child_tes err =3D start_command(&(*child)->process); if (err || !sequential) return err; - return finish_test(*child, width); + return finish_test(child, /*running_test=3D*/0, /*child_test_num=3D*/1, w= idth); } =20 #define for_each_test(j, k, t) \ @@ -465,7 +497,7 @@ static int __cmd_test(int argc, const char *argv[], str= uct intlist *skiplist) } for (i =3D 0; i < child_test_num; i++) { if (!sequential) { - int ret =3D finish_test(child_tests[i], width); + int ret =3D finish_test(child_tests, i, child_test_num, width); =20 if (ret) return ret; diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h index 01f7bed21c9b..4b9f8d5d4439 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h @@ -22,6 +22,7 @@ #define MIN_GREEN 0.5 #define MIN_RED 5.0 =20 +#define PERF_COLOR_DELETE_LINE "\033[A\33[2K\r" /* * This variable stores the value of color.ui */ --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Wed Nov 27 10:45:22 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 996C820ADF4 for ; Fri, 11 Oct 2024 07:36:21 +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=1728632183; cv=none; b=Z1kJOgfSLfP3+c8CSPyf6O3gxzay5NuYL9TENx3FjJeG6sbuDGOSUkSKrqogSYeggHmsXkMJks0DHYLlcHp+MJ6zEig/13bQplH6tlkyfmIxxTLN3t6JspLhDjzGkbA25Xhm/mNkX5xKRD7Wd0h3C65hsJxrNS08iXclnm5QSmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728632183; c=relaxed/simple; bh=j9xoZhKUCxCRzKJME1b4ctoFywjIrcKy9BRs5A8oUiA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=fc46PASJuEwXlZjmVxy347dNAfbNSHM/HKmrFQoYzZupf0+9CRw+MsVSy4m/3R78eFx0ilP3KZuC/thnEyyo0a+qxsDNZQ95A+IH+JtTcfjN0MxzpiiGKs7eE8KdfN+4Ta05eNOSPcvwZhKPaV75gFW+bBlT/T02AzaB9awtEfs= 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=ZaSEn0YN; 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="ZaSEn0YN" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e31e5d1739so33092257b3.1 for ; Fri, 11 Oct 2024 00:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728632181; x=1729236981; 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=rgB00BYIV9qluKgj4RC8eehGF10YxeeBjZZWHyrv1y0=; b=ZaSEn0YNjf8R2J/E8cqDERh+uEpFZoKt3bRWQ5+AX3hROyWWy9+i7pUCfYFLs8ERRo fG+ziIi6sLGMG02R0kFp7XOXXrvM9J7vPrsH+4lPvfwlcg9IAKHwpHocdJoIVbS5qLiN OBCzsacQchKEK+WXKt1pD/Ke8aq+xFUsJQKua45lqKW0wpiVsCDCZWJWuOyyhi2FSUS5 JSsj1LTyTuz3NTmfhjUjK37xIsbUrhZofuMHJYuJuU6AOYvPFYAcckgjINxpZq2rStFf DeijZKy7qRQnc1uomJKVaDGxpNxH3ff1nwBYMOHnGbe99ClS3MNgl9vpCBp/YUAr5+/L 5iHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728632181; x=1729236981; 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=rgB00BYIV9qluKgj4RC8eehGF10YxeeBjZZWHyrv1y0=; b=gQjGYvwBxJMLIiNvI0bZKI4fGKQFY/4OhDg3pMn+5kugfDkRx05w5LL4HtjJoWeZkl WuOxx4xaElfc2sb/9OYo2eKMNGXFVNJUbP+YFGXg7kE4PQIaRJ0ncS8OxnxczhjjM+R0 3Ztpf8iXwRwG960856bAHoa7iWsDB9OOmY9ks+LyoELjEpscTFy/mIT/bdrX5saseZMo 4vGivLJd5uJZmCVWKqQYQZ6yZoIMbYdpT1wYkNeV+9+l7vob0hMgEWj0m4rvD3diKp/a uwj1E7nfq2OZoDecUWSQHTX1AdSnldJIktukM84kXh0Oc7d2XOMP43mKEC0YzWlBZTj+ a5IQ== X-Forwarded-Encrypted: i=1; AJvYcCVuERK3BUINHc8B+FC/C9CBZZWqI0S5h7dz4G348tBqNlVwfQuEJLp+ZF2EbyzGHQV8XM64SBu2YQuxlmc=@vger.kernel.org X-Gm-Message-State: AOJu0YwhhqmzdvspebsW7MDfKlvup2CKiYe2awX/MIOvzqB9p7A1jzLZ XFG6TAMzBQyEfaSycp7RipS8CRr6FYYILeHS0pyY+X31B6XtkQyoNgdhhAGrA/2D8XdrVs8PazF hZj1Hhw== X-Google-Smtp-Source: AGHT+IFAgo37u8rfjVAYg4qiXtWEdAHj0LY5XoBITiq7BqupjjYH0ReOmowk3vBX1hWxCN/0yj8Fi53KsVtF X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8144:56f:2e1e:4db]) (user=irogers job=sendgmr) by 2002:a05:690c:4449:b0:6e2:2c72:3abb with SMTP id 00721157ae682-6e347c85db8mr432917b3.7.1728632180691; Fri, 11 Oct 2024 00:36:20 -0700 (PDT) Date: Fri, 11 Oct 2024 00:35:54 -0700 In-Reply-To: <20241011073559.431302-1-irogers@google.com> Message-Id: <20241011073559.431302-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: <20241011073559.431302-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v1 3/8] 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. Signed-off-by: Ian Rogers Tested-by: James Clark --- 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 df0466d3def6..6b8ef198d975 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -41,9 +41,6 @@ static bool dont_fork; /* Don't fork the tests in parallel and wait for their completion. */ static bool sequential =3D true; -/* Do it in parallel, lacks infrastructure to avoid running tests that cla= sh for resources, - * So leave it as the developers choice to enable while working on the nee= ded infra */ -static bool parallel; const char *dso_to_test; const char *test_objdump_path =3D "objdump"; =20 @@ -566,6 +563,12 @@ int cmd_test(int argc, const char **argv) }; const char *skip =3D NULL; const char *workload =3D NULL; + /* + * Run tests in parallel, lacks infrastructure to avoid running tests + * that clash for resources, So leave it as the developers choice to + * enable while working on the needed infra. + */ + bool parallel =3D false; const struct option test_options[] =3D { OPT_STRING('s', "skip", &skip, "tests", "tests to skip"), OPT_INCR('v', "verbose", &verbose, --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Wed Nov 27 10:45:22 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 A3F9C20B1EF for ; Fri, 11 Oct 2024 07:36:23 +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=1728632185; cv=none; b=i8U9U7yE2hd0v0W07ZBVWhrR5AnuII0mq9ajOnDt7h8HmlJXby4PyY3aLCrlXJyzw5IGmoRm9ynHWgfkvkdD6oWncJZtmDwQFchBSquWwbm0K7giHC3vfiQgZv3SLZwJOqHKR8RQTvG7LtDjYQeUT8U3dSbG0VRfIlInJSn3q8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728632185; c=relaxed/simple; bh=JuqmInDNCF0j1qi7X8VY+IRMQTve1+ETPqQ3Y60nnhA=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=FWuNGvBlZLFs4kwfo0n4X1ng/0jcMXD/mCDHl96b90cR6HBQQF6aZhQneLPE4E/2iiUtq3RChBLhl2OPXe1vTwmmVIVoytI66BYH/SkX8SpB73aVomAjtI8CVJlCW+nEwq/A1/rDCD+JXUHXPAUcSB5wOca/L5A+HvpsenvCMaA= 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=XECGUSDc; 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="XECGUSDc" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e1fbe2a6b1so32159477b3.2 for ; Fri, 11 Oct 2024 00:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728632183; x=1729236983; 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=h1RDoAb7ubYjo7SH/MUMAZWwf1Fgw9lZgxpoFFh96f4=; b=XECGUSDcKH6N8BU/D68R30ZD8DXcqX6UVk1jaioffmgJUn+/YwVry+XOhwqyBCw9Qy T9lkglx8s3v37tQw2LmjbsIGWlIbOgYyrAXpMZhoEmPDXS2TQiiBItvqvWAk7+GeuQQm eH3WYfZdESAdyVuSPX7lg214IEOfKXuG1BfkYGoQb7+S78lmmAlvMhILzpeyGTZXeQWG IAElI+Jq9upgqZCda/psCuaozUr8n17IZFRjbbqQ23duA9QG3zCFXHTCVWB3vbHkWkal DIKBVu5FrXaikicbTz1787SjGNArOuZEkSFeZ5YoYZxkRfHozBirHGSdzLmsnA0ZVdDa N8HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728632183; x=1729236983; 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=h1RDoAb7ubYjo7SH/MUMAZWwf1Fgw9lZgxpoFFh96f4=; b=DLtJPCWhV+a8spIyauqtmT4P7oOkmKwyK/JfN4AqCzq+IzPSFMY8yTus2XJHwiKqyS PEJjtkNdrbzvj6Gf8y7vx8nzL2PPPN9sC71tNKJvWKDIcHD31iIrsquxAvoBjUzJyMQ9 TLU+XRTi/FnGiyl5NN1TQaPZQWqdMzpM3YQUccBchqZKm39cS1owTYbkzZOWElLLxup2 X7JJ0hhnG+2VKJrOR16DP7pFHebsmkl/g8Z29RK/HKEcQzC7/xoZFJF6pFjDpuSa4AdT rvIUhm11F6qyY0BGfmXkvcPsYZ0wdMH3qZ+meRvQ6+Bfm6WbaSuQ85kL7FKG+VW0Ekvb 4inw== X-Forwarded-Encrypted: i=1; AJvYcCUkj2ho5pp2Ze/uaNJTHRlAFAoZu/wGPvGV3nYguFBzuU76PtwgBvWqXrRpOJ5HEhWhpc3jPeSFN90ZJCY=@vger.kernel.org X-Gm-Message-State: AOJu0YxU+G46q0bvOb843KO+n/tv54wcQRc/K7zMAoG6++0Iqbiw4R1+ tMMrYe0YRR8KAewsGMNcjHfMVVnFT8qA2bIeIlYm5bY9abXtaWmryByVTM/+gFxVhEZ1hgva1t7 XXuCnCw== X-Google-Smtp-Source: AGHT+IEU5guu/3Lk+woHIE6L9NJ5fVlRdYN3CeRTj1h03zL1dcCIN4gq5f88dhPrvr+ImWXEtantlftK84yf X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8144:56f:2e1e:4db]) (user=irogers job=sendgmr) by 2002:a05:690c:6d8f:b0:6e3:21cf:a67f with SMTP id 00721157ae682-6e347c76847mr857467b3.7.1728632182799; Fri, 11 Oct 2024 00:36:22 -0700 (PDT) Date: Fri, 11 Oct 2024 00:35:55 -0700 In-Reply-To: <20241011073559.431302-1-irogers@google.com> Message-Id: <20241011073559.431302-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: <20241011073559.431302-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v1 4/8] 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. Signed-off-by: Ian Rogers Tested-by: James Clark --- 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.rc1.288.g06298d1525-goog From nobody Wed Nov 27 10:45:22 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 E88F920B216 for ; Fri, 11 Oct 2024 07:36:25 +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=1728632187; cv=none; b=ZrmoN7DRkyo97dXwq+GU3IydSqnTiQ0ReVsnNlBIGQosNhtQuZTz49eg+Ir5nwaTahzepHOVUaPyUwly5UZRHaTdSQxJduR1XD/+em4470nebu0Yv1D36DvLwuvMsjAT0FkJzNl1xTanIfjBMhnTydV4D3ORtsjSTc/YzfnCHp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728632187; c=relaxed/simple; bh=qRJ7uobiuXa4lx58ydid8NsiY9eSUc6Dd5fam5Iq7JM=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=k8LQ3/7O/6aQ4t/oZHqW2nb+Gmy9jpkaMNEZ73ZkNIMA1PyH3Bw5QNUwOkE51skdSgZxjznoAV91wQ1LAdVfhcKYK3X3fakJgNc2/HkjDRqwPHr1GLsyPcjwKgoPC/rzg65upr8EJ0NwDuUu0BIvNfiQ1dglv8y+3KWbdJ8w6Cs= 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=x/1WHHhc; 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="x/1WHHhc" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e31d9c8efcso35447607b3.0 for ; Fri, 11 Oct 2024 00:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728632185; x=1729236985; 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=sGy2stET4dPYcbIauhcjx1YKA3rAeDl4bGF/9JCbzDA=; b=x/1WHHhcX5uhIxoTpgJ6UZwPYJRUF+JSEIHaOdJWNzLDZJe6aHEZe/3u+iSYX8MOlB Nrk+Bfyq+S/t+w5ZOTXMXYCpMbHvoUN3BoqSGR4KR3wcO6KLTSt86R+Rc/nzuSnFJG78 ARnI42Sxg/65Q77Vb0iQOzCbiYXAzJ7odOkuvDh0sJa9boNgE3YU6rRWaIplJAHO8niU nQ7W2z67TzFq5jNUm8Ntgdk+WAmCeEyauyjtia2NXK4bhEsYV4xPU9yADNrGtj/uuxSu t7swkd2owG05q61MaFjqCy8YL2niNI8XDJOfnCUZ3lriD7U0jMXKQq90yo6nMFjwKEn4 ++3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728632185; x=1729236985; 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=sGy2stET4dPYcbIauhcjx1YKA3rAeDl4bGF/9JCbzDA=; b=HCe2Z7LB8ZN5CSYKUzVukaXFHJt2p09Wa/DyUZSGRo93kDKkWZT590iYo6NBUTz0RU llkCxXYuwxXwdQttobnRYOcGwVb0QTrXkndrWTXfRfAqP5aKB9zhBm/dwdGdKiQljoeO 11aFvItyUUN875FN/47mrLlgJ0fJ22HK0XlFRNFBSejYZdDxqiNA3HQAqFZP/ucUD7P6 21gHzcAe3r2nQttcE3Ey9txF6wV7ZTh5m2naHGF2wQ7pVnxgyy07Vi/WvLOx2bt2MYuW pWmbWJLBxMoaWvwYSswaKxWOtl9HtJR/ttgrZCtKMcEL5YybLuJI8LaM3vq55IOvFaIG pznA== X-Forwarded-Encrypted: i=1; AJvYcCWgcmoDKLKVLm2pcnW+/+xMRgAAYXqSskyatrBdvhzu6CWQINLcMZD8kF8bWc7CqV51zkC2kzWIPJkbUmQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4zn2RbTQmyih8cBgkBlJIEdYJI8tQ86Gofet4NvG7VOIRUXcj mN1a2X6fL+7d4PI0uU778wHSMaEQMXmJRFXCWMsY9gZCsLJeaifL0yhZJqRohFokZcQ/IGxASxs WCbof4A== X-Google-Smtp-Source: AGHT+IFCnDFL9xKF8OEn5GZiOdl2eowmU59Qvp9zHwHa5EKbZlB7BPAnM/Hp0z+j/P9xYahKR4m00uHjtQKt X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8144:56f:2e1e:4db]) (user=irogers job=sendgmr) by 2002:a25:c593:0:b0:e28:ede2:d060 with SMTP id 3f1490d57ef6-e2919dd2c51mr1323276.4.1728632185018; Fri, 11 Oct 2024 00:36:25 -0700 (PDT) Date: Fri, 11 Oct 2024 00:35:56 -0700 In-Reply-To: <20241011073559.431302-1-irogers@google.com> Message-Id: <20241011073559.431302-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: <20241011073559.431302-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v1 5/8] 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. Signed-off-by: Ian Rogers Tested-by: James Clark --- tools/perf/tests/shell/perftool-testsuite_report.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/test_intel_pt.sh | 2 +- tools/perf/tests/shell/test_stat_intel_tpebs.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) 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/record.sh b/tools/perf/tests/shell/reco= rd.sh index 8d6366d96883..f7d8c5b243a4 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -1,5 +1,5 @@ #!/bin/bash -# perf record tests +# perf record tests (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/= record_lbr.sh index 32314641217e..8d750ee631f8 100755 --- a/tools/perf/tests/shell/record_lbr.sh +++ b/tools/perf/tests/shell/record_lbr.sh @@ -1,5 +1,5 @@ #!/bin/bash -# perf record LBR tests +# perf record LBR tests (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/record_offcpu.sh b/tools/perf/tests/she= ll/record_offcpu.sh index 67c925f3a15a..678947fe69ee 100755 --- a/tools/perf/tests/shell/record_offcpu.sh +++ b/tools/perf/tests/shell/record_offcpu.sh @@ -1,5 +1,5 @@ #!/bin/sh -# perf record offcpu profiling tests +# perf record offcpu profiling tests (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/stat_all_pmu.sh b/tools/perf/tests/shel= l/stat_all_pmu.sh index 42456d89c5da..8b148b300be1 100755 --- a/tools/perf/tests/shell/stat_all_pmu.sh +++ b/tools/perf/tests/shell/stat_all_pmu.sh @@ -1,5 +1,5 @@ #!/bin/bash -# perf all PMU test +# perf all PMU test (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/she= ll/test_intel_pt.sh index 723ec501f99a..660991d17607 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Miscellaneous Intel PT testing +# Miscellaneous Intel PT testing (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e diff --git a/tools/perf/tests/shell/test_stat_intel_tpebs.sh b/tools/perf/t= ests/shell/test_stat_intel_tpebs.sh index 9a11f42d153c..f95fc64bf0a7 100755 --- a/tools/perf/tests/shell/test_stat_intel_tpebs.sh +++ b/tools/perf/tests/shell/test_stat_intel_tpebs.sh @@ -1,5 +1,5 @@ #!/bin/bash -# test Intel TPEBS counting mode +# test Intel TPEBS counting mode (exclusive) # SPDX-License-Identifier: GPL-2.0 =20 set -e --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Wed Nov 27 10:45:22 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 64E9B20C476 for ; Fri, 11 Oct 2024 07:36: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=1728632189; cv=none; b=Mpc6a3qEE5cX7tInGQyA3NeyKBtO9BN7YpGJfbCed4+dPaXsZJp2VwB9eW8E3oNnJztkhSHDyGNDFvvvODTUGFmr+ipyZmV+ulB31ywFnVDWGMHCZ6ijtuSzp6Qy3LexBb67IlT2/VnVQh6016PN9aTO+74M7OkJsoj1EYEU+jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728632189; c=relaxed/simple; bh=xnAMIL5v413ciitu1wkY24YCgY7LrYNUuSXRkWHF/SY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=mVYGk67gOd8kk+AbdmltQqnYPUY8caX98L1aActPm51vdPNWBZ0kO1OypZ/uJx3Mm/YSOG4NNm6M3bIWh0pyo8mCY5h0VOQhzSczl2hPax7uNkdfuCfE22mdq9B+3bEl4KFT6hrX7k0DgfEkwEilmKwhLFtj2cZFbcdJszUIdHI= 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=EVh7wXdf; 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="EVh7wXdf" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e34c8daef3so5203227b3.1 for ; Fri, 11 Oct 2024 00:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728632187; x=1729236987; 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=sInfOXsK4DHkW3UJ8a7cyPbP0ObPdFBOq3supb45AvQ=; b=EVh7wXdfXe0RnpY8nfR5yQqfuXB1hROt3aBQ9TpDmWIFeJKi0XOAlK7GWLBDKA/Elh WDDgTnjGWYY+mA/Zl/e8YRHXmcdJ0CtWPGijEVwWkCfRIhHLw+0Tsu1vtjngo1UEa5g9 wzyA1kqvzpyuado4cXCTXbJLO39OvCmaVlhtbkfsIBceo7wLsOUt3Rqk0fhGGS78OlC+ +Pvg5b2nnCobNFCwRA0tYwzhtG86Sd09rSDYFFRnRPgha0u3GcEXNMmBuGZsdNTb72Z4 tMmjcZSj9e2LTFVmVgPYbggCttW+XWwWz7D1o7QInT7F+x0dx8Lcb+SYoTrmC0N3Vb4s mzjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728632187; x=1729236987; 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=sInfOXsK4DHkW3UJ8a7cyPbP0ObPdFBOq3supb45AvQ=; b=RRPfv9wTbBRxjc8iQz6xFgFqjaw45daLPoH608kV5xiPTBzI4bCp9Hc2bPnWqqbE/Z Yvvx+f71nIcbNCDb/nASDOkkuQ7XLEeqM4SvazcvRfDMy5wiqKRQtiYoAwHgYuaFDmtl 8doN9I0mj4NLnVI2D2ykeR/o5Vs17jFkgf1elNCtGfYJm74AUDmkaBEHtJplZOq4XYhC O3a4FgA7p2q1xXSjT0fCX7Q5iZqS2XRTVxDgCCyY8K15NM7lHwrcrLz5mN+TdhqI4bBO nvr4GfZKk5AZ5jfkrAiDu1g9iNxRnaf6MeuB3R6lIhw9Q4CH23okqa4OJ9YidBoR0RZE plew== X-Forwarded-Encrypted: i=1; AJvYcCWlgzD7dH0VssrYmLzyBWortbMlV3y3VCF1ylDsmQFHZTugMHdDms4/BJSzsf8LyNAkmImHHfV1ZZsagVE=@vger.kernel.org X-Gm-Message-State: AOJu0YyqkD+xDE4p+OFl0uv9IZJjLRNQoBisMacN+GivShBaPpKiD5Sz bHDM2Ovtv+hyBltlUUQNMPX5nvcYLleFklUhL937EsXVxMQQwOHX0j7gzglYAqqTnUw8myr3dDV lD7+3+g== X-Google-Smtp-Source: AGHT+IHA2iTnHlVf+hgVhL9GrhHFp/9IHezt164Cm5YXlEKS9eEEUTgiN/fM/H+2WylpswmvDe7BHPccrB/E X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8144:56f:2e1e:4db]) (user=irogers job=sendgmr) by 2002:a05:690c:c09:b0:6e2:6f2:efc with SMTP id 00721157ae682-6e347c52d2emr463317b3.5.1728632187304; Fri, 11 Oct 2024 00:36:27 -0700 (PDT) Date: Fri, 11 Oct 2024 00:35:57 -0700 In-Reply-To: <20241011073559.431302-1-irogers@google.com> Message-Id: <20241011073559.431302-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: <20241011073559.431302-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v1 6/8] 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. Signed-off-by: Ian Rogers Tested-by: James Clark --- 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 6b8ef198d975..45a31376fdb0 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 @@ -226,16 +227,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.rc1.288.g06298d1525-goog From nobody Wed Nov 27 10:45:22 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 9024920C48F for ; Fri, 11 Oct 2024 07:36:30 +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=1728632192; cv=none; b=e1S51NbQO+8uNFJJJ+xmx1AAWmEK+cRPtn5OSpAx2zeeuc1/KqBb8gLuZhYBDorVK3guu/kFjxKgFvakFQRta+x4XnAoNbqI6lnbPwVqdBERtVk1ipAmRyhB7Ho4/PsFpU4d+nR6oRoRRbTVA7+7GyLeiZyTLACoxvGzg9SoBm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728632192; c=relaxed/simple; bh=EZ/KSG2YCgcvIuiR2hkvbB+QWUT2P7L8MSU3/WNrSEw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=FlWSwdo5BwbfWsUWv/Pz11MNQ04pHvpHHCCG4tEIgAbAaqucu0y4VQ8Uky8aUPb8vuuTBx4dtAprfP9F9SjjT1WeImBnNOAe7Ql+rCqR2qGp/9yyWs2Z1XU8xgpZhBun2FtbRNAoZVJthMMLhS3LcKnLyjPvqXRsyWfkGDT89V0= 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=XU7LBvjg; 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="XU7LBvjg" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e0082c1dd0so35241627b3.3 for ; Fri, 11 Oct 2024 00:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728632190; x=1729236990; 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=AiVV7OPM9xYY9A282fOCtqbe0eCO4PXqRKkc+NuZBAM=; b=XU7LBvjgh28epU7V4n2EY6xytfXh7/tBFHsE2R/bW4oCq8hRhJKfpoPGKdMRFNmiMp f22qd5+GtblEXkvzBjKFi1fqG6mH9pJi9M0rGTc8NaYGjhtsXqO3equCSM31d8tF4Ws9 XBCGl5DasObXi99AUKuCxWz6w0gaX/24GQrCDA7IQWJby5hwYaAUN1RZ9gwl//rldGsC jFU6wGjFVx6OTYt3PMl+dCKibNJ8NiCvMfs+YWe8Sk6fGWXXXkLtyiJBrP0jygeKc3n9 fN35QYEKvBbEAOlk047tHXLbbXjNxIVw1I5h6bD5uoyoT+lkHic8dehX0GXmqG6bUnss E2Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728632190; x=1729236990; 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=AiVV7OPM9xYY9A282fOCtqbe0eCO4PXqRKkc+NuZBAM=; b=jEZshVvcOEH/lfL30b4hxCcqbazPDOk1gcOKrlUlr226Va3iOwXajyE8UJ16NRw5n8 e62smttlv1AZhNF5Z9JInxyCmp4bf8gkJMyKu7ULzYytOmLSbMOZA837qDrQf9oncgIQ VvtPvL81s9R0Cw6X6i0txb+h77yqXYntNsMroeXrK7wz5s5+Ar75Z0Ul05IM7I9qoQwo ao/YEe0r4lsaLcAoJpkmCGcpf2+ixq90CJzG9BmrXxTg/rnS+16FdCQOfa955LaBUxQf hkbu6j2y2f9gZTYdWWC5HTL8PUIrB2R0mSuPFq2GsZpS0IMB/t/0k3AY3Ewi+GoZ8m42 LGfg== X-Forwarded-Encrypted: i=1; AJvYcCXfJWuopRrffK6mDf+HQEHIAbnH/jlShNR0Kp1q+FZKEEgcAqEVgTG6SLOLgSibAl2IguBoJgVaTcMjexY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9xZ78IkKdY+dObCVQFhQ4w+brTuBOyoW1EK4lZqmOV92Xxjp1 Aen/B3NsYwmSn3M87RqweQnU5ciwZXubTmnHLmJ0nfQKHofvxzQdZZaPZcx42sArvLbe9nIBxcX CRdE/ZA== X-Google-Smtp-Source: AGHT+IGM45tCNomTmEn3OcKMTDY9R/u9tmt8y7Bg1uK9OcK6gzdkRtPRCoHu/FUBC1udeMjiND22pMmIlE9U X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8144:56f:2e1e:4db]) (user=irogers job=sendgmr) by 2002:a05:690c:4982:b0:648:fc8a:cd23 with SMTP id 00721157ae682-6e3477b49c8mr507797b3.2.1728632189615; Fri, 11 Oct 2024 00:36:29 -0700 (PDT) Date: Fri, 11 Oct 2024 00:35:58 -0700 In-Reply-To: <20241011073559.431302-1-irogers@google.com> Message-Id: <20241011073559.431302-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: <20241011073559.431302-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v1 7/8] 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. Add error handling to finish tests if starting a test fails. Signed-off-by: Ian Rogers Tested-by: James Clark --- tools/perf/tests/builtin-test.c | 149 +++++++++++++++++++------------ tools/perf/tests/tests-scripts.c | 5 ++ tools/perf/tests/tests.h | 1 + 3 files changed, 96 insertions(+), 59 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-tes= t.c index 45a31376fdb0..fd6b50f4d145 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -239,7 +239,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); @@ -249,7 +249,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 @@ -302,19 +301,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_tests_in_progress =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. @@ -344,6 +349,8 @@ static int finish_test(struct child_test **child_tests,= int running_test, int ch int tests_in_progress =3D running_test; =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)) tests_in_progress++; } @@ -397,23 +404,32 @@ static int finish_test(struct child_test **child_test= s, int running_test, int ch print_test_result(t, i, subi, ret, width, /*remaining=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, /*remaining=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, /*remaining=3D*/0); + } + return 0; + } + if (pass =3D=3D 1 && !sequential && test->exclusive) { + /* When parallel, skip exclusive tests on the first pass. */ + return 0; + } + if (pass !=3D 1 && (sequential || !test->exclusive)) { + /* Sequential and non-exclusive tests were run on the first pass. */ return 0; } - *child =3D zalloc(sizeof(**child)); if (!*child) return -ENOMEM; @@ -432,10 +448,14 @@ static int start_test(struct test_suite *test, int i,= int subi, struct child_tes (*child)->process.err =3D -1; } (*child)->process.no_exec_cmd =3D run_test_child; - err =3D start_command(&(*child)->process); - if (err || !sequential) - return err; - return finish_test(child, /*running_test=3D*/0, /*child_test_num=3D*/1, w= idth); + if (sequential || pass =3D=3D 2) { + err =3D start_command(&(*child)->process); + if (err) + return err; + finish_test(child, /*running_test=3D*/0, /*child_test_num=3D*/1, width); + return 0; + } + return start_command(&(*child)->process); } =20 #define for_each_test(j, k, t) \ @@ -445,12 +465,11 @@ static int start_test(struct test_suite *test, int i,= int subi, struct child_tes static int __cmd_test(int argc, const char *argv[], struct intlist *skipli= st) { struct test_suite *t; - unsigned int j, k; - int i =3D 0; int width =3D 0; + unsigned int j, k; size_t num_tests =3D 0; struct child_test **child_tests; - int child_test_num =3D 0; + int err =3D 0; =20 for_each_test(j, k, t) { int len =3D strlen(test_description(t, -1)); @@ -473,62 +492,73 @@ static int __cmd_test(int argc, const char *argv[], s= truct intlist *skiplist) if (!child_tests) return -ENOMEM; =20 - for_each_test(j, k, t) { - int curr =3D i++; - - if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) { - bool skip =3D true; + /* + * In parallel mode pass 1 runs non-exclusive tests in parallel, pass 2 + * runs the exclusive tests sequentially. In other modes all tests are + * run in pass 1. + */ + for (int pass =3D 1; pass <=3D 2; pass++) { + int child_test_num =3D 0; + int i =3D 0; + + for_each_test(j, k, t) { + int curr =3D i++; + + if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) { + /* + * Test suite shouldn't be run based on + * description. See if subtest should. + */ + bool skip =3D true; + + for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { + if (perf_test__matches(test_description(t, subi), + curr, argc, argv)) + skip =3D false; + } =20 - for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { - if (perf_test__matches(test_description(t, subi), - curr, argc, argv)) - skip =3D false; + if (skip) + continue; } =20 - if (skip) + if (intlist__find(skiplist, i)) { + pr_info("%3d: %-*s:", curr + 1, width, test_description(t, -1)); + color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); continue; - } - - if (intlist__find(skiplist, i)) { - pr_info("%3d: %-*s:", curr + 1, width, test_description(t, -1)); - color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); - continue; - } - - if (!has_subtests(t)) { - int err =3D start_test(t, curr, -1, &child_tests[child_test_num++], wid= th); + } =20 - if (err) { - /* TODO: if !sequential waitpid the already forked children. */ - free(child_tests); - return err; + if (!has_subtests(t)) { + err =3D start_test(t, curr, -1, &child_tests[child_test_num++], + width, pass); + if (err) + goto err_out; + continue; } - } else { for (int subi =3D 0, subn =3D num_subtests(t); subi < subn; subi++) { - int err; - if (!perf_test__matches(test_description(t, subi), curr, argc, argv)) continue; =20 err =3D start_test(t, curr, subi, &child_tests[child_test_num++], - width); + width, pass); if (err) - return err; + goto err_out; } } - } - for (i =3D 0; i < child_test_num; i++) { if (!sequential) { - int ret =3D finish_test(child_tests, i, child_test_num, width); - - if (ret) - return ret; + /* Parallel mode starts tests but doesn't finish them. Do that now. */ + for (size_t x =3D 0; x < num_tests; x++) + finish_test(child_tests, x, num_tests, width); } - free(child_tests[i]); + } +err_out: + if (err) { + pr_err("Internal test harness failure. Completing any started tests:\n:"= ); + for (size_t x =3D 0; x < num_tests; x++) + finish_test(child_tests, x, num_tests, width); } free(child_tests); - return 0; + return err; } =20 static int perf_test__list(int argc, const char **argv) @@ -638,6 +668,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/tests-scripts.c b/tools/perf/tests/tests-scri= pts.c index ed114b044293..443b55b0e05c 100644 --- a/tools/perf/tests/tests-scripts.c +++ b/tools/perf/tests/tests-scripts.c @@ -203,6 +203,11 @@ static void append_script(int dir_fd, const char *name= , char *desc, test_suite->desc =3D desc; test_suite->test_cases =3D tests; test_suite->priv =3D strdup_check(filename); + /* + * Note, tests with lots of stdout can't be exclusive as if they block + * then the file lock is held and no one makes progress. + */ + test_suite->exclusive =3D strstr(desc, "(exclusive)") !=3D NULL; /* Realloc is good enough, though we could realloc by chunks, not that * anyone will ever measure performance here */ result_tmp =3D realloc(*result, (*result_sz + 1) * sizeof(*result_tmp)); diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 6ea2be86b7bf..1d3e1f91871c 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -42,6 +42,7 @@ struct test_suite { const char *desc; struct test_case *test_cases; void *priv; + bool exclusive; }; =20 #define DECLARE_SUITE(name) \ --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Wed Nov 27 10:45:22 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 B1B4820CCC6 for ; Fri, 11 Oct 2024 07:36:32 +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=1728632194; cv=none; b=orMnINSSeChc/PIp5lLm3KhEooCzQne5MGS5ajqOuU7CrOcC7ehA+Xu6+SM3MQ96hzDB8mABrNqqr4KsRPaFvbi939L7V3OwfikfFjqzfFU4ofrbEOekawRIS8uBxF3Yer2pcUMv42PFuhVp/AephC5ca+fk6EzET1qHFOFTkuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728632194; c=relaxed/simple; bh=7cqOV3OKkh0N+su0/SwF7baEzp7XzLuZ+XLRbByZ/6Y=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=oWSU37VjVltdzG3zkQvyUYLsknineX/7TeJSU/jlOzH4s6ROpxlk7+bgneGy+AyGkHcN+7cKv1n4OPz2/QY/L+jXflj0aaa71hV3CYZajbuX3ovedZCYmzyCkjeG7+HFspOcJNmYCC04AsvwiqL1quW1sYVh66wm3LDqQYhG37c= 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=nTKWRUil; 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="nTKWRUil" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e22f8dc491so33744827b3.1 for ; Fri, 11 Oct 2024 00:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728632192; x=1729236992; 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=6fQaK0kCKOZGBatmn2bqZbV4z0l+dtzmVYsD8j3jWpk=; b=nTKWRUilqiqh4AEX8WKZ0HhnUIqvIufEtQ6IIEGKqTZ0Vc/mPSlFuQg0//imSejJTp CJrUXtOmHp1pQUpKZVl9ZqMzwVY9KA7KcDyq/sSxq5tLeRZgfgLpxJTj7cnsRJDqZ7CN qvF1Gk4n2UroSLAxAqv+kX6bU/o6HaMfu2VN7S14XDivJBHTCKkyEULLpIATcY8nK9ie BR3JvDRsYgSQ2hr6f5vwwkVHhiP77XpEramvO02qcPmElgb1Tt31Q1K27lI4H1tzCGc4 FhnIW+Jh82nioUu7yNMTdA1BhQpcKw7YYYUGwuQyU8y51nvXgRhWg5H0dxsLHUZoXg3T UY8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728632192; x=1729236992; 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=6fQaK0kCKOZGBatmn2bqZbV4z0l+dtzmVYsD8j3jWpk=; b=pQl7Uqb8/6FlA8CbFicr4rNwereEvqX7F3K8NoQRyuW6BDD4/SvmD7Is2UzPkS3OZO u+pLRMC/O/OGY8J7N6yy4nsDq4OVJmYJNr3GAsM3SFHxqM3UdPFc2mcOng9n8VoPhFlg lgptSvBkD+OI9gYHchfLXVjasGTC7wRHgJxQAewNu6Ff7x63CRB/TA5L49nUSr+7r8ju 1GZbaZ5ZmxRalhgW8fG00LaQcYyH6+2SAE42/nyPKQ0PISZrCqA15wyHpE+/tKZv2LEJ d11Bjedvwk7KJCmGFO7hlFvhRZnGG/hMeHshCzQev3kmR9V0ymKK1tbUWIomfdH3fxJc RkaQ== X-Forwarded-Encrypted: i=1; AJvYcCWkEyYyRi94iQG0VbHcsBjs+iTevtBRUcI4v70IYbhZCb7Z94xF6S2UooYcOnz6hLuSDFv17ENsK4EoPLE=@vger.kernel.org X-Gm-Message-State: AOJu0YzPvAE6i6hJ+65+jnGrqvaZSzacIbZ2Xf9auQ2FSJsCKZthMbGQ N5BCeU05HARWLCJ17IQD8/BesaKM/BGh7lEkMLYaLB+cjmEzMmWExFDb+WUw445uFCotpIrnmvH QE0feTg== X-Google-Smtp-Source: AGHT+IF3KkyD+E9c898rKYU9e/dhW5sEakuibvn0Cey33Cw5++s26UatIho8gVX2C49X9jgcYvAvAPF5dAGC X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8144:56f:2e1e:4db]) (user=irogers job=sendgmr) by 2002:a05:690c:2e13:b0:6b2:3ecc:817 with SMTP id 00721157ae682-6e347c6547dmr47247b3.8.1728632191939; Fri, 11 Oct 2024 00:36:31 -0700 (PDT) Date: Fri, 11 Oct 2024 00:35:59 -0700 In-Reply-To: <20241011073559.431302-1-irogers@google.com> Message-Id: <20241011073559.431302-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: <20241011073559.431302-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v1 8/8] 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. Signed-off-by: Ian Rogers Tested-by: James Clark --- 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 fd6b50f4d145..2d62b4961f85 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 @@ -619,19 +619,12 @@ int cmd_test(int argc, const char **argv) }; const char *skip =3D NULL; const char *workload =3D NULL; - /* - * Run tests in parallel, lacks infrastructure to avoid running tests - * that clash for resources, So leave it as the developers choice to - * enable while working on the needed infra. - */ - bool parallel =3D false; const struct option test_options[] =3D { OPT_STRING('s', "skip", &skip, "tests", "tests to skip"), OPT_INCR('v', "verbose", &verbose, "be more verbose (show symbol address, etc)"), OPT_BOOLEAN('F', "dont-fork", &dont_fork, "Do not fork for testcase"), - OPT_BOOLEAN('p', "parallel", ¶llel, "Run the tests in parallel"), OPT_BOOLEAN('S', "sequential", &sequential, "Run the tests one after another rather than in parallel"), OPT_STRING('w', "workload", &workload, "work", "workload to run for testi= ng"), @@ -662,8 +655,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.rc1.288.g06298d1525-goog