tools/perf/util/bpf_kwork_top.c
Source file repositories/reference/linux-study-clean/tools/perf/util/bpf_kwork_top.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/bpf_kwork_top.c- Extension
.c- Size
- 6350 bytes
- Lines
- 311
- 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
time.hfcntl.hsignal.hstdio.hunistd.hlinux/time64.hutil/debug.hutil/evsel.hutil/kwork.hbpf/bpf.hperf/cpumap.hutil/bpf_skel/kwork_top.skel.h
Detected Declarations
struct time_datastruct work_datastruct task_datastruct work_keystruct task_keystruct kwork_class_bpffunction perf_kwork__top_startfunction perf_kwork__top_finishfunction irq_load_preparefunction softirq_load_preparefunction sched_load_preparefunction valid_kwork_class_typefunction setup_filtersfunction perf_cpu_map__for_each_cpufunction perf_kwork__top_prepare_bpffunction list_for_each_entryfunction read_task_infofunction add_workfunction perf_kwork__top_read_bpffunction perf_kwork__top_cleanup_bpf
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 kwork_class_bpf {
struct kwork_class *class;
void (*load_prepare)(void);
};
static struct kwork_top_bpf *skel;
void perf_kwork__top_start(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
skel->bss->from_timestamp = (u64)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
skel->bss->enabled = 1;
pr_debug("perf kwork top start at: %lld\n", skel->bss->from_timestamp);
}
void perf_kwork__top_finish(void)
{
struct timespec ts;
skel->bss->enabled = 0;
clock_gettime(CLOCK_MONOTONIC, &ts);
skel->bss->to_timestamp = (u64)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
pr_debug("perf kwork top finish at: %lld\n", skel->bss->to_timestamp);
}
static void irq_load_prepare(void)
{
bpf_program__set_autoload(skel->progs.on_irq_handler_entry, true);
bpf_program__set_autoload(skel->progs.on_irq_handler_exit, true);
}
static struct kwork_class_bpf kwork_irq_bpf = {
.load_prepare = irq_load_prepare,
};
static void softirq_load_prepare(void)
{
bpf_program__set_autoload(skel->progs.on_softirq_entry, true);
bpf_program__set_autoload(skel->progs.on_softirq_exit, true);
}
static struct kwork_class_bpf kwork_softirq_bpf = {
.load_prepare = softirq_load_prepare,
};
static void sched_load_prepare(void)
{
bpf_program__set_autoload(skel->progs.on_switch, true);
}
static struct kwork_class_bpf kwork_sched_bpf = {
.load_prepare = sched_load_prepare,
};
static struct kwork_class_bpf *
kwork_class_bpf_supported_list[KWORK_CLASS_MAX] = {
[KWORK_CLASS_IRQ] = &kwork_irq_bpf,
[KWORK_CLASS_SOFTIRQ] = &kwork_softirq_bpf,
[KWORK_CLASS_SCHED] = &kwork_sched_bpf,
};
static bool valid_kwork_class_type(enum kwork_class_type type)
{
Annotation
- Immediate include surface: `time.h`, `fcntl.h`, `signal.h`, `stdio.h`, `unistd.h`, `linux/time64.h`, `util/debug.h`, `util/evsel.h`.
- Detected declarations: `struct time_data`, `struct work_data`, `struct task_data`, `struct work_key`, `struct task_key`, `struct kwork_class_bpf`, `function perf_kwork__top_start`, `function perf_kwork__top_finish`, `function irq_load_prepare`, `function softirq_load_prepare`.
- 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.