On Fri, Aug 8, 2025 at 9:11 AM Leon Hwang <leon.hwang@xxxxxxxxx> wrote: > > On Fri Aug 8, 2025 at 1:20 AM +08, Alexei Starovoitov wrote: > > On Tue, Aug 5, 2025 at 9:30 AM Leon Hwang <leon.hwang@xxxxxxxxx> wrote: > >> > >> Introduce support for the BPF_F_CPU flag in percpu_array maps to allow > >> updating values for specified CPU or for all CPUs with a single value. > >> > >> This enhancement enables: > >> > >> * Efficient update of all CPUs using a single value when cpu == (u32)~0. > >> * Targeted update or lookup for a specified CPU otherwise. > >> > >> The flag is passed via: > >> > >> * map_flags in bpf_percpu_array_update() along with embedded cpu field. > >> * elem_flags in generic_map_update_batch() along with embedded cpu field. > >> > >> Signed-off-by: Leon Hwang <leon.hwang@xxxxxxxxx> > >> --- > >> include/linux/bpf.h | 3 +- > >> include/uapi/linux/bpf.h | 6 +++ > >> kernel/bpf/arraymap.c | 54 ++++++++++++++++++------ > >> kernel/bpf/syscall.c | 77 +++++++++++++++++++++------------- > >> tools/include/uapi/linux/bpf.h | 6 +++ > >> 5 files changed, 103 insertions(+), 43 deletions(-) > >> > >> diff --git a/include/linux/bpf.h b/include/linux/bpf.h > >> index cc700925b802f..c17c45f797ed9 100644 > >> --- a/include/linux/bpf.h > >> +++ b/include/linux/bpf.h > >> @@ -2691,7 +2691,8 @@ int map_set_for_each_callback_args(struct bpf_verifier_env *env, > >> struct bpf_func_state *callee); > >> > >> int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value); > >> -int bpf_percpu_array_copy(struct bpf_map *map, void *key, void *value); > >> +int bpf_percpu_array_copy(struct bpf_map *map, void *key, void *value, > >> + u64 flags); > >> int bpf_percpu_hash_update(struct bpf_map *map, void *key, void *value, > >> u64 flags); > >> int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value, > >> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > >> index 233de8677382e..67bc35e4d6a8d 100644 > >> --- a/include/uapi/linux/bpf.h > >> +++ b/include/uapi/linux/bpf.h > >> @@ -1372,6 +1372,12 @@ enum { > >> BPF_NOEXIST = 1, /* create new element if it didn't exist */ > >> BPF_EXIST = 2, /* update existing element */ > >> BPF_F_LOCK = 4, /* spin_lock-ed map_lookup/map_update */ > >> + BPF_F_CPU = 8, /* map_update for percpu_array */ > > > > only percpu_array?! > > Aren't you doing it for percpu_hash too? > > > > Only percpu_array in this patchset. > > I have no need to do it for percpu_hash. You're missing the point. If we're adding the flag it should work for all per-cpu maps. Both array and hash. Same issue as with your other patch with common_attr. We're not adding a feature that works for 1 out 10 commands/map types/whatever and doesn't work for the rest. Flags/features have to be generic and consistent.