Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\arraymap.c Create Date:2022-07-28 13:10:58
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:array_map_alloc

Proto:static struct bpf_map *array_map_alloc(union bpf_attr *attr)

Type:struct bpf_map

Parameter:

TypeParameterName
union bpf_attr *attr
77  percpu = one of enum bpf_map_type == BPF_MAP_TYPE_PERCPU_ARRAY
78  numa_node = bpf_map_attr_numa_node(attr)
80  unpriv = Not Check operation authority
85  elem_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 of value in bytes , 8)
87  max_entries = max number of entries in a map
93  mask64 = fls_long(max_entries - 1)
94  mask64 = 1ULL << mask64
95  mask64 -= 1
97  index_mask = mask64
98  If unpriv Then
102  max_entries = index_mask + 1
104  If max_entries < max number of entries in a map Then Return ERR_PTR( - E2BIG)
108  array_size = size of array
109  If percpu Then
110  array_size += max_entries * size of *
111  Else
118  Else
124  cost = array_size
125  If percpu Then cost += max number of entries in a map * elem_size * num_possible_cpus()
128  ret = bpf_map_charge_init( & mem, cost)
129  If ret < 0 Then Return ERR_PTR(ret)
133  If BPF_MAP_CREATE related * flags defined above. & Enable memory-mapping BPF map Then
137  data = bpf_map_area_mmapable_alloc(array_size, numa_node)
138  If Not data Then
140  Return ERR_PTR( - ENOMEM)
142  array = data + align the pointer to the (next) page boundary (sizeof(structbpf_array)) - offsetof(structbpf_array, value)
144  Else
145  array = bpf_map_area_alloc(array_size, numa_node)
147  If Not array Then
148  bpf_map_charge_finish( & mem)
149  Return ERR_PTR( - ENOMEM)
151  index_mask = index_mask
152  unpriv_array = unpriv
155  bpf_map_init_from_attr( & map, attr)
156  bpf_map_charge_move( & memory, & mem)
157  elem_size = elem_size
159  If percpu && bpf_array_alloc_percpu(array) Then
160  bpf_map_charge_finish( & memory)
161  bpf_map_area_free(array)
162  Return ERR_PTR( - ENOMEM)
165  Return map
Caller
NameDescribe
prog_array_map_alloc
array_of_map_alloc