tools/tracing/rtla/src/osnoise_hist.c
Source file repositories/reference/linux-study-clean/tools/tracing/rtla/src/osnoise_hist.c
File Facts
- System
- Linux kernel
- Corpus path
tools/tracing/rtla/src/osnoise_hist.c- Extension
.c- Size
- 10868 bytes
- Lines
- 468
- 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_hist_cpustruct osnoise_hist_datafunction osnoise_free_histogramfunction osnoise_free_hist_toolfunction osnoise_hist_update_multiplefunction osnoise_destroy_trace_histfunction osnoise_init_trace_histfunction osnoise_read_trace_histfunction osnoise_hist_headerfunction for_each_monitored_cpufunction osnoise_print_summaryfunction for_each_monitored_cpufunction for_each_monitored_cpufunction for_each_monitored_cpufunction for_each_monitored_cpufunction osnoise_print_statsfunction for_each_monitored_cpufunction for_each_monitored_cpufunction osnoise_hist_apply_configfunction osnoise_hist_enablefunction osnoise_hist_main_loop
Annotated Snippet
struct osnoise_hist_cpu {
int *samples;
int count;
unsigned long long min_sample;
unsigned long long sum_sample;
unsigned long long max_sample;
};
struct osnoise_hist_data {
struct tracefs_hist *trace_hist;
struct osnoise_hist_cpu *hist;
int entries;
int bucket_size;
};
/*
* osnoise_free_histogram - free runtime data
*/
static void
osnoise_free_histogram(struct osnoise_hist_data *data)
{
int cpu;
/* one histogram for IRQ and one for thread, per CPU */
for (cpu = 0; cpu < nr_cpus; cpu++) {
if (data->hist[cpu].samples)
free(data->hist[cpu].samples);
}
/* one set of histograms per CPU */
if (data->hist)
free(data->hist);
free(data);
}
static void osnoise_free_hist_tool(struct osnoise_tool *tool)
{
osnoise_free_histogram(tool->data);
}
/*
* osnoise_alloc_histogram - alloc runtime data
*/
static struct osnoise_hist_data
*osnoise_alloc_histogram(int entries, int bucket_size)
{
struct osnoise_hist_data *data;
int cpu;
data = calloc(1, sizeof(*data));
if (!data)
return NULL;
data->entries = entries;
data->bucket_size = bucket_size;
data->hist = calloc(1, sizeof(*data->hist) * nr_cpus);
if (!data->hist)
goto cleanup;
for (cpu = 0; cpu < nr_cpus; cpu++) {
data->hist[cpu].samples = calloc(1, sizeof(*data->hist->samples) * (entries + 1));
if (!data->hist[cpu].samples)
goto cleanup;
}
/* set the min to max */
for (cpu = 0; cpu < nr_cpus; cpu++)
data->hist[cpu].min_sample = ~0;
return data;
cleanup:
osnoise_free_histogram(data);
return NULL;
}
static void osnoise_hist_update_multiple(struct osnoise_tool *tool, int cpu,
unsigned long long duration, int count)
{
struct osnoise_params *params = to_osnoise_params(tool->params);
struct osnoise_hist_data *data = tool->data;
unsigned long long total_duration;
int entries = data->entries;
int bucket;
int *hist;
Annotation
- Immediate include surface: `stdlib.h`, `string.h`, `signal.h`, `unistd.h`, `stdio.h`, `time.h`, `osnoise.h`, `cli.h`.
- Detected declarations: `struct osnoise_hist_cpu`, `struct osnoise_hist_data`, `function osnoise_free_histogram`, `function osnoise_free_hist_tool`, `function osnoise_hist_update_multiple`, `function osnoise_destroy_trace_hist`, `function osnoise_init_trace_hist`, `function osnoise_read_trace_hist`, `function osnoise_hist_header`, `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.