tools/tracing/rtla/src/osnoise_top.c
Source file repositories/reference/linux-study-clean/tools/tracing/rtla/src/osnoise_top.c
File Facts
- System
- Linux kernel
- Corpus path
tools/tracing/rtla/src/osnoise_top.c- Extension
.c- Size
- 7530 bytes
- Lines
- 312
- 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
stdlib.hstring.hsignal.hunistd.hstdio.htime.hosnoise.hcli.h
Detected Declarations
struct osnoise_top_cpustruct osnoise_top_datafunction osnoise_free_topfunction osnoise_free_top_toolfunction osnoise_top_handlerfunction osnoise_top_headerfunction clear_terminalfunction osnoise_top_printfunction osnoise_print_statsfunction for_each_monitored_cpufunction osnoise_top_apply_config
Annotated Snippet
struct osnoise_top_cpu {
unsigned long long sum_runtime;
unsigned long long sum_noise;
unsigned long long max_noise;
unsigned long long max_sample;
unsigned long long hw_count;
unsigned long long nmi_count;
unsigned long long irq_count;
unsigned long long softirq_count;
unsigned long long thread_count;
int sum_cycles;
};
struct osnoise_top_data {
struct osnoise_top_cpu *cpu_data;
};
/*
* osnoise_free_top - free runtime data
*/
static void osnoise_free_top(struct osnoise_top_data *data)
{
free(data->cpu_data);
free(data);
}
static void osnoise_free_top_tool(struct osnoise_tool *tool)
{
osnoise_free_top(tool->data);
}
/*
* osnoise_alloc_histogram - alloc runtime data
*/
static struct osnoise_top_data *osnoise_alloc_top(void)
{
struct osnoise_top_data *data;
data = calloc(1, sizeof(*data));
if (!data)
return NULL;
/* one set of histograms per CPU */
data->cpu_data = calloc(1, sizeof(*data->cpu_data) * nr_cpus);
if (!data->cpu_data)
goto cleanup;
return data;
cleanup:
osnoise_free_top(data);
return NULL;
}
/*
* osnoise_top_handler - this is the handler for osnoise tracer events
*/
static int
osnoise_top_handler(struct trace_seq *s, struct tep_record *record,
struct tep_event *event, void *context)
{
struct trace_instance *trace = context;
struct osnoise_tool *tool;
unsigned long long val;
struct osnoise_top_cpu *cpu_data;
struct osnoise_top_data *data;
int cpu = record->cpu;
tool = container_of(trace, struct osnoise_tool, trace);
data = tool->data;
cpu_data = &data->cpu_data[cpu];
cpu_data->sum_cycles++;
tep_get_field_val(s, event, "runtime", record, &val, 1);
update_sum(&cpu_data->sum_runtime, &val);
tep_get_field_val(s, event, "noise", record, &val, 1);
update_max(&cpu_data->max_noise, &val);
update_sum(&cpu_data->sum_noise, &val);
tep_get_field_val(s, event, "max_sample", record, &val, 1);
update_max(&cpu_data->max_sample, &val);
tep_get_field_val(s, event, "hw_count", record, &val, 1);
update_sum(&cpu_data->hw_count, &val);
Annotation
- Immediate include surface: `stdlib.h`, `string.h`, `signal.h`, `unistd.h`, `stdio.h`, `time.h`, `osnoise.h`, `cli.h`.
- Detected declarations: `struct osnoise_top_cpu`, `struct osnoise_top_data`, `function osnoise_free_top`, `function osnoise_free_top_tool`, `function osnoise_top_handler`, `function osnoise_top_header`, `function clear_terminal`, `function osnoise_top_print`, `function osnoise_print_stats`, `function for_each_monitored_cpu`.
- 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.