Re: [PATCH -next 3/5] bpf: Remove map_pop_elem callbacks with -EOPNOTSUPP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2/17/2025 9:41 AM, Xiaomeng Zhang wrote:
> Remove redundant map_pop_elem callbacks with return -EOPNOTSUPP. We can
> directly return -EOPNOTSUPP when calling the unimplemented callbacks.
>
> Signed-off-by: Xiaomeng Zhang <zhangxiaomeng13@xxxxxxxxxx>
> ---
>  kernel/bpf/arena.c        | 6 ------
>  kernel/bpf/bloom_filter.c | 6 ------
>  kernel/bpf/helpers.c      | 5 ++++-
>  kernel/bpf/syscall.c      | 5 ++++-
>  4 files changed, 8 insertions(+), 14 deletions(-)
>

>  BPF_CALL_2(bpf_map_pop_elem, struct bpf_map *, map, void *, value)
>  {
> -	return map->ops->map_pop_elem(map, value);
> +	if (map->ops->map_pop_elem)
> +		return map->ops->map_pop_elem(map, value);
> +	else
> +		return -EOPNOTSUPP;
>  }
>  

Similar with the previous patch, it is unnecessary.
>  const struct bpf_func_proto bpf_map_pop_elem_proto = {
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 79a118ea9270..c6f55283f4ff 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -2142,7 +2142,10 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr)
>  	err = -ENOTSUPP;
>  	if (map->map_type == BPF_MAP_TYPE_QUEUE ||
>  	    map->map_type == BPF_MAP_TYPE_STACK) {
> -		err = map->ops->map_pop_elem(map, value);
> +		if (map->ops->map_pop_elem)
> +			err = map->ops->map_pop_elem(map, value);
> +		else
> +			err = -EOPNOTSUPP;

It is also unnecessary.
>  	} else if (map->map_type == BPF_MAP_TYPE_HASH ||
>  		   map->map_type == BPF_MAP_TYPE_PERCPU_HASH ||
>  		   map->map_type == BPF_MAP_TYPE_LRU_HASH ||





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux