函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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
注解内核,赢得工具下载SCCTEnglish

函数名称: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
306  percpu_lru等于 BPF_MAP_CREATE related * flags defined above.按位与Instead of having one common LRU list in the* BPF_MAP_TYPE_LRU_[PERCPU_]HASH map, use a percpu LRU list* which can scale and perform better.* Note, the LRU nodes (including free nodes) cannot be moved* across different LRU lists.
307  prealloc等于非 BPF_MAP_CREATE related * flags defined above.按位与lags for BPF_MAP_CREATE command 的值
312  htab等于分配内存并置零
313  如果非htab则返回:错误号
316  bpf_map_init_from_attr( & map, attr)
318  如果percpu_lru
323  max_entries等于undup - round up to the next specified multiple*@x: the value to up*@y: multiple to round up to* Rounds @x up to next multiple of @y. If @y will always be a power* of 2, consider using the faster round_up().( max number of entries in a map , num_possible_cpus())
325  如果max_entries小于 max number of entries in a map max_entries等于unddown - round down to next specified multiple*@x: the value to round*@y: multiple to round down to* Rounds @x down to next multiple of @y. If @y will always be a power* of 2, consider using the faster round_down().( max number of entries in a map , num_possible_cpus())
331  number of hash buckets 等于undup_pow_of_two - round the given value up to nearest power of two*@n: parameter* round the given value up to the nearest power of two* - the result is undefined when n == 0* - this can be used to initialise global variables from constant data(max_entries)
333  size of each element in bytes 等于sizeof(structhtab_elem)加und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(key_size, 8)
335  如果percpu size of each element in bytes 加等于*的长度
337  否则 size of each element in bytes 加等于und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(value_size, 8)
340  err等于负E2BIG
342  如果 number of hash buckets 恒等于0或 number of hash buckets 大于U32_MAXsizeof(structbucket)则转到:free_htab
346  cost等于 number of hash buckets sizeof(structbucket)加 size of each element in bytes max_entries
349  如果percpucost加等于und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(value_size, 8)乘num_possible_cpus()乘max_entries
352  否则cost加等于 size of each element in bytes num_possible_cpus()
356  err等于bpf_map_charge_init( & memory, cost)
357  如果err则转到:free_htab
360  err等于负ENOMEM
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
382  如果非percpu且非lru
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 :
401  kfree(htab)
402  返回:错误号
调用者
名称描述
htab_of_map_alloc