From: sashiko-bot@kernel.org
To: "James Clark" <james.clark@linaro.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v3 03/19] perf test: Add a workload that forces context switches
Date: Wed, 03 Jun 2026 10:28:17 +0000 [thread overview]
Message-ID: <20260603102817.EFB021F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260603-james-cs-context-tracking-fix-v3-3-c392945d9ed5@linaro.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Calling exit(1) on I/O failure in the parent process abruptly terminates the test wrapper and bypasses workload control cleanup.
--
commit 4bc96eb1d44f39f8252cd4bbe7f402600bc7ca26
Author: James Clark <james.clark@linaro.org>
perf test: Add a workload that forces context switches
This workload launches two processes that block when reading and writing
to each other forcing the other process to be scheduled for each
read/write pair.
> diff --git a/tools/perf/tests/workloads/context_switch_loop.c b/tools/perf/tests/workloads/context_switch_loop.c
> new file mode 100644
> index 0000000000000..173d770ae6192
> --- /dev/null
> +++ b/tools/perf/tests/workloads/context_switch_loop.c
> @@ -0,0 +1,101 @@
[ ... ]
> +#define write_block(fd) \
> + do { \
> + if (write(fd, &buf, 1) <= 0) \
> + exit(1); \
> + } while (0)
> +
> +#define read_block(fd) \
> + do { \
> + if (read(fd, &buf, 1) <= 0) \
> + exit(1); \
> + } while (0)
[ ... ]
> + if (!proc1_pid) {
> + close(a_to_b[0]);
> + close(b_to_a[1]);
> + prctl(PR_SET_NAME, "proc1", 0, 0, 0);
> + context_switch_loop_proc1(b_to_a[0], a_to_b[1]);
> + close(a_to_b[1]);
> + close(b_to_a[0]);
> + exit(0);
> + }
> +
> + close(a_to_b[1]);
> + close(b_to_a[0]);
> + prctl(PR_SET_NAME, "proc2", 0, 0, 0);
> + context_switch_loop_proc2(a_to_b[0], b_to_a[1]);
[Severity: Medium]
Since context_switch_loop_proc2() runs in the parent process, does calling
exit(1) on I/O failures abruptly terminate the entire perf test wrapper?
If write_block() or read_block() encounter an error like EINTR, they call
exit(1) directly. Because context_switch_loop_proc2() is executed in the main
process rather than a forked child, this bypasses the workload control cleanup
in run_workload().
Should the parent process return an error code instead of calling exit(1) so
perf test can clean up gracefully?
> + close(a_to_b[0]);
> + close(b_to_a[1]);
> +
> + if (waitpid(proc1_pid, &status, 0) != proc1_pid || !WIFEXITED(status) ||
> + WEXITSTATUS(status))
> + return 1;
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260603-james-cs-context-tracking-fix-v3-0-c392945d9ed5@linaro.org?part=3
next prev parent reply other threads:[~2026-06-03 10:28 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 10:17 [PATCH v3 00/19] perf cs-etm: Queue context packets for frontend James Clark
2026-06-03 10:17 ` [PATCH v3 01/19] " James Clark
2026-06-03 10:32 ` sashiko-bot
2026-06-03 20:14 ` Amir Ayupov
2026-06-03 10:17 ` [PATCH v3 02/19] perf test: Add workload-ctl option James Clark
2026-06-03 10:17 ` [PATCH v3 03/19] perf test: Add a workload that forces context switches James Clark
2026-06-03 10:28 ` sashiko-bot [this message]
2026-06-03 10:17 ` [PATCH v3 04/19] perf test cs-etm: Test process attribution James Clark
2026-06-03 10:17 ` [PATCH v3 05/19] perf test: Add deterministic workload James Clark
2026-06-03 10:24 ` sashiko-bot
2026-06-03 10:17 ` [PATCH v3 06/19] perf test cs-etm: Replace unroll loop thread with deterministic decode test James Clark
2026-06-03 10:30 ` sashiko-bot
2026-06-03 10:17 ` [PATCH v3 07/19] perf test cs-etm: Remove asm_pure_loop test James Clark
2026-06-03 10:17 ` [PATCH v3 08/19] perf test cs-etm: Replace memcpy test with raw dump stress test James Clark
2026-06-03 10:17 ` [PATCH v3 09/19] perf test: Add named_threads workload James Clark
2026-06-03 10:26 ` sashiko-bot
2026-06-03 10:17 ` [PATCH v3 10/19] perf test cs-etm: Test decoding for concurrent threads test James Clark
2026-06-03 10:17 ` [PATCH v3 11/19] perf test cs-etm: Remove duplicate branch tests James Clark
2026-06-03 10:17 ` [PATCH v3 12/19] perf test cs-etm: Skip if not root James Clark
2026-06-03 10:17 ` [PATCH v3 13/19] perf test cs-etm: Reduce snapshot size James Clark
2026-06-03 10:17 ` [PATCH v3 14/19] perf test cs-etm: Speed up basic test James Clark
2026-06-03 10:17 ` [PATCH v3 15/19] perf test cs-etm: Remove unused Coresight workloads James Clark
2026-06-03 10:41 ` sashiko-bot
2026-06-03 10:17 ` [PATCH v3 16/19] perf test cs-etm: Make disassembly test use kcore James Clark
2026-06-03 10:36 ` sashiko-bot
2026-06-03 10:17 ` [PATCH v3 17/19] perf test cs-etm: Add all branch instructions to test James Clark
2026-06-03 10:17 ` [PATCH v3 18/19] perf test cs-etm: Speed up disassembly test James Clark
2026-06-03 10:17 ` [PATCH v3 19/19] perf test cs-etm: Move existing tests to coresight folder James Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260603102817.EFB021F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=james.clark@linaro.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox