Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:____bpf_get_stackid

Proto:static inline __attribute__((__always_inline__)) u64 ____bpf_get_stackid(struct pt_regs *regs, struct bpf_map *map, u64 flags)

Type:u64

Parameter:

TypeParameterName
struct pt_regs *regs
struct bpf_map *map
u64flags
349  smap = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(map, structbpf_stack_map, map)
352  max_depth = value_size / stack_map_data_size(map)
354  init_nr = sysctl_perf_event_max_stack - max_depth
355  skip = flags & lags for both BPF_FUNC_get_stackid and BPF_FUNC_get_stack.
357  user = flags & BPF_F_USER_STACK
358  kernel = Not user
362  If Value for the false possibility is greater at compile time(flags & ~(lags for both BPF_FUNC_get_stackid and BPF_FUNC_get_stack. | BPF_F_USER_STACK | lags used by BPF_FUNC_get_stackid only. | BPF_F_REUSE_STACKID)) Then Return -EINVAL
366  trace = get_perf_callchain(regs, init_nr, kernel, user, sysctl_perf_event_max_stack, TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., false)
369  If Value for the false possibility is greater at compile time(!trace) Then Return -EFAULT
376  trace_nr = nr - init_nr
378  If trace_nr <= skip Then Return -EFAULT
382  trace_nr -= skip
383  trace_len = trace_nr * sizeof(u64)
384  ips = /proc/sys/kernel/perf_event_max_stack + skip + init_nr
385  hash = jhash2 - hash an array of u32's*@k: the key which must be an array of u32's*@length: the number of u32's in the key*@initval: the previous hash, or an arbitray value* Returns the hash value of the key.
386  id = hash & n_buckets - 1
387  bucket = READ_ONCE(buckets[id])
389  hash_matches = bucket && hash == hash
391  If hash_matches && flags & lags used by BPF_FUNC_get_stackid only. Then Return id
394  If stack_map_use_build_id(map) Then
396  new_bucket = pcpu_freelist_pop( & freelist)
398  If Value for the false possibility is greater at compile time(!new_bucket) Then Return -ENOMEM
400  nr = trace_nr
401  stack_map_get_build_id_offset((structbpf_stack_build_id * )data, ips, trace_nr, user)
404  trace_len = trace_nr * sizeof(structbpf_stack_build_id)
405  If hash_matches && nr == trace_nr && memcmp(data, data, trace_len) == 0 Then
408  Return id
410  If bucket && Not (flags & BPF_F_REUSE_STACKID) Then
412  Return -EEXIST
414  Else
415  If hash_matches && nr == trace_nr && memcmp(data, ips, trace_len) == 0 Then Return id
418  If bucket && Not (flags & BPF_F_REUSE_STACKID) Then Return -EEXIST
421  new_bucket = pcpu_freelist_pop( & freelist)
423  If Value for the false possibility is greater at compile time(!new_bucket) Then Return -ENOMEM
425  No 3D Now!(data, ips, trace_len)
428  hash = hash
429  nr = trace_nr
431  old_bucket = xchg( & buckets[id], new_bucket)
432  If old_bucket Then pcpu_freelist_push( & freelist, & fnode)
434  Return id