Skip to contentSkip to conversation

selftests/bpf: Fix flaky file_reader test

PATCH Applied Mykyta Yatsenko 3 participants 4 messages Jun 3 – Jun 5

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

PATCH 1/1 selftests/bpf: Fix flaky file_reader test

From: Mykyta Yatsenko <[email protected]>

file_reader/on_open_expect_fault test expects page fault when reading pages from the test harness executable. It is not guaranteed that those are paged out, even after madvise(MADV_PAGEOUT).
Relax the condition in the test to succeed with both 0 and -EFAULT returned.

Fixes 784cdf931543 ("selftests/bpf: add file dynptr tests")
---
 tools/testing/selftests/bpf/progs/file_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/file_reader.c +1 -1
index 462712ff3b8a..aa2c05cce2b3 100644
@@ -50,7 +50,7 @@ int on_open_expect_fault(void *c)
 		goto out;
 
 	local_err = bpf_dynptr_read(tmp_buf, user_buf_sz, &dynptr, user_buf_sz, 0);
-	if (local_err == -EFAULT) { /* Expect page fault */
+	if (local_err == -EFAULT || local_err == 0) { /* Expect page fault or success */
 		local_err = 0;
 		run_success = 1;
 	}

---
base-commit: 245da8192c073820390f7fa1cc1e834b32119bce
change-id: 20260603-file_reader_flake-bf0753be6b2e

Best regards,

Signature · 1 line
Mykyta Yatsenko <[email protected]>
reviewer Tested-by on v1 1/1
#2 lore raw
In reply to Mykyta Yatsenko
Quoted 9 lines · Mykyta Yatsenko

From: Mykyta Yatsenko <[email protected]>

file_reader/on_open_expect_fault test expects page fault when reading pages from the test harness executable. It is not guaranteed that those are paged out, even after madvise(MADV_PAGEOUT).
Relax the condition in the test to succeed with both 0 and -EFAULT returned.

Quoted 4 lines
Fixes 784cdf931543 ("selftests/bpf: add file dynptr tests")

Hi Mykyta,

I tried the patch on libbpf/libbpf CI, the test was consistently failing there. It works [1], thanks!

[1] https://github.com/libbpf/libbpf/actions/runs/27032965962

Quoted 26 lines
---
 tools/testing/selftests/bpf/progs/file_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/file_reader.c +1 -2
index 462712ff3b8a..aa2c05cce2b3 100644
@@ -50,7 +50,7 @@ int on_open_expect_fault(void *c)
 		goto out;
 
 	local_err = bpf_dynptr_read(tmp_buf, user_buf_sz, &dynptr, user_buf_sz, 0);
-	if (local_err == -EFAULT) { /* Expect page fault */
+	if (local_err == -EFAULT || local_err == 0) { /* Expect page fault or success */
 		local_err = 0;
 		run_success = 1;
 	}
 
---

base-commit: 245da8192c073820390f7fa1cc1e834b32119bce
change-id: 20260603-file_reader_flake-bf0753be6b2e

Best regards,

Signature · 1 line
Mykyta Yatsenko <[email protected]>
#3 lore raw
In reply to Mykyta Yatsenko
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

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

Quoted 10 lines · On Wed, 03 Jun 2026 07:39:15 -0700 you wrote:

From: Mykyta Yatsenko <[email protected]>

file_reader/on_open_expect_fault test expects page fault when reading pages from the test harness executable. It is not guaranteed that those are paged out, even after madvise(MADV_PAGEOUT).
Relax the condition in the test to succeed with both 0 and -EFAULT returned.

[...]

Here is the summary with links:
- selftests/bpf: Fix flaky file_reader test

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

You are awesome, thank you!

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