Re: [PATCH bpf-next v4 2/7] bpf: Refactor inode/task/sk storage map_{alloc,free}() for reuse

Martin KaFai Lau
2022-10-24T22:28:20Z

On 10/23/22 11:05 AM, Yonghong Song wrote
> -void bpf_local_storage_map_free(struct bpf_local_storage_map *smap,
> - int __percpu *busy_counter)
> +static void __bpf_local_storage_map_free(struct bpf_local_storage_map *smap,
> + int __percpu *busy_counter)

nit.

This map_free does not look like it requires a separate "__" version since it is
not reused. probably just put everything into the bpf_local_storage_map_free()
instead?

> {
> struct bpf_local_storage_elem *selem;
> struct bpf_local_storage_map_bucket *b;
> @@ -613,7 +613,7 @@ int bpf_local_storage_map_alloc_check(union bpf_attr *attr)
> return 0;
> }
>
> -struct bpf_local_storage_map *bpf_local_storage_map_alloc(union bpf_attr *attr)
> +static struct bpf_local_storage_map *__bpf_local_storage_map_alloc(union bpf_attr *attr)
> {
> struct bpf_local_storage_map *smap;
> unsigned int i;
> @@ -663,3 +663,28 @@ int bpf_local_storage_map_check_btf(const struct bpf_map *map,
>
> return 0;
> }

[ ... ]

> +void bpf_local_storage_map_free(struct bpf_map *map,
> + struct bpf_local_storage_cache *cache,
> + int __percpu *busy_counter)
> +{
> + struct bpf_local_storage_map *smap;
> +
> + smap = (struct bpf_local_storage_map *)map;
> + bpf_local_storage_cache_idx_free(cache, smap->cache_idx);
> + __bpf_local_storage_map_free(smap, busy_counter);
> +}