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

Yonghong Song
2022-10-25T02:29:04Z

On 10/24/22 1:34 PM, Martin KaFai Lau wrote:
> 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?

Okay, will inline __bpf_local_storage_map_free() into
bpf_local_storage_map_free().

>
>>   {
>>       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);
>> +}
>