tools/perf/util/bpf_skel/kwork_top.bpf.c
Source file repositories/reference/linux-study-clean/tools/perf/util/bpf_skel/kwork_top.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/bpf_skel/kwork_top.bpf.c- Extension
.c- Size
- 6393 bytes
- Lines
- 339
- 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.
- 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.h
Detected Declarations
struct time_datastruct work_datastruct task_datastruct work_keystruct task_keyenum kwork_class_typefunction cpu_is_filteredfunction update_task_infofunction update_workfunction on_sched_outfunction on_sched_infunction on_switchfunction on_irq_handler_entryfunction on_irq_handler_exitfunction on_softirq_entryfunction on_softirq_exit
Annotated Snippet
struct time_data {
__u64 timestamp;
};
struct work_data {
__u64 runtime;
};
struct task_data {
__u32 tgid;
__u32 is_kthread;
char comm[MAX_COMMAND_LEN];
};
struct work_key {
__u32 type;
__u32 pid;
__u64 task_p;
};
struct task_key {
__u32 pid;
__u32 cpu;
};
struct {
__uint(type, BPF_MAP_TYPE_TASK_STORAGE);
__uint(map_flags, BPF_F_NO_PREALLOC);
__type(key, int);
__type(value, struct time_data);
} kwork_top_task_time SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_HASH);
__uint(key_size, sizeof(struct work_key));
__uint(value_size, sizeof(struct time_data));
__uint(max_entries, MAX_ENTRIES);
} kwork_top_irq_time SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(key_size, sizeof(struct task_key));
__uint(value_size, sizeof(struct task_data));
__uint(max_entries, MAX_ENTRIES);
} kwork_top_tasks SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_HASH);
__uint(key_size, sizeof(struct work_key));
__uint(value_size, sizeof(struct work_data));
__uint(max_entries, MAX_ENTRIES);
} kwork_top_works SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(key_size, sizeof(u32));
__uint(value_size, sizeof(u8));
__uint(max_entries, MAX_NR_CPUS);
} kwork_top_cpu_filter SEC(".maps");
int enabled = 0;
const volatile int has_cpu_filter = 0;
__u64 from_timestamp = 0;
__u64 to_timestamp = 0;
static __always_inline int cpu_is_filtered(__u32 cpu)
{
__u8 *cpu_val;
if (has_cpu_filter) {
cpu_val = bpf_map_lookup_elem(&kwork_top_cpu_filter, &cpu);
if (!cpu_val)
return 1;
}
return 0;
}
static __always_inline void update_task_info(struct task_struct *task, __u32 cpu)
{
struct task_key key = {
.pid = task->pid,
.cpu = cpu,
};
if (!bpf_map_lookup_elem(&kwork_top_tasks, &key)) {
struct task_data data = {
.tgid = task->tgid,
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf/bpf_core_read.h`.
- Detected declarations: `struct time_data`, `struct work_data`, `struct task_data`, `struct work_key`, `struct task_key`, `enum kwork_class_type`, `function cpu_is_filtered`, `function update_task_info`, `function update_work`, `function on_sched_out`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.