Skip to content

bpf: Introduce BPF_F_CPU flag for percpu_array map #9180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

Asphaltt
Copy link
Contributor

No description provided.

Kernel Patches Daemon and others added 4 commits June 23, 2025 09:35
To reduce the cached data of updating percpu_array map in light
skeleton, introduce BPF_F_CPU flag for updating percpu_array map by
reusing one value for all CPUs.

The BPF_F_CPU flag places in map_flags of bpf_percpu_array_update() or
in batch.elem_flags of generic_map_update_batch() alongside a cpu field.
The cpu field indicates updating for all CPUs if 0xFFFFFFFF, or updating
for the specified CPU otherwise.

Similarly, the BPF_F_CPU flag alongside a cpu field can be used for
looking up a value on specified CPU.

Signed-off-by: Leon Hwang <[email protected]>
Introduce the following APIs for percpu_array map flag BPF_F_CPU:

1. bpf_map_update_elem_opts(): update percpu_array map using
   'const struct bpf_map_update_elem_opts *'.
2. bpf_map_lookup_elem_opts(): lookup percpu_array map using
   'const struct bpf_map_lookup_elem_opts *'.
3. bpf_map__lookup_elem_opts(): wrap bpf_map_lookup_elem_opts() with
   checking arguments.
4. bpf_map__update_elem_opts(): wrap bpf_map_update_elem_opts() with
   checking arguments.

Signed-off-by: Leon Hwang <[email protected]>
The following APIs will be tested:

1. bpf_map_update_batch()
2. bpf_map_lookup_batch()
3. bpf_map_update_elem_opts()
4. bpf_map__update_elem_opts()
5. bpf_map_lookup_elem_opts()
6. bpf_map__lookup_elem_opts()

cd tools/testing/selftests/bpf/; ./test_progs -t percpu_alloc/cpu_flag_tests
251/5   percpu_alloc/cpu_flag_tests:OK
251     percpu_alloc:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Leon Hwang <[email protected]>
@Asphaltt Asphaltt force-pushed the bpf/percpu-array-flag/rfc-v1 branch from bdb8c6a to a2c68e1 Compare June 24, 2025 15:17
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the bpf-next_base branch 5 times, most recently from a974116 to eaa5230 Compare June 25, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant