Skip to contentSkip to conversation

selftests/bpf: Report the real error from libarena parallel workers

PATCH Applied Jiayuan Chen 4 participants 5 messages Jul 23 – Jul 28

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests/bpf: Report the real error from libarena parallel workers

Several CI runs failed in the libarena parallel tests with -4 (-EINTR) [1], which says nothing about what actually went wrong.

Two workers can fail like this:

worker 1: gives up, e.g. the rendezvous times out, sets test_abort and
returns its own error (-ETIMEDOUT)
worker 2: sees test_abort and returns -EINTR

-EINTR only means "someone else already gave up", so it carries no information. Which of the two gets reported depends on the order pthread_join() collects them, because

	err = err ?: (long)thread_ret;

keeps the first non-zero value and drops the rest. When the -EINTR worker comes first, the error describing the actual failure is lost.

Skip -EINTR entirely: a worker only returns it once another worker has already reported the real error, so report and log only the real errors.

It is still unclear whether the timeouts come from CI load or from a problem in the test itself. Report the error accurately first, so the next failure can be diagnosed.

[1]:
https://github.com/kernel-patches/bpf/actions/runs/29867905253/job/88764463566
https://github.com/kernel-patches/bpf/actions/runs/29878191901/job/88794845824

---
v1 -> v2:
- hoist the worker_err declaration to the top of the function
- skip -EINTR workers entirely: do not aggregate and do not log them
- comment/commit message wording fixes

v1: https://lore.kernel.org/bpf/[email protected]/

---
 .../selftests/bpf/prog_tests/libarena.c        | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/libarena.c +17 -1
index df7e4b8dc394..daade4150af6 100644
@@ -73,6 +73,7 @@ static int run_libarena_parallel_test_workers(struct libarena *skel,
 	uint32_t nthreads;
 	void *thread_ret;
 	int ret, err = 0;
+	int worker_err;
 	int i;
 
 	for (nthreads = 0; nthreads < UINT_MAX; nthreads++) {
@@ -118,7 +119,22 @@ static int run_libarena_parallel_test_workers(struct libarena *skel,
 			continue;
 		}
 
-		err = err ?: (long)thread_ret;
+		worker_err = (long)thread_ret;
+
+		/*
+		 * A worker that bails out because another one already gave up
+		 * reports -EINTR. It is collateral damage that carries no
+		 * information, so skip it entirely: never let it become the
+		 * reported error, and don't log it either.
+		 */
+		if (!worker_err || worker_err == -EINTR)
+			continue;
+
+		if (!err)
+			err = worker_err;
+
+		fprintf(stdout, "%.*s__%d returned %d\n", (int)prefixlen, name,
+			i, worker_err);
 	}
 
 	free(threads);
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Skipping `-EINTR` completely causes interrupted tests to falsely pass. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Skipping -EINTR completely causes interrupted tests to falsely pass. --

--- Patch [1]: [PATCH bpf-next v2] selftests/bpf: Report the real error from libarena parallel workers --- commit a35a4526e56449664def8e15919986cc43126b84
Author: Jiayuan Chen <[email protected]>

selftests/bpf: Report the real error from libarena parallel workers

This commit updates the error collection logic in the libarena parallel tests to skip -EINTR. The goal is to ensure the real failure is reported rather than losing it when another worker thread bails out early.

Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/libarena.c +0 -0
index df7e4b8dc3945..daade4150af66 100644

[ ... ]

Quoted 8 lines
tools/testing/selftests/bpf/prog_tests/libarena.c +3 -1
@@ -118,7 +119,22 @@ static int run_libarena_parallel_test_workers(struct libarena *skel,
 			continue;
 		}
 
-		err = err ?: (long)thread_ret;
+		worker_err = (long)thread_ret;
+
+		/*

tools/testing/selftests/bpf/prog_tests/libarena.c static int run_libarena_parallel_test_workers(struct libarena *skel, · line 134

Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/libarena.c +10 -0
+		 * A worker that bails out because another one already gave up
+		 * reports -EINTR. It is collateral damage that carries no
+		 * information, so skip it entirely: never let it become the
+		 * reported error, and don't log it either.
+		 */
+		if (!worker_err || worker_err == -EINTR)
+			continue;
+
+		if (!err)
+			err = worker_err;

[Severity: Medium]
If all worker threads return -EINTR due to a process-wide signal, such as a global CI timeout or user SIGINT, does this loop leave err initialized to 0 and falsely report the test as passed?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
Quoted 37 lines · On 7/23/26 2:24 PM, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Skipping -EINTR completely causes interrupted tests to falsely pass. --

--- Patch [1]: [PATCH bpf-next v2] selftests/bpf: Report the real error from libarena parallel workers --- commit a35a4526e56449664def8e15919986cc43126b84
Author: Jiayuan Chen <[email protected]>

selftests/bpf: Report the real error from libarena parallel workers

This commit updates the error collection logic in the libarena parallel tests to skip -EINTR. The goal is to ensure the real failure is reported rather than losing it when another worker thread bails out early.

Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/libarena.c +0 -0
index df7e4b8dc3945..daade4150af66 100644

[ ... ]

Quoted 14 lines
tools/testing/selftests/bpf/prog_tests/libarena.c +9 -1
@@ -118,7 +119,22 @@ static int run_libarena_parallel_test_workers(struct libarena *skel,
  			continue;
  		}
 
-		err = err ?: (long)thread_ret;
+		worker_err = (long)thread_ret;
+
+		/*
+		 * A worker that bails out because another one already gave up
+		 * reports -EINTR. It is collateral damage that carries no
+		 * information, so skip it entirely: never let it become the
+		 * reported error, and don't log it either.
+		 */
+		if (!worker_err || worker_err == -EINTR)
Quoted 8 lines

tools/testing/selftests/bpf/prog_tests/libarena.c static int run_libarena_parallel_test_workers(struct libarena *skel, · line 134

Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/libarena.c +4 -0
+			continue;
+
+		if (!err)
+			err = worker_err;

[Severity: Medium]
If all worker threads return -EINTR due to a process-wide signal, such as a global CI timeout or user SIGINT, does this loop leave err initialized to 0 and falsely report the test as passed?

The bpf_prog_test_run_syscall() path has no way to return -EINTR; a worker returns -EINTR only when test_abort is true, and test_abort is never set without another worker returning the real error, so the workers can never all return -EINTR.

And even if some future signal-based exit were added to the syscall path, by then correctness is already moot....

reviewer Reviewed-by on v2 1/1
#3 lore raw
In reply to Jiayuan Chen
Quoted 25 lines · Jiayuan Chen

Several CI runs failed in the libarena parallel tests with -4 (-EINTR) [1], which says nothing about what actually went wrong.

Two workers can fail like this:

worker 1: gives up, e.g. the rendezvous times out, sets test_abort and
returns its own error (-ETIMEDOUT)
worker 2: sees test_abort and returns -EINTR

-EINTR only means "someone else already gave up", so it carries no information. Which of the two gets reported depends on the order pthread_join() collects them, because

	err = err ?: (long)thread_ret;

keeps the first non-zero value and drops the rest. When the -EINTR worker comes first, the error describing the actual failure is lost.

Skip -EINTR entirely: a worker only returns it once another worker has already reported the real error, so report and log only the real errors.

It is still unclear whether the timeouts come from CI load or from a problem in the test itself. Report the error accurately first, so the next failure can be diagnosed.

Quoted 5 lines

[1]:
https://github.com/kernel-patches/bpf/actions/runs/29867905253/job/88764463566
https://github.com/kernel-patches/bpf/actions/runs/29878191901/job/88794845824

Quoted 48 lines

---
v1 -> v2:
- hoist the worker_err declaration to the top of the function
- skip -EINTR workers entirely: do not aggregate and do not log them
- comment/commit message wording fixes

v1: https://lore.kernel.org/bpf/[email protected]/

---
 .../selftests/bpf/prog_tests/libarena.c        | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/libarena.c +17 -1
index df7e4b8dc394..daade4150af6 100644
@@ -73,6 +73,7 @@ static int run_libarena_parallel_test_workers(struct libarena *skel,
 	uint32_t nthreads;
 	void *thread_ret;
 	int ret, err = 0;
+	int worker_err;
 	int i;
 
 	for (nthreads = 0; nthreads < UINT_MAX; nthreads++) {
@@ -118,7 +119,22 @@ static int run_libarena_parallel_test_workers(struct libarena *skel,
 			continue;
 		}
 
-		err = err ?: (long)thread_ret;
+		worker_err = (long)thread_ret;
+
+		/*
+		 * A worker that bails out because another one already gave up
+		 * reports -EINTR. It is collateral damage that carries no
+		 * information, so skip it entirely: never let it become the
+		 * reported error, and don't log it either.
+		 */
+		if (!worker_err || worker_err == -EINTR)
+			continue;
+
+		if (!err)
+			err = worker_err;
+
+		fprintf(stdout, "%.*s__%d returned %d\n", (int)prefixlen, name,
+			i, worker_err);
 	}
 
 	free(threads);
#4 lore raw
In reply to Jiayuan Chen
This patch was applied to bpf/bpf-next.git (master) by Kumar Kartikeya Dwivedi <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Kumar Kartikeya Dwivedi <[email protected]>:

Quoted 10 lines · On Thu, 23 Jul 2026 14:13:37 +0800 you wrote:

Several CI runs failed in the libarena parallel tests with -4 (-EINTR) [1], which says nothing about what actually went wrong.

Two workers can fail like this:

worker 1: gives up, e.g. the rendezvous times out, sets test_abort and
returns its own error (-ETIMEDOUT)
worker 2: sees test_abort and returns -EINTR

[...]

Here is the summary with links:
- [bpf-next,v2] selftests/bpf: Report the real error from libarena parallel workers

    https://git.kernel.org/bpf/bpf-next/c/fdec474c65fd

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html