函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\stackmap.c Create Date:2022-07-27 14:44:59
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:____bpf_get_stackid

函数原型:static inline __attribute__((__always_inline__)) u64 ____bpf_get_stackid(struct pt_regs *regs, struct bpf_map *map, u64 flags)

返回类型:u64

参数:

类型参数名称
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_sizestack_map_data_size(map)
354  init_nr等于sysctl_perf_event_max_stackmax_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等于非user
362  如果此条件成立可能性小(为编译器优化)(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))则返回:负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  如果此条件成立可能性小(为编译器优化)(!trace)则返回:负EFAULT
376  trace_nr等于nrinit_nr
378  如果trace_nr小于等于skip则返回:负EFAULT
382  trace_nr减等于skip
383  trace_len等于trace_nrsizeof(u64)
384  ips等于 /proc/sys/kernel/perf_event_max_stack skipinit_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等于buckethash恒等于hash
391  如果hash_matchesflags按位与lags used by BPF_FUNC_get_stackid only. 则返回:id
394  如果stack_map_use_build_id(map)则
396  new_bucket等于pcpu_freelist_pop( & freelist)
398  如果此条件成立可能性小(为编译器优化)(!new_bucket)则返回:负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_nrsizeof(structbpf_stack_build_id)
405  如果hash_matchesnr恒等于trace_nr内存比较恒等于0则
408  返回:id
410  如果bucket且非flags按位与BPF_F_REUSE_STACKID的值则
412  返回:负EEXIST
414  否则
415  如果hash_matchesnr恒等于trace_nr内存比较恒等于0则返回:id
418  如果bucket且非flags按位与BPF_F_REUSE_STACKID的值则返回:负EEXIST
421  new_bucket等于pcpu_freelist_pop( & freelist)
423  如果此条件成立可能性小(为编译器优化)(!new_bucket)则返回:负ENOMEM
425  内存复制(data, ips, trace_len)
428  hash等于hash
429  nr等于trace_nr
431  old_bucket等于xchg( & buckets[id], new_bucket)
432  如果old_bucketpcpu_freelist_push( & freelist, & fnode)
434  返回:id