Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\hashtab.c Create Date:2022-07-28 13:09:09
Last Modify:2022-05-23 09:15:29 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:prealloc_init

Proto:static int prealloc_init(struct bpf_htab *htab)

Type:int

Parameter:

TypeParameterName
struct bpf_htab *htab
136  num_entries = max_entries
137  err = -ENOMEM
139  If Not htab_is_percpu(htab) && Not htab_is_lru(htab) Then num_entries += num_possible_cpus()
142  elems = bpf_map_area_alloc( size of each element in bytes * num_entries, numa_node)
144  If Not elems Then Return -ENOMEM
147  If Not htab_is_percpu(htab) Then Go to skip_percpu_elems
150  When i < num_entries cycle
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  __percpu * pptr
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  If Not pptr Then Go to free_elems
157  htab_elem_set_ptr(get_htab_elem(htab, i), key_size, pptr)
159  cond_resched()
162  skip_percpu_elems :
163  If htab_is_lru(htab) Then 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  Else err = pcpu_freelist_init( & freelist)
173  If err Then Go to free_elems
176  If htab_is_lru(htab) Then bpf_lru_populate( & lru, elems, offsetof(structhtab_elem, lru_node), size of each element in bytes , num_entries)
180  Else pcpu_freelist_populate( & freelist, elems + offsetof(structhtab_elem, fnode), size of each element in bytes , num_entries)
185  Return 0
187  free_elems :
188  htab_free_elems(htab)
189  Return err
Caller
NameDescribe
htab_map_alloc