tools/tracing/rtla/src/timerlat.bpf.c
Source file repositories/reference/linux-study-clean/tools/tracing/rtla/src/timerlat.bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/tracing/rtla/src/timerlat.bpf.c- Extension
.c- Size
- 4234 bytes
- Lines
- 175
- 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
linux/bpf.hbpf/bpf_tracing.hstdbool.htimerlat_bpf.h
Detected Declarations
struct trace_event_raw_timerlat_samplefunction map_getfunction map_setfunction map_incrementfunction update_main_histfunction update_summaryfunction set_stop_tracingfunction handle_timerlat_sample
Annotated Snippet
struct trace_event_raw_timerlat_sample {
unsigned long long timer_latency;
int context;
} __attribute__((preserve_access_index));
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(max_entries, MAX_ENTRIES_DEFAULT);
__type(key, unsigned int);
__type(value, unsigned long long);
} hist_irq SEC(".maps"), hist_thread SEC(".maps"), hist_user SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(max_entries, SUMMARY_FIELD_N);
__type(key, unsigned int);
__type(value, unsigned long long);
} summary_irq SEC(".maps"), summary_thread SEC(".maps"), summary_user SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, unsigned int);
__type(value, unsigned long long);
} stop_tracing SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_RINGBUF);
__uint(max_entries, 1);
} signal_stop_tracing SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
__uint(key_size, sizeof(unsigned int));
__uint(max_entries, 1);
__array(values, unsigned int (void *));
} bpf_action SEC(".maps") = {
.values = {
[0] = 0
},
};
/* Params to be set by rtla */
const volatile int bucket_size = 1;
const volatile int output_divisor = 1000;
const volatile int entries = 256;
const volatile int irq_threshold;
const volatile int thread_threshold;
const volatile bool aa_only;
nosubprog unsigned long long map_get(void *map,
unsigned int key)
{
unsigned long long *value_ptr;
value_ptr = bpf_map_lookup_elem(map, &key);
return !value_ptr ? 0 : *value_ptr;
}
nosubprog void map_set(void *map,
unsigned int key,
unsigned long long value)
{
bpf_map_update_elem(map, &key, &value, BPF_ANY);
}
nosubprog void map_increment(void *map,
unsigned int key)
{
map_set(map, key, map_get(map, key) + 1);
}
nosubprog void update_main_hist(void *map,
int bucket)
{
if (entries == 0)
/* No histogram */
return;
if (bucket >= entries)
/* Overflow */
return;
map_increment(map, bucket);
}
nosubprog void update_summary(void *map,
unsigned long long latency,
int bucket)
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_tracing.h`, `stdbool.h`, `timerlat_bpf.h`.
- Detected declarations: `struct trace_event_raw_timerlat_sample`, `function map_get`, `function map_set`, `function map_increment`, `function update_main_hist`, `function update_summary`, `function set_stop_tracing`, `function handle_timerlat_sample`.
- 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.