tools/tracing/rtla/src/timerlat.c
Source file repositories/reference/linux-study-clean/tools/tracing/rtla/src/timerlat.c
File Facts
- System
- Linux kernel
- Corpus path
tools/tracing/rtla/src/timerlat.c- Extension
.c- Size
- 7786 bytes
- Lines
- 308
- 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
sys/types.hsys/stat.hpthread.hstdlib.hstring.hunistd.hfcntl.hstdio.hsched.hlinux/compiler.htimerlat.htimerlat_aa.htimerlat_bpf.h
Detected Declarations
function timerlat_apply_configfunction timerlat_enablefunction for_each_monitored_cpufunction timerlat_analyzefunction timerlat_freefunction for_each_monitored_cpufunction timerlat_usagefunction timerlat_main
Annotated Snippet
if (retval) {
debug_msg("Could not enable BPF\n");
params->mode = TRACING_MODE_TRACEFS;
}
}
/* Check if BPF action program is requested but BPF is not available */
if (params->bpf_action_program) {
if (params->mode == TRACING_MODE_TRACEFS) {
err_msg("BPF actions are not supported in tracefs-only mode\n");
goto out_err;
}
if (timerlat_load_bpf_action_program(params->bpf_action_program))
goto out_err;
}
retval = osnoise_set_timerlat_period_us(tool->context,
params->timerlat_period_us ?
params->timerlat_period_us :
DEFAULT_TIMERLAT_PERIOD);
if (retval) {
err_msg("Failed to set timerlat period\n");
goto out_err;
}
retval = osnoise_set_print_stack(tool->context, params->print_stack);
if (retval) {
err_msg("Failed to set print stack\n");
goto out_err;
}
retval = osnoise_set_timerlat_align(tool->context, params->timerlat_align);
if (retval && params->timerlat_align) {
/*
* We might be running on a kernel that does not support timerlat align.
* Unless user requested it explicitly, ignore the error.
*/
err_msg("Failed to enable timerlat align\n");
goto out_err;
}
if (params->timerlat_align) {
retval = osnoise_set_timerlat_align_us(tool->context, params->timerlat_align_us);
if (retval) {
err_msg("Failed to set timerlat align us\n");
goto out_err;
}
}
/*
* If the user did not specify a type of thread, try user-threads first.
* Fall back to kernel threads otherwise.
*/
if (!params->common.kernel_workload && !params->common.user_data) {
retval = tracefs_file_exists(NULL, "osnoise/per_cpu/cpu0/timerlat_fd");
if (retval) {
debug_msg("User-space interface detected, setting user-threads\n");
params->common.user_workload = 1;
params->common.user_data = 1;
} else {
debug_msg("User-space interface not detected, setting kernel-threads\n");
params->common.kernel_workload = 1;
}
}
return common_apply_config(tool, ¶ms->common);
out_err:
return -1;
}
int timerlat_enable(struct osnoise_tool *tool)
{
struct timerlat_params *params = to_timerlat_params(tool->params);
int retval, i;
if (params->dma_latency >= 0) {
dma_latency_fd = set_cpu_dma_latency(params->dma_latency);
if (dma_latency_fd < 0) {
err_msg("Could not set /dev/cpu_dma_latency.\n");
return -1;
}
}
if (params->deepest_idle_state >= -1) {
if (!have_libcpupower_support()) {
err_msg("rtla built without libcpupower, --deepest-idle-state is not supported\n");
return -1;
Annotation
- Immediate include surface: `sys/types.h`, `sys/stat.h`, `pthread.h`, `stdlib.h`, `string.h`, `unistd.h`, `fcntl.h`, `stdio.h`.
- Detected declarations: `function timerlat_apply_config`, `function timerlat_enable`, `function for_each_monitored_cpu`, `function timerlat_analyze`, `function timerlat_free`, `function for_each_monitored_cpu`, `function timerlat_usage`, `function timerlat_main`.
- 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.