Re: [PATCH] kernel/bpf/syscall: use IS_FD_HASH in bpf_map_update_value

From: Alexei Starovoitov
Date: Thu Oct 09 2025 - 11:38:53 EST


On Wed, Oct 8, 2025 at 11:23 PM <chensong_2000@xxxxxx> wrote:
>
> From: Song Chen <chensong_2000@xxxxxx>
>
> If IS_FD_HASH is defined on the top of the file, then use it to replace
> "map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS".
>
> Signed-off-by: Song Chen <chensong_2000@xxxxxx>
> ---
> kernel/bpf/syscall.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 0fbfa8532c39..2c194a73aeda 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -154,8 +154,7 @@ static void maybe_wait_bpf_programs(struct bpf_map *map)
> * time can be very long and userspace may think it will hang forever,
> * so don't handle sleepable BPF programs now.
> */
> - if (map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS ||
> - map->map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS)
> + if (IS_FD_HASH(map) || map->map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS)
> synchronize_rcu();
> }
>
> @@ -274,7 +273,7 @@ static int bpf_map_update_value(struct bpf_map *map, struct file *map_file,
> } else if (IS_FD_ARRAY(map)) {
> err = bpf_fd_array_map_update_elem(map, map_file, key, value,
> flags);
> - } else if (map->map_type == BPF_MAP_TYPE_HASH_OF_MAPS) {
> + } else if (/(map)) {

Let's not. It only obfuscates the code in this case.

pw-bot: cr