函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\hashtab.c Create Date:2022-07-27 14:24:57
Last Modify:2022-05-23 09:15:29 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:prealloc_init

函数原型:static int prealloc_init(struct bpf_htab *htab)

返回类型:int

参数:

类型参数名称
struct bpf_htab *htab
136  num_entries等于max_entries
137  err等于负ENOMEM
139  如果非htab_is_percpu(htab)且非htab_is_lru(htab)则num_entries加等于num_possible_cpus()
142  elems等于bpf_map_area_alloc( size of each element in bytes * num_entries, numa_node)
144  如果非elems则返回:负ENOMEM
147  如果非htab_is_percpu(htab)则转到:skip_percpu_elems
150 i小于num_entries循环
151  size等于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)
152  __percpupptr
154  pptr等于__alloc_percpu_gfp(size, 8, GFP_USER | DOC: Action modifiers* Action modifiers* ~~~~~~~~~~~~~~~~* %__GFP_NOWARN suppresses allocation failure reports.* %__GFP_COMP address compound page metadata.* %__GFP_ZERO returns a zeroed page on success.)
155  如果非pptr则转到:free_elems
157  htab_elem_set_ptr(get_htab_elem(htab, i), key_size, pptr)
159  cond_resched()
162  skip_percpu_elems :
163  如果htab_is_lru(htab)则err等于bpf_lru_init( & lru, map_flags & 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., offsetof(structhtab_elem, hash) - offsetof(structhtab_elem, lru_node), htab_lru_map_delete_node, htab)
170  否则err等于pcpu_freelist_init( & freelist)
173  如果err则转到:free_elems
176  如果htab_is_lru(htab)则bpf_lru_populate( & lru, elems, offsetof(structhtab_elem, lru_node), size of each element in bytes , num_entries)
180  否则pcpu_freelist_populate( & freelist, elems + offsetof(structhtab_elem, fnode), size of each element in bytes , num_entries)
185  返回:0
187  free_elems :
188  htab_free_elems(htab)
189  返回:err
调用者
名称描述
htab_map_alloc