tools/perf/util/bpf_skel/lock_contention.bpf.c
Source file repositories/reference/linux-study-clean/tools/perf/util/bpf_skel/lock_contention.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/bpf_skel/lock_contention.bpf.c- Extension
.c- Size
- 23567 bytes
- Lines
- 990
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf/bpf_core_read.hasm-generic/errno-base.hlock_data.h
Detected Declarations
struct rw_semaphore___oldstruct rw_semaphore___newstruct mm_struct___oldstruct mm_struct___newstruct rq___oldstruct rq___newstruct bpf_iter__kmem_cache___newfunction get_current_cgroup_idfunction can_recordfunction update_task_datafunction check_lock_typefunction delay_callbackfunction do_lock_delayfunction check_lock_delayfunction get_owner_stack_idfunction update_contention_datafunction update_owner_statfunction contention_beginfunction contention_endfunction collect_zone_lockfunction BPF_PROGfunction BPF_PROGfunction slab_cache_iter
Annotated Snippet
struct rw_semaphore___old {
struct task_struct *owner;
} __attribute__((preserve_access_index));
struct rw_semaphore___new {
atomic_long_t owner;
} __attribute__((preserve_access_index));
struct mm_struct___old {
struct rw_semaphore mmap_sem;
} __attribute__((preserve_access_index));
struct mm_struct___new {
struct rw_semaphore mmap_lock;
} __attribute__((preserve_access_index));
extern struct kmem_cache *bpf_get_kmem_cache(u64 addr) __ksym __weak;
/* control flags */
const volatile int has_cpu;
const volatile int has_task;
const volatile int has_type;
const volatile int has_addr;
const volatile int has_cgroup;
const volatile int has_slab;
const volatile int needs_callstack;
const volatile int stack_skip;
const volatile int lock_owner;
const volatile int use_cgroup_v2;
const volatile int max_stack;
const volatile int lock_delay;
/* determine the key of lock stat */
const volatile int aggr_mode;
int enabled;
int perf_subsys_id = -1;
__u64 end_ts;
__u32 slab_cache_id;
/* error stat */
int task_fail;
int stack_fail;
int time_fail;
int data_fail;
int task_map_full;
int data_map_full;
struct task_struct *bpf_task_from_pid(s32 pid) __ksym __weak;
void bpf_task_release(struct task_struct *p) __ksym __weak;
static inline __u64 get_current_cgroup_id(void)
{
struct task_struct *task;
struct cgroup *cgrp;
if (use_cgroup_v2)
return bpf_get_current_cgroup_id();
task = bpf_get_current_task_btf();
if (perf_subsys_id == -1) {
#if __has_builtin(__builtin_preserve_enum_value)
perf_subsys_id = bpf_core_enum_value(enum cgroup_subsys_id,
perf_event_cgrp_id);
#else
perf_subsys_id = perf_event_cgrp_id;
#endif
}
cgrp = BPF_CORE_READ(task, cgroups, subsys[perf_subsys_id], cgroup);
return BPF_CORE_READ(cgrp, kn, id);
}
static inline int can_record(u64 *ctx)
{
if (has_cpu) {
__u32 cpu = bpf_get_smp_processor_id();
__u8 *ok;
ok = bpf_map_lookup_elem(&cpu_filter, &cpu);
if (!ok)
return 0;
}
if (has_task) {
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf/bpf_core_read.h`, `asm-generic/errno-base.h`, `lock_data.h`.
- Detected declarations: `struct rw_semaphore___old`, `struct rw_semaphore___new`, `struct mm_struct___old`, `struct mm_struct___new`, `struct rq___old`, `struct rq___new`, `struct bpf_iter__kmem_cache___new`, `function get_current_cgroup_id`, `function can_record`, `function update_task_data`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.