tools/tracing/rtla/src/common.c
Source file repositories/reference/linux-study-clean/tools/tracing/rtla/src/common.c
File Facts
- System
- Linux kernel
- Corpus path
tools/tracing/rtla/src/common.c- Extension
.c- Size
- 10326 bytes
- Lines
- 457
- 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
pthread.hsignal.hstdlib.hstring.hsys/sysinfo.hcommon.h
Detected Declarations
function stop_tracefunction set_signalsfunction unset_signalsfunction common_apply_configfunction actionsfunction run_toolfunction top_main_loopfunction hist_main_loopfunction osn_set_stopfunction print_msg_arrayfunction common_usage
Annotated Snippet
if (retval == -1) {
err_msg("Failed to set rtla to the house keeping CPUs\n");
goto out_err;
}
} else if (params->cpus) {
/*
* Even if the user do not set a house-keeping CPU, try to
* move rtla to a CPU set different to the one where the user
* set the workload to run.
*
* No need to check results as this is an automatic attempt.
*/
auto_house_keeping(¶ms->monitored_cpus);
}
/*
* Set workload according to type of thread if the kernel supports it.
* On kernels without support, user threads will have already failed
* on missing fd, and kernel threads do not need it.
*/
retval = osnoise_set_workload(tool->context, params->kernel_workload);
if (retval < -1) {
err_msg("Failed to set OSNOISE_WORKLOAD option\n");
goto out_err;
}
return 0;
out_err:
return -1;
}
/**
* common_threshold_handler - handle latency threshold overflow
* @tool: pointer to the osnoise_tool instance containing trace contexts
*
* Executes the configured threshold actions (e.g., saving trace, printing,
* sending signals). If the continue flag is set (--on-threshold continue),
* restarts the auxiliary trace instances to continue monitoring.
*
* Return: 0 for success, -1 for error.
*/
int
common_threshold_handler(const struct osnoise_tool *tool)
{
actions_perform(&tool->params->threshold_actions);
if (!should_continue_tracing(tool->params))
/* continue flag not set, break */
return 0;
/* continue action reached, re-enable tracing */
if (tool->record && trace_instance_start(&tool->record->trace))
goto err;
if (tool->aa && trace_instance_start(&tool->aa->trace))
goto err;
return 0;
err:
err_msg("Error restarting trace\n");
return -1;
}
int run_tool(struct tool_ops *ops, int argc, char *argv[])
{
struct common_params *params;
enum result return_value = ERROR;
struct osnoise_tool *tool;
bool stopped;
int retval;
nr_cpus = get_nprocs_conf();
params = ops->parse_args(argc, argv);
if (!params)
exit(1);
tool = ops->init_tool(params);
if (!tool) {
err_msg("Could not init osnoise tool\n");
goto out_exit;
}
tool->ops = ops;
tool->params = params;
/*
* Expose the tool to signal handlers so they can stop the trace.
* Otherwise, rtla could loop indefinitely when overloaded.
*/
Annotation
- Immediate include surface: `pthread.h`, `signal.h`, `stdlib.h`, `string.h`, `sys/sysinfo.h`, `common.h`.
- Detected declarations: `function stop_trace`, `function set_signals`, `function unset_signals`, `function common_apply_config`, `function actions`, `function run_tool`, `function top_main_loop`, `function hist_main_loop`, `function osn_set_stop`, `function print_msg_array`.
- 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.