Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:alloc_htab_elem

Proto:static struct htab_elem *alloc_htab_elem(struct bpf_htab *htab, void *key, void *value, u32 key_size, u32 hash, bool percpu, bool onallcpus, struct htab_elem *old_elem)

Type:struct htab_elem

Parameter:

TypeParameterName
struct bpf_htab *htab
void *key
void *value
u32key_size
u32hash
boolpercpu
boolonallcpus
struct htab_elem *old_elem
726  size = value_size
727  prealloc = htab_is_prealloc(htab)
729  __percpu * pptr
731  If prealloc Then
732  If old_elem Then
737  l_new = pl_new
738  pl_new = old_elem
739  Else
743  If Not l Then Return ERR_PTR( - E2BIG)
747  Else
748  If atomic_inc_return( & number of elements in this hashtable ) > max_entries Then If Not old_elem Then
755  l_new = ERR_PTR( - E2BIG)
756  Go to dec_count
758  l_new = kmalloc_node( size of each element in bytes , DOC: Useful GFP flag combinations* Useful GFP flag combinations* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~* Useful GFP flag combinations that are commonly used. It is recommended* that subsystems start with one of these combinations and then set/clear | 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., numa_node)
760  If Not l_new Then
761  l_new = ERR_PTR( - ENOMEM)
762  Go to dec_count
764  check_and_init_map_lock( & map, key + 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))
768  No 3D Now!(key, key, key_size)
769  If percpu Then
770  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.(size, 8)
771  If prealloc Then
773  Else
777  If Not pptr Then
778  kfree(l_new)
779  l_new = ERR_PTR( - ENOMEM)
780  Go to dec_count
784  pcpu_copy_value(htab, pptr, value, onallcpus)
786  If Not prealloc Then htab_elem_set_ptr(l_new, key_size, pptr)
788  Else if fd_htab_map_needs_adjust(htab) Then
789  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.(size, 8)
790  No 3D Now!(key + 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), value, size)
791  Else
792  py everything but bpf_spin_lock
797  hash = hash
798  Return l_new
799  dec_count :
800  atomic_dec( & number of elements in this hashtable )
801  Return l_new
Caller
NameDescribe
htab_map_update_elemCalled from syscall or from eBPF program
__htab_percpu_map_update_elem