selftests/bpf: Avoid flaky resize value test for percpu data
Subsystems (3)
PATCH v2 1/1 selftests/bpf: Avoid flaky resize value test for percpu data
The bpf_map__set_value_size() test for percpu data relies on the tail 'cpu_id' field in the ".percpu" map. The test would fail, when 'cpu_id' is not the last field in the map.
To avoid the flaky test, factor out a subtest to use a dedicated ".percpu.arr" map that only has one field 'int arr[1]' to ensure that bpf_map__set_value_size() won't fail on 4K page systems.
And, drop 'args' in test_percpu_data_on_cpus(), which isn't used in bpf prog side.
And, enhance the test to cover 'set' and 'nums[6]'.
---
v1 -> v2:
* Factor out a subtest to test bpf_map__set_value_size().
* Run the new subtest only on 4K page systems. (Sashiko)
* v1: https://lore.kernel.org/bpf/[email protected]/
--- .../bpf/prog_tests/global_data_init.c | 86 ++++++++++++++----- .../bpf/progs/test_global_percpu_data.c | 10 ++- 2 files changed, 70 insertions(+), 26 deletions(-)
tools/testing/selftests/bpf/prog_tests/global_data_init.c +63 -23
@@ -68,12 +68,9 @@ static void test_percpu_data_on_cpus(struct bpf_map *map, int map_fd, int prog_f {struct test_global_percpu_data__percpu *data =NULL ;int i, err, key =0 , num_online, run =0 ; -__u64 args[2 ] = {0x1234ULL ,0x5678ULL };size_t data_sz;bool *online;LIBBPF_OPTS (bpf_test_run_opts, topts, - .ctx_in = args, - .ctx_size_in = sizeof(args), .flags = BPF_F_TEST_RUN_ON_CPU, );
@@ -81,7 +78,7 @@ static void test_percpu_data_on_cpus(struct bpf_map *map, int map_fd, int prog_fif (!ASSERT_OK (err,"parse_cpu_mask_file" ))return ; - data_sz = map ?bpf_map__value_size (map) :sizeof (*data); + data_sz =sizeof (*data); data =calloc (1 , data_sz);if (!ASSERT_OK_PTR (data,"calloc percpu data" )) goto out;
@@ -109,7 +106,7 @@ static void test_percpu_data_on_cpus(struct bpf_map *map, int map_fd, int prog_fbreak ;ASSERT_EQ (*runp, ++run,"run" ); -ASSERT_EQ (data->cpu_id[0 ], i,"cpu_id" ); +ASSERT_EQ (data->cpu_id, i,"cpu_id" );ASSERT_EQ (data->data,1 ,"data" );ASSERT_TRUE (data->set,"set" );ASSERT_EQ (data->nums[6 ],0xc0de ,"nums[6]" );
@@ -127,7 +124,6 @@ static void test_global_percpu_data_init(void) {struct test_global_percpu_data__percpu init_value = {};struct test_global_percpu_data__percpu *init_data; -const __u32 desired_sz =sysconf (_SC_PAGE_SIZE);struct test_global_percpu_data *skel =NULL ;size_t init_data_sz;struct bpf_map *map;
@@ -163,9 +159,11 @@ static void test_global_percpu_data_init(void)if (!ASSERT_EQ (bpf_map__type (map),BPF_MAP_TYPE_PERCPU_ARRAY ,"bpf_map__type" )) goto out; + init_value.set =1 ; init_value.data =2 ; init_value.nums[6 ] =-1 ; init_value.struct_data.i =2 ; + init_value.struct_data.set =1 ; init_value.struct_data.nums[6 ] =-1 ; err =bpf_map__set_initial_value (map, &init_value,sizeof (init_value));if (!ASSERT_OK (err,"bpf_map__set_initial_value" ))
@@ -177,35 +175,24 @@ static void test_global_percpu_data_init(void)ASSERT_EQ (init_data->data, init_value.data,"init_value data" );ASSERT_EQ (init_data->set, init_value.set,"init_value set" ); +ASSERT_EQ (init_data->nums[6 ], init_value.nums[6 ],"init_value nums[6]" );ASSERT_EQ (init_data->struct_data.i, init_value.struct_data.i,"init_value struct_data.i" ); +ASSERT_EQ (init_data->struct_data.set, init_value.struct_data.set, +"init_value struct_data.set" );ASSERT_EQ (init_data->struct_data.nums[6 ], init_value.struct_data.nums[6 ],"init_value struct_data.nums[6]" );ASSERT_EQ (init_data_sz,sizeof (init_value),"init_value size" );ASSERT_EQ ((void *) init_data, (void *) skel->percpu,"skel->percpu eq init_data" );ASSERT_EQ (skel->percpu->data, init_value.data,"skel->percpu->data" );ASSERT_EQ (skel->percpu->set, init_value.set,"skel->percpu->set" ); +ASSERT_EQ (skel->percpu->nums[6 ], init_value.nums[6 ],"skel->percpu->nums[6]" );ASSERT_EQ (skel->percpu->struct_data.i, init_value.struct_data.i,"skel->percpu->struct_data.i" ); +ASSERT_EQ (skel->percpu->struct_data.set, init_value.struct_data.set, +"skel->percpu->struct_data.set" );ASSERT_EQ (skel->percpu->struct_data.nums[6 ], init_value.struct_data.nums[6 ],"skel->percpu->struct_data.nums[6]" ); -ASSERT_GT (desired_sz,sizeof (init_value),"desired_sz" ); - err =bpf_map__set_value_size (map, desired_sz); -if (!ASSERT_OK (err,"bpf_map__set_value_size" )) - goto out; -if (!ASSERT_EQ (bpf_map__value_size (map), desired_sz,"percpu value size" )) - goto out; -if (!ASSERT_NEQ (bpf_map__btf_value_type_id (map),0 ,"percpu BTF value type" )) - goto out; - - init_data =bpf_map__initial_value (map, &init_data_sz); -if (!ASSERT_OK_PTR (init_data,"resized bpf_map__initial_value" )) - goto out; -if (!ASSERT_EQ (init_data_sz, desired_sz,"resized initial value size" )) - goto out; -if (!ASSERT_EQ (init_data->data, init_value.data,"resized initial value data" )) - goto out; - err =test_global_percpu_data__load (skel);if (!ASSERT_OK (err,"test_global_percpu_data__load" )) goto out;
@@ -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); +if (!ASSERT_OK (err,"bpf_map__set_value_size" )) + goto out; +if (!ASSERT_EQ (bpf_map__value_size (map), desired_sz,"bpf_map__value_size" )) + goto out; +if (!ASSERT_NEQ (bpf_map__btf_value_type_id (map),0 ,"bpf_map__btf_value_type_id" )) + goto out; + + skel->percpu_arr =bpf_map__initial_value (map, &data_sz); +if (!ASSERT_EQ (data_sz, desired_sz,"data_sz" )) + goto out; +if (!ASSERT_OK_PTR (skel->percpu_arr,"skel->percpu_arr" )) + goto out; +if (!ASSERT_EQ (skel->percpu_arr->arr[0 ], arr_value,"arr[0]" )) + goto out; + + err =test_global_percpu_data__load (skel); +if (!ASSERT_OK (err,"test_global_percpu_data__load" )) + goto out; + + map = skel->maps.percpu; + prog_fd =bpf_program__fd (skel->progs.update_percpu_data); +test_percpu_data_on_cpus (map,bpf_map__fd (map), prog_fd, &skel->bss->run); +ASSERT_EQ (skel->bss->arr_sum, arr_value * skel->bss->run,"arr_sum" ); + +out: +test_global_percpu_data__destroy (skel); +} +static int create_rdonly_percpu_array (void ) { LIBBPF_OPTS(bpf_map_create_opts, map_opts,
@@ -388,6 +426,8 @@ void test_global_percpu_data(void)test_global_percpu_data_init ();if (test__start_subtest ("lskel" ))test_global_percpu_data_lskel (); +if (test__start_subtest ("map_resize" )) +test_global_percpu_data_map_resize ();if (test__start_subtest ("rdonly_direct_read" ))test_global_percpu_data_rdonly_direct_read ();if (test__start_subtest ("rdonly_direct_write" ))
tools/testing/selftests/bpf/progs/test_global_percpu_data.c +7 -3
@@ -8,9 +8,12 @@ int loong SEC(".percpu.looooooooong"); int data3 SEC(".data.percpu"); int data2 SEC(".percpu.data"); +/* Used for testing bpf_map__set_value_size(). */ +int arr[1] SEC(".percpu.arr"); +int arr_sum; +int run; -/* cpu_id as array to verify map value resizing. */ -int cpu_id[1] SEC(".percpu"); +int cpu_id SEC(".percpu"); int data SEC(".percpu") = -1; int nums[7] SEC(".percpu"); bool set SEC(".percpu") = false;
@@ -34,7 +37,8 @@ int update_percpu_data(void *ctx) data =1 ; run++; set = true; - cpu_id[0 ] =bpf_get_smp_processor_id (); + cpu_id =bpf_get_smp_processor_id (); + arr_sum += arr[0 ];return 0 ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewThis 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 here - and is the unguarded `#define PAGE_SIZE…
Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +0
-0
[ ... ]
Quoted 17 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +13
-0@@ -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 ();
tools/testing/selftests/bpf/prog_tests/global_data_init.c static void test_global_percpu_data_lskel(void) · line 248
Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +10
-0+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 here - and is the unguarded #define PAGE_SIZE 4096 preferable to the #ifndef PAGE_SIZE form used in sockopt.c?
tools/testing/selftests/bpf/prog_tests/global_data_init.c static void test_global_percpu_data_lskel(void) · line 260
Quoted 12 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +12
-0+if (!ASSERT_OK (err,"bpf_map__set_value_size" )) + goto out; +if (!ASSERT_EQ (bpf_map__value_size (map), desired_sz,"bpf_map__value_size" )) + goto out; +if (!ASSERT_NEQ (bpf_map__btf_value_type_id (map),0 ,"bpf_map__btf_value_type_id" )) + goto out; + + skel->percpu_arr =bpf_map__initial_value (map, &data_sz); +if (!ASSERT_EQ (data_sz, desired_sz,"data_sz" )) + goto out; +if (!ASSERT_OK_PTR (skel->percpu_arr,"skel->percpu_arr" )) + goto out;
This isn't a bug, but would it read more consistently with test_global_percpu_data_init() to check ASSERT_OK_PTR(skel->percpu_arr) before ASSERT_EQ(data_sz, desired_sz)? The block this replaces checked pointer-then-size, and the surviving test_global_percpu_data_init() at the same file still does pointer-then-size.
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/32156312094
Quoted 29 lines · On 19/8/26 00:15, [email protected] wrote:
Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +0
-0[ ... ]
Quoted 22 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +18
-0@@ -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" ))
Quoted 8 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c static void test_global_percpu_data_lskel(void) · line 248
Quoted 5 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +5
-0+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.
Quoted 2 lines
here - and is the unguarded
#define PAGE_SIZE 4096preferable to the#ifndef PAGE_SIZEform used insockopt.c?
No. PAGE_SIZE must be 4096 here.
Quoted 11 lines
Quoted 11 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +10
-0+if (!ASSERT_OK (err,"bpf_map__set_value_size" )) + goto out; +if (!ASSERT_EQ (bpf_map__value_size (map), desired_sz,"bpf_map__value_size" )) + goto out; +if (!ASSERT_NEQ (bpf_map__btf_value_type_id (map),0 ,"bpf_map__btf_value_type_id" )) + goto out; + + skel->percpu_arr =bpf_map__initial_value (map, &data_sz); +if (!ASSERT_EQ (data_sz, desired_sz,"data_sz" )) + goto out;
Quoted 8 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c static void test_global_percpu_data_lskel(void) · line 260
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +2
-0+if (!ASSERT_OK_PTR (skel->percpu_arr,"skel->percpu_arr" )) + goto out;This isn't a bug, but would it read more consistently with
test_global_percpu_data_init()to checkASSERT_OK_PTR(skel->percpu_arr)beforeASSERT_EQ(data_sz, desired_sz)? The block this replaces checked pointer-then-size, and the survivingtest_global_percpu_data_init()at the same file still does pointer-then-size.
Unnecessary to keep consistent for their order. This is a really minor readability concern.
Thanks,
Leon
Quoted 40 lines · Leon Hwang
Quoted 29 lines · On 19/8/26 00:15, [email protected] wrote:
Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +0
-0[ ... ]
Quoted 22 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +18
-0@@ -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" ))Quoted 8 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c static void test_global_percpu_data_lskel(void) · line 248
Quoted 5 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +5
-0+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
Quoted 7 lines
Will change to '
PAGE_SIZE* 2' if the next revision is needed.Quoted 2 lines
here - and is the unguarded
#define PAGE_SIZE 4096preferable to the#ifndef PAGE_SIZEform used insockopt.c?No.
PAGE_SIZEmust 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...
Quoted 26 lines
Quoted 14 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c static void test_global_percpu_data_lskel(void) · line 260
Quoted 13 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +12
-0+if (!ASSERT_OK (err,"bpf_map__set_value_size" )) + goto out; +if (!ASSERT_EQ (bpf_map__value_size (map), desired_sz,"bpf_map__value_size" )) + goto out; +if (!ASSERT_NEQ (bpf_map__btf_value_type_id (map),0 ,"bpf_map__btf_value_type_id" )) + goto out; + + skel->percpu_arr =bpf_map__initial_value (map, &data_sz); +if (!ASSERT_EQ (data_sz, desired_sz,"data_sz" )) + goto out; +if (!ASSERT_OK_PTR (skel->percpu_arr,"skel->percpu_arr" )) + goto out;Quoted 5 lines
This isn't a bug, but would it read more consistently with
test_global_percpu_data_init()to checkASSERT_OK_PTR(skel->percpu_arr)beforeASSERT_EQ(data_sz, desired_sz)? The block this replaces checked pointer-then-size, and the survivingtest_global_percpu_data_init()at the same file still does pointer-then-size.Unnecessary to keep consistent for their order. This is a really minor readability concern.
Thanks,
Leon
Quoted 43 lines · Andrii Nakryiko
Quoted 42 lines · Leon Hwang
Quoted 29 lines · On 19/8/26 00:15, [email protected] wrote:
Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +0
-0[ ... ]
Quoted 22 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +18
-0@@ -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" ))Quoted 8 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c static void test_global_percpu_data_lskel(void) · line 248
Quoted 5 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +5
-0+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 directlyWill change to '
PAGE_SIZE* 2' if the next revision is needed.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
here - and is the unguarded
#define PAGE_SIZE 4096preferable to the#ifndef PAGE_SIZEform used insockopt.c?No.
PAGE_SIZEmust be 4096 here.can you please elaborate why do we care about specific
PAGE_SIZEvalue? 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
Quoted 48 lines · Leon Hwang
Quoted 46 lines · Andrii Nakryiko
Quoted 45 lines · Leon Hwang
Quoted 29 lines · On 19/8/26 00:15, [email protected] wrote:
Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +0
-0[ ... ]
Quoted 22 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +18
-0@@ -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" ))Quoted 8 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c static void test_global_percpu_data_lskel(void) · line 248
Quoted 5 lines
tools/testing/selftests/bpf/prog_tests/global_data_init.c +5
-0+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 directlyWill change to '
PAGE_SIZE* 2' if the next revision is needed.Quoted 2 lines
here - and is the unguarded
#define PAGE_SIZE 4096preferable to the#ifndef PAGE_SIZEform used insockopt.c?
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
No.
PAGE_SIZEmust be 4096 here.can you please elaborate why do we care about specific
PAGE_SIZEvalue? 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 inglobal_map_resize.c.
this didn't explain much, but I think what you are trying to say is that this won't work for PERCPU arrays with PAGE_SIZE=64KB, because PERCPU value is limited to 32KB today, is that right?
so maybe actually model that in the test itself, expect -E2BIG if PAGE_SIZE > 32KB or something, and otherwise check the resize?
Quoted 3 lines
Thanks,
Leon
Quoted 1 line · Andrii Nakryiko
On Sun, Aug 23, 2026 at 10:02 PM Leon Hwang <[email protected]> wrote:
[...]
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
It is to verify the mmap change in libbpf's
bpf_map_mmap_resize()for percpu data map, like those subtests inglobal_map_resize.c.this didn't explain much, but I think what you are trying to say is that this won't work for PERCPU arrays with PAGE_SIZE=64KB, because PERCPU value is limited to 32KB today, is that right?
Right. Limiting PAGE_SIZE=4KB is to avoid the test_global_percpu_data__load() failure due to PERCPU value 32KB limit when PAGE_SIZE is 64KB.
Quoted 4 lines
so maybe actually model that in the test itself, expect
-E2BIGifPAGE_SIZE> 32KB or something, and otherwise check the resize?
How about skipping test_percpu_data_on_cpus() when test_global_percpu_data__load() returns -E2BIG? Because bpf_map__set_value_size() has already been verified before calling test_global_percpu_data__load(). Afterward, it's unnecessary to check PAGE_SIZE value.
Thanks,
Leon
Quoted 19 lines · Leon Hwang
Quoted 1 line · Andrii Nakryiko
On Sun, Aug 23, 2026 at 10:02 PM Leon Hwang <[email protected]> wrote:
[...]
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
It is to verify the mmap change in libbpf's
bpf_map_mmap_resize()for percpu data map, like those subtests inglobal_map_resize.c.this didn't explain much, but I think what you are trying to say is that this won't work for PERCPU arrays with PAGE_SIZE=64KB, because PERCPU value is limited to 32KB today, is that right?
Right. Limiting PAGE_SIZE=4KB is to avoid the
test_global_percpu_data__load()failure due to PERCPU value 32KB limit whenPAGE_SIZEis 64KB.Quoted 1 line
Quoted 9 lines
Quoted 3 lines
so maybe actually model that in the test itself, expect
-E2BIGifPAGE_SIZE> 32KB or something, and otherwise check the resize?How about skipping
test_percpu_data_on_cpus()whentest_global_percpu_data__load()returns-E2BIG? Becausebpf_map__set_value_size()has already been verified before callingtest_global_percpu_data__load(). Afterward, it's unnecessary to checkPAGE_SIZEvalue.
let's just add a comment about per-cpu limit of 32KB and why PAGE_SIZE of 64KB or more is not going to work, and skip the test
ignoring load failures seems worse
Quoted 3 lines
Thanks,
Leon