From: sashiko-bot@kernel.org
To: "James Clark" <james.clark@linaro.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 03/18] perf test: Add a workload that forces context switches
Date: Tue, 02 Jun 2026 14:38:40 +0000 [thread overview]
Message-ID: <20260602143841.1AAEB1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602-james-cs-context-tracking-fix-v2-3-85b5ce6f55c6@linaro.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Parent process fails to close unused pipe ends, causing a deadlock if the child exits prematurely, and leaks file descriptors on all paths.
--
commit 4b7337e6446674341b89bdd15dec4b286776529f
Author: James Clark <james.clark@linaro.org>
perf test: Add a workload that forces context switches
This commit adds a new test workload that forces context switches by launching
two processes that block when reading and writing to each other.
> 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..73bfcaeff5b09
> --- /dev/null
> +++ b/tools/perf/tests/workloads/context_switch_loop.c
[ ... ]
> +static int context_switch_loop(int argc, const char **argv)
> +{
> + int a_to_b[2], b_to_a[2];
> + pid_t proc1_pid;
> + int status;
[ ... ]
> + if (pipe(a_to_b) || pipe(b_to_a)) {
[Severity: Medium]
If pipe(b_to_a) fails, does this return 1 and leak the file descriptors
successfully allocated by pipe(a_to_b)?
> + perror("Pipe error");
> + return 1;
> + }
> +
> + proc1_pid = fork();
> + if (proc1_pid < 0) {
> + perror("Fork error");
> + return 1;
[Severity: Medium]
Similarly, does this error path leak all 4 file descriptors allocated by the
pipes?
> + }
> +
> + 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]);
> + exit(0);
> + }
> +
> + prctl(PR_SET_NAME, "proc2", 0, 0, 0);
> + context_switch_loop_proc2(a_to_b[0], b_to_a[1]);
[Severity: Medium]
Does the parent process (proc2) need to close its unused pipe ends (a_to_b[1]
and b_to_a[0]) before executing its workload loop?
If the child process (proc1) terminates unexpectedly or calls exit(1) (e.g.,
due to a read/write error), it closes its file descriptors. However, the parent
waiting in read(a_to_b[0]) will not receive an EOF (0) because it still holds
the write end a_to_b[1] open itself. This could cause the parent to block
indefinitely and hang the test suite.
> +
> + if (waitpid(proc1_pid, &status, 0) != proc1_pid || !WIFEXITED(status) ||
> + WEXITSTATUS(status))
> + return 1;
> +
> + return 0;
[Severity: Medium]
Do the waitpid error path and successful return path both exit without closing
the remaining pipe file descriptors?
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260602-james-cs-context-tracking-fix-v2-0-85b5ce6f55c6@linaro.org?part=3
next prev parent reply other threads:[~2026-06-02 14:38 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 14:26 [PATCH v2 00/18] perf cs-etm: Queue context packets for frontend James Clark
2026-06-02 14:26 ` [PATCH v2 01/18] " James Clark
2026-06-02 14:43 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 02/18] perf test: Add workload-ctl option James Clark
2026-06-02 14:40 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 03/18] perf test: Add a workload that forces context switches James Clark
2026-06-02 14:38 ` sashiko-bot [this message]
2026-06-02 14:26 ` [PATCH v2 04/18] perf test cs-etm: Test process attribution James Clark
2026-06-02 14:26 ` [PATCH v2 05/18] perf test: Add deterministic workload James Clark
2026-06-02 14:49 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 06/18] perf test cs-etm: Replace unroll loop thread with deterministic decode test James Clark
2026-06-02 14:26 ` [PATCH v2 07/18] perf test cs-etm: Remove asm_pure_loop test James Clark
2026-06-02 14:26 ` [PATCH v2 08/18] perf test cs-etm: Replace memcpy test with raw dump stress test James Clark
2026-06-02 15:01 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 09/18] perf test: Add named_threads workload James Clark
2026-06-02 15:01 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 10/18] perf test cs-etm: Test decoding for concurrent threads test James Clark
2026-06-02 14:26 ` [PATCH v2 11/18] perf test cs-etm: Remove duplicate branch tests James Clark
2026-06-02 15:05 ` sashiko-bot
2026-06-02 14:26 ` [PATCH v2 12/18] perf test cs-etm: Reduce snapshot size James Clark
2026-06-02 14:26 ` [PATCH v2 13/18] perf test cs-etm: Speed up basic test James Clark
2026-06-02 14:26 ` [PATCH v2 14/18] perf test cs-etm: Remove unused Coresight workloads James Clark
2026-06-02 14:26 ` [PATCH v2 15/18] perf test cs-etm: Make disassembly test use kcore James Clark
2026-06-02 14:26 ` [PATCH v2 16/18] perf test cs-etm: Add all branch instructions to test James Clark
2026-06-02 14:26 ` [PATCH v2 17/18] perf test cs-etm: Speed up disassembly test James Clark
2026-06-02 15:26 ` sashiko-bot
2026-06-02 14:27 ` [PATCH v2 18/18] 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=20260602143841.1AAEB1F00893@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