kernel/bpf/syscall.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
From: Song Chen <chensong_2000@189.cn>
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@189.cn>
---
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 (IS_FD_HASH(map)) {
err = bpf_fd_htab_map_update_elem(map, map_file, key, value,
flags);
} else if (map->map_type == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY) {
--
2.34.1
On Wed, Oct 8, 2025 at 11:23 PM <chensong_2000@189.cn> wrote:
>
> From: Song Chen <chensong_2000@189.cn>
>
> 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@189.cn>
> ---
> 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
© 2016 - 2025 Red Hat, Inc.