tools/perf/util/bpf_skel/kwork_trace.bpf.c
Source file repositories/reference/linux-study-clean/tools/perf/util/bpf_skel/kwork_trace.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/bpf_skel/kwork_trace.bpf.c- Extension
.c- Size
- 9038 bytes
- Lines
- 385
- 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.h
Detected Declarations
struct work_keystruct report_dataenum kwork_class_typefunction local_strncmpfunction trace_event_matchfunction do_update_timefunction do_update_timestartfunction do_update_timeendfunction do_update_namefunction update_timestartfunction update_timestart_and_namefunction update_timeendfunction update_timeend_and_namefunction report_irq_handler_entryfunction report_irq_handler_exitfunction report_softirq_entryfunction report_softirq_exitfunction latency_softirq_raisefunction latency_softirq_entryfunction report_workqueue_execute_startfunction report_workqueue_execute_endfunction latency_workqueue_activate_workfunction latency_workqueue_execute_start
Annotated Snippet
struct work_key {
__u32 type;
__u32 cpu;
__u64 id;
};
struct report_data {
__u64 nr;
__u64 total_time;
__u64 max_time;
__u64 max_time_start;
__u64 max_time_end;
};
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(key_size, sizeof(struct work_key));
__uint(value_size, MAX_KWORKNAME);
__uint(max_entries, KWORK_COUNT);
} perf_kwork_names SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(key_size, sizeof(struct work_key));
__uint(value_size, sizeof(__u64));
__uint(max_entries, KWORK_COUNT);
} perf_kwork_time SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(key_size, sizeof(struct work_key));
__uint(value_size, sizeof(struct report_data));
__uint(max_entries, KWORK_COUNT);
} perf_kwork_report SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(key_size, sizeof(__u32));
__uint(value_size, sizeof(__u8));
__uint(max_entries, 1);
} perf_kwork_cpu_filter SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(key_size, sizeof(__u32));
__uint(value_size, MAX_KWORKNAME);
__uint(max_entries, 1);
} perf_kwork_name_filter SEC(".maps");
int enabled = 0;
const volatile int has_cpu_filter = 0;
const volatile int has_name_filter = 0;
static __always_inline int local_strncmp(const char *s1,
unsigned int sz, const char *s2)
{
int ret = 0;
unsigned int i;
for (i = 0; i < sz; i++) {
ret = (unsigned char)s1[i] - (unsigned char)s2[i];
if (ret || !s1[i])
break;
}
return ret;
}
static __always_inline int trace_event_match(struct work_key *key, char *name)
{
__u8 *cpu_val;
char *name_val;
__u32 zero = 0;
__u32 cpu = bpf_get_smp_processor_id();
if (!enabled)
return 0;
if (has_cpu_filter) {
cpu_val = bpf_map_lookup_elem(&perf_kwork_cpu_filter, &cpu);
if (!cpu_val)
return 0;
}
if (has_name_filter && (name != NULL)) {
name_val = bpf_map_lookup_elem(&perf_kwork_name_filter, &zero);
if (name_val &&
(local_strncmp(name_val, MAX_KWORKNAME, name) != 0)) {
return 0;
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`.
- Detected declarations: `struct work_key`, `struct report_data`, `enum kwork_class_type`, `function local_strncmp`, `function trace_event_match`, `function do_update_time`, `function do_update_timestart`, `function do_update_timeend`, `function do_update_name`, `function update_timestart`.
- 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.