Re: [PATCH bpf-next v2] selftests/bpf: Avoid flaky resize value test for percpu data
Leon Hwang <[email protected]>
| Newsgroups | org.kernel.vger.bpf,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest |
|---|---|
| Message-ID | <[email protected]> |
On 22/8/26 01:58, Andrii Nakryiko wrote: > On Tue, Aug 18, 2026 at 6:44 PM Leon Hwang <[email protected]> wrote: >> >> On 19/8/26 00:15, [email protected] wrote: >>>> diff --git a/tools/testing/selftests/bpf/prog_tests/global_data_init.c b/tools/testing/selftests/bpf/prog_tests/global_data_init.c >>>> index 5671c31085cd..2b69290bcc3e 100644 >>>> --- a/tools/testing/selftests/bpf/prog_tests/global_data_init.c >>>> +++ b/tools/testing/selftests/bpf/prog_tests/global_data_init.c >>> >>> [ ... ] >>> >>>> @@ -236,6 +223,57 @@ static void test_global_percpu_data_lskel(void) >>>> test_global_percpu_data_lskel__destroy(lskel); >>>> } >>>> >>>> +#define PAGE_SIZE 4096 >>>> + >>>> +static void test_global_percpu_data_map_resize(void) >>>> +{ >>>> + const __u32 desired_sz = sysconf(_SC_PAGE_SIZE) * 2; >>>> + struct test_global_percpu_data *skel; >>>> + const int arr_value = -1; >>>> + struct bpf_map *map; >>>> + int err, prog_fd; >>>> + size_t data_sz; >>>> + >>>> + if (sysconf(_SC_PAGE_SIZE) != PAGE_SIZE) { >>>> + test__skip(); >>>> + return; >>>> + } >>>> + >>>> + skel = test_global_percpu_data__open(); >>>> + if (!ASSERT_OK_PTR(skel, "test_global_percpu_data__open")) >>>> + return; >>>> + >>>> + map = skel->maps.percpu_arr; >>>> + skel->percpu_arr->arr[0] = arr_value; >>>> + err = bpf_map__set_value_size(map, desired_sz); >>> >>> This isn't a bug, but since the guard above already pins the page size to >>> 4096, would `const __u32 desired_sz = PAGE_SIZE * 2;` read more directly >> >> Will change to 'PAGE_SIZE * 2' if the next revision is needed. >> >>> here - and is the unguarded `#define PAGE_SIZE 4096` preferable to the >>> `#ifndef PAGE_SIZE` form used in sockopt.c? >> >> No. PAGE_SIZE must be 4096 here. >> > > can you please elaborate why do we care about specific PAGE_SIZE > value? it's a bit weird to guard test based on page size... > It is to verify the mmap change in libbpf's bpf_map_mmap_resize() for percpu data map, like those subtests in global_map_resize.c. Thanks, Leon