Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Fix intermittent failures in file_reader test

file_reader/on_open_expect_fault intermittently fails when test_progs
runs tests in parallel, because it expects a page fault on first read.
Another file_reader test running concurrently may have already pulled
the same pages into the page cache, eliminating the fault and causing a
spurious failure.

Make file_reader/on_open_expect_fault read from a file region that does
not overlap with other file_reader tests, so the initial access still
faults even under parallel execution.

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/r/20251029195907.858217-1-mykyta.yatsenko5@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Mykyta Yatsenko and committed by
Alexei Starovoitov
5913e936 e2e668bd

+6 -2
+5 -1
tools/testing/selftests/bpf/prog_tests/file_reader.c
··· 52 52 /* page-align base file address */ 53 53 addr = (void *)((unsigned long)addr & ~(page_sz - 1)); 54 54 55 - for (off = 0; off < sizeof(file_contents); off += page_sz) { 55 + /* 56 + * Page out range 0..512K, use 0..256K for positive tests and 57 + * 256K..512K for negative tests expecting page faults 58 + */ 59 + for (off = 0; off < sizeof(file_contents) * 2; off += page_sz) { 56 60 if (!ASSERT_OK(madvise(addr + off, page_sz, MADV_PAGEOUT), 57 61 "madvise pageout")) 58 62 return errno;
+1 -1
tools/testing/selftests/bpf/progs/file_reader.c
··· 49 49 if (bpf_dynptr_from_file(file, 0, &dynptr)) 50 50 goto out; 51 51 52 - local_err = bpf_dynptr_read(tmp_buf, user_buf_sz, &dynptr, 0, 0); 52 + local_err = bpf_dynptr_read(tmp_buf, user_buf_sz, &dynptr, user_buf_sz, 0); 53 53 if (local_err == -EFAULT) { /* Expect page fault */ 54 54 local_err = 0; 55 55 run_success = 1;