Re: [PATCH] selftests/bpf: Page out as late a possible in file_reader

sashiko-bot
2026-04-20T23:13:28Z

Sashiko AI review found 1 potential issue(s):
- [Low] The newly promoted global variable `addr` is declared without the `static` keyword, polluting the global namespace.
--

commit e2c581de007abac2e6985b4f49f6c9786c3263b0
Author: Jerome Marchand <jmarchan@redhat.com>

selftests/bpf: Page out as late a possible in file_reader

The file_reader/on_open_expect_fault fails consistently on my system.
This commit moves the call to madvise(MADV_PAGEOUT) to just before
attaching the program to minimize the risk of having those pages pulled
back in.

> diff --git a/tools/testing/selftests/bpf/prog_tests/file_reader.c b/tools/testing/selftests/bpf/prog_tests/file_reader.c
> index 5cde32b35da44..48aae7ea0e4bb 100644
> --- a/tools/testing/selftests/bpf/prog_tests/file_reader.c
> +++ b/tools/testing/selftests/bpf/prog_tests/file_reader.c
> @@ -10,6 +10,7 @@
>
> const char *user_ptr = "hello world";
> char file_contents[256000];
> +void *addr;

This isn't a bug, but BPF selftests link all prog_tests/*.c files together
into a single test_progs executable.

Since modern compilers use -fno-common by default, could this un-prefixed
global variable cause a multiple definition linker error if another test
introduces a global variable with the same name?

Should addr be declared as static to safely restrict its linkage to
file_reader.c?

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260420134637.2513867-1-jmarchan@redhat.com?part=1