tools/tracing/rtla/src/osnoise.c
Source file repositories/reference/linux-study-clean/tools/tracing/rtla/src/osnoise.c
File Facts
- System
- Linux kernel
- Corpus path
tools/tracing/rtla/src/osnoise.c- Extension
.c- Size
- 33271 bytes
- Lines
- 1385
- 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.herrno.hfcntl.hstdio.hsched.hlinux/compiler.hosnoise.h
Detected Declarations
function Copyrightfunction osnoise_set_cpusfunction osnoise_set_cpusfunction osnoise_put_cpusfunction osnoise_read_ll_configfunction osnoise_write_ll_configfunction osnoise_get_runtimefunction osnoise_get_periodfunction __osnoise_write_runtimefunction __osnoise_write_periodfunction osnoise_set_runtime_periodfunction osnoise_restore_runtime_periodfunction osnoise_put_runtime_periodfunction osnoise_get_timerlat_period_usfunction osnoise_set_timerlat_period_usfunction osnoise_restore_timerlat_period_usfunction osnoise_put_timerlat_period_usfunction osnoise_get_timerlat_align_usfunction osnoise_set_timerlat_align_usfunction osnoise_restore_timerlat_align_usfunction osnoise_put_timerlat_align_usfunction osnoise_get_stop_usfunction osnoise_set_stop_usfunction osnoise_restore_stop_usfunction osnoise_put_stop_usfunction osnoise_get_stop_total_usfunction osnoise_set_stop_total_usfunction osnoise_restore_stop_total_usfunction osnoise_put_stop_total_usfunction osnoise_get_print_stackfunction osnoise_set_print_stackfunction osnoise_restore_print_stackfunction osnoise_put_print_stackfunction osnoise_get_tracing_threshfunction osnoise_set_tracing_threshfunction osnoise_restore_tracing_threshfunction osnoise_put_tracing_threshfunction osnoise_options_get_optionfunction osnoise_options_set_optionfunction osnoise_get_irq_disablefunction osnoise_set_irq_disablefunction osnoise_restore_irq_disablefunction osnoise_put_irq_disablefunction osnoise_get_workloadfunction osnoise_set_workloadfunction osnoise_restore_workloadfunction osnoise_put_workloadfunction osnoise_get_timerlat_align
Annotated Snippet
else if (tool->trace.missed_events > 0) {
total_events = tool->trace.processed_events + tool->trace.missed_events;
printf("%lld (%.2f%%) events missed, results might not be accurate\n",
tool->trace.missed_events,
(double) tool->trace.missed_events / total_events * 100.0);
}
}
/*
* osnoise_apply_config - apply osnoise configs to the initialized tool
*/
int
osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
{
int retval;
params->common.kernel_workload = true;
if (params->runtime || params->period) {
retval = osnoise_set_runtime_period(tool->context,
params->runtime,
params->period);
} else {
retval = osnoise_set_runtime_period(tool->context,
DEFAULT_SAMPLE_PERIOD,
DEFAULT_SAMPLE_RUNTIME);
}
if (retval) {
err_msg("Failed to set runtime and/or period\n");
goto out_err;
}
retval = osnoise_set_tracing_thresh(tool->context, params->threshold);
if (retval) {
err_msg("Failed to set tracing_thresh\n");
goto out_err;
}
return common_apply_config(tool, ¶ms->common);
out_err:
return -1;
}
int osnoise_enable(struct osnoise_tool *tool)
{
struct osnoise_params *params = to_osnoise_params(tool->params);
int retval;
/*
* Start the tracer here, after having set all instances.
*
* Let the trace instance start first for the case of hitting a stop
* tracing while enabling other instances. The trace instance is the
* one with most valuable information.
*/
if (tool->record)
trace_instance_start(&tool->record->trace);
trace_instance_start(&tool->trace);
if (params->common.warmup > 0) {
debug_msg("Warming up for %d seconds\n", params->common.warmup);
sleep(params->common.warmup);
if (stop_tracing)
return -1;
/*
* Clean up the buffer. The osnoise workload do not run
* with tracing off to avoid creating a performance penalty
* when not needed.
*/
retval = tracefs_instance_file_write(tool->trace.inst, "trace", "");
if (retval < 0) {
debug_msg("Error cleaning up the buffer");
return retval;
}
}
retval = osn_set_stop(tool);
if (retval)
return retval;
return 0;
}
__noreturn static void osnoise_usage(int err)
{
int i;
Annotation
- Immediate include surface: `sys/types.h`, `sys/stat.h`, `pthread.h`, `stdlib.h`, `string.h`, `unistd.h`, `errno.h`, `fcntl.h`.
- Detected declarations: `function Copyright`, `function osnoise_set_cpus`, `function osnoise_set_cpus`, `function osnoise_put_cpus`, `function osnoise_read_ll_config`, `function osnoise_write_ll_config`, `function osnoise_get_runtime`, `function osnoise_get_period`, `function __osnoise_write_runtime`, `function __osnoise_write_period`.
- 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.