函数逻辑报告 |
Source Code:kernel\bpf\hashtab.c |
Create Date:2022-07-27 14:25:13 |
| Last Modify:2022-05-23 09:15:29 | Copyright©Brick |
| 首页 | 函数Tree |
| 注解内核,赢得工具 | 下载SCCT | English |
函数名称:htab_map_alloc
函数原型:static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
返回类型:struct bpf_map
参数:
| 类型 | 参数 | 名称 |
|---|---|---|
| union bpf_attr * | attr |
| 297 | percpu等于 one of enum bpf_map_type 恒等于BPF_MAP_TYPE_PERCPU_HASH或 one of enum bpf_map_type 恒等于BPF_MAP_TYPE_LRU_PERCPU_HASH |
| 299 | lru等于 one of enum bpf_map_type 恒等于BPF_MAP_TYPE_LRU_HASH或 one of enum bpf_map_type 恒等于BPF_MAP_TYPE_LRU_PERCPU_HASH |
| 316 | bpf_map_init_from_attr( & map, attr) |
| 318 | 如果percpu_lru则 |
| 335 | 如果percpu则 size of each element in bytes 加等于*的长度 |
| 342 | 如果 number of hash buckets 恒等于0或 number of hash buckets 大于U32_MAX除sizeof(structbucket)则转到:free_htab |
| 346 | cost等于 number of hash buckets 乘sizeof(structbucket)加 size of each element in bytes 乘max_entries |
| 352 | 否则cost加等于 size of each element in bytes 乘num_possible_cpus() |
| 356 | err等于bpf_map_charge_init( & memory, cost) |
| 361 | buckets等于bpf_map_area_alloc( number of hash buckets * sizeof(structbucket), numa_node) |
| 364 | 如果非buckets则转到:free_charge |
| 367 | 如果map_flags按位与Zero-initialize hash function seed. This should only be used for testing. 则hashrnd等于0 |
| 369 | 否则hashrnd等于get_random_int() |
| 372 | 以i小于 number of hash buckets 循环 |
| 373 | INIT_HLIST_NULLS_HEAD( & head, i) |
| 374 | raw_spin_lock_init( & lock) |
| 377 | 如果prealloc则 |
| 378 | err等于prealloc_init(htab) |
| 379 | 如果err则转到:free_buckets |
| 386 | err等于alloc_extra_elems(htab) |
| 387 | 如果err则转到:free_prealloc |
| 392 | 返回:map |
| 394 | free_prealloc : |
| 395 | prealloc_destroy(htab) |
| 396 | free_buckets : |
| 397 | bpf_map_area_free(buckets) |
| 398 | free_charge : |
| 399 | bpf_map_charge_finish( & memory) |
| 400 | free_htab : |
| 402 | 返回:错误号 |
| 名称 | 描述 |
|---|---|
| htab_of_map_alloc |
| 源代码转换工具 开放的插件接口 | X |
|---|---|
| 支持:c/c++/esqlc/java Oracle/Informix/Mysql 插件可实现:逻辑报告 代码生成和批量转换代码 |