> 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 8466332d7406f..06d163a022dcc 100644
> --- a/tools/testing/selftests/bpf/prog_tests/global_data_init.c
> +++ b/tools/testing/selftests/bpf/prog_tests/global_data_init.c

[ ... ]

> @@ -60,3 +63,188 @@ void test_global_data_init(void)
>       free(newval);
>       bpf_object__close(obj);
>  }
> +
> +static void test_percpu_data_on_cpus(struct bpf_map *map, int map_fd, int 
> prog_fd, int *runp)
> +{
> +     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,
> +     );

This isn't a bug, but does the raw_tp ctx need to be passed here, given
the program ignores it?

[ ... ]

> +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;
> +     int prog_fd, err;

[ ... ]

> +     map = skel->maps.percpu;
> +     if (!ASSERT_EQ(bpf_map__type(map), BPF_MAP_TYPE_PERCPU_ARRAY, 
> "bpf_map__type"))
> +             goto out;
> +
> +     init_value.data = 2;
> +     init_value.nums[6] = -1;
> +     init_value.struct_data.i = 2;
> +     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"))
> +             goto out;
> +
> +     init_data = bpf_map__initial_value(map, &init_data_sz);
> +     if (!ASSERT_OK_PTR(init_data, "bpf_map__initial_value"))
> +             goto out;
> +
> +     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->struct_data.i, init_value.struct_data.i, 
> "init_value struct_data.i");
> +     ASSERT_EQ(init_data->struct_data.nums[6], 
> init_value.struct_data.nums[6],
> +               "init_value struct_data.nums[6]");

This isn't a bug, but should init_value.set be given a non-zero value,
and nums[6] checked, so these assertions can actually distinguish a broken
copy?


---
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/31716447858

Reply via email to