Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Called from syscall

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

Type:struct bpf_map

Parameter:

TypeParameterName
union bpf_attr *attr
87  value_size = size of value in bytes
93  If Not Check operation authority Then Return ERR_PTR( - EPERM)
96  If BPF_MAP_CREATE related * flags defined above. & ~STACK_CREATE_FLAG_MASK Then Return ERR_PTR( - EINVAL)
100  If max number of entries in a map == 0 || size of key in bytes != 4 || value_size < 8 || value_size % 8 Then Return ERR_PTR( - EINVAL)
104  BUILD_BUG_ON - break compile if a condition is true(sizeof(structbpf_stack_build_id) % sizeof(u64))
105  If BPF_MAP_CREATE related * flags defined above. & Flag for stack_map, store build_id+offset instead of pointer Then
106  If value_size % sizeof(structbpf_stack_build_id) || value_size / sizeof(structbpf_stack_build_id) > sysctl_perf_event_max_stack Then Return ERR_PTR( - EINVAL)
110  Else if value_size / 8 > sysctl_perf_event_max_stack Then Return ERR_PTR( - EINVAL)
114  n_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 number of entries in a map )
116  cost = n_buckets * size of * + size of smap
117  cost += n_buckets * (value_size + sizeof(structstack_map_bucket))
118  err = bpf_map_charge_init( & mem, cost)
119  If err Then Return ERR_PTR(err)
122  smap = bpf_map_area_alloc(cost, bpf_map_attr_numa_node(attr))
123  If Not smap Then
124  bpf_map_charge_finish( & mem)
125  Return ERR_PTR( - ENOMEM)
128  bpf_map_init_from_attr( & map, attr)
129  value_size = value_size
130  n_buckets = n_buckets
132  err = get_callchain_buffers(sysctl_perf_event_max_stack)
133  If err Then Go to free_charge
136  err = prealloc_elems_and_freelist(smap)
137  If err Then Go to put_buffers
140  bpf_map_charge_move( & memory, & mem)
142  Return map
144  put_buffers :
145  put_callchain_buffers()
146  free_charge :
147  bpf_map_charge_finish( & mem)
148  bpf_map_area_free(smap)
149  Return ERR_PTR(err)