tools/power/x86/turbostat/turbostat.c
Source file repositories/reference/linux-study-clean/tools/power/x86/turbostat/turbostat.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/x86/turbostat/turbostat.c- Extension
.c- Size
- 317963 bytes
- Lines
- 11721
- 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
stdarg.hstdio.herr.hunistd.hsys/types.hsys/wait.hsys/stat.hsys/select.hsys/resource.hsys/mman.hfcntl.hsignal.hsys/time.hstdlib.hgetopt.hdirent.hstring.hctype.hsched.htime.hcpuid.hsys/capability.herrno.hmath.hlinux/perf_event.hasm/unistd.hstdbool.hassert.hlinux/kernel.hlimits.h
Detected Declarations
struct perf_counter_infostruct sysfs_pathstruct msr_counterstruct gfx_sysfs_infostruct platform_featuresstruct platform_datastruct perf_l2_eventsstruct perf_model_supportstruct rapl_counter_info_tstruct rapl_counter_arch_infostruct rapl_counterstruct cstate_counter_info_tstruct cstate_counter_arch_infostruct msr_counter_info_tstruct msr_counter_arch_infostruct pmt_mmiostruct pmt_domain_infostruct pmt_counterstruct pmt_diriter_tstruct llc_statsstruct l2_statsstruct thread_datastruct core_datastruct pkg_datastruct msr_sum_arraystruct sys_countersstruct countersstruct platform_countersstruct cpu_topologystruct topo_paramsstruct read_formatstruct read_formatenum counter_scopeenum counter_typeenum counter_formatenum counter_sourceenum bic_namesenum gfx_sysfs_idxenum bclk_freqenum package_cstate_limitenum turbo_ratio_limit_msrsenum perf_limit_reason_msrsenum rapl_msrsenum cstatesenum rapl_rci_indexenum rapl_unitenum ccstate_rci_indexenum msr_rci_index
Annotated Snippet
struct perf_counter_info {
struct perf_counter_info *next;
/* How to open the counter / What counter it is. */
char device[PERF_DEV_NAME_BYTES];
char event[PERF_EVT_NAME_BYTES];
/* How to show/format the counter. */
char name[PERF_NAME_BYTES];
unsigned int width;
enum counter_scope scope;
enum counter_type type;
enum counter_format format;
double scale;
/* For reading the counter. */
int *fd_perf_per_domain;
size_t num_domains;
};
struct sysfs_path {
char path[PATH_BYTES];
int id;
struct sysfs_path *next;
};
struct msr_counter {
unsigned int msr_num;
char name[NAME_BYTES];
struct sysfs_path *sp;
unsigned int width;
enum counter_type type;
enum counter_format format;
struct msr_counter *next;
unsigned int flags;
#define FLAGS_HIDE (1 << 0)
#define FLAGS_SHOW (1 << 1)
#define SYSFS_PERCPU (1 << 1)
};
static int use_android_msr_path;
struct msr_counter bic[] = {
{ 0x0, "usec", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Time_Of_Day_Seconds", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Package", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Node", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Avg_MHz", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Busy%", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Bzy_MHz", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "TSC_MHz", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "IRQ", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "SMI", NULL, 32, 0, FORMAT_DELTA, NULL, 0 },
{ 0x0, "cpuidle", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CPU%c1", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CPU%c3", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CPU%c6", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CPU%c7", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "ThreadC", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CoreTmp", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CoreCnt", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "PkgTmp", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "GFX%rc6", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "GFXMHz", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Pkg%pc2", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Pkg%pc3", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Pkg%pc6", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Pkg%pc7", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Pkg%pc8", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Pkg%pc9", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Pk%pc10", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CPU%LPI", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "SYS%LPI", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "PkgWatt", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CorWatt", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "GFXWatt", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "PkgCnt", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "RAMWatt", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "PKG_%", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "RAM_%", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Pkg_J", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Cor_J", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "GFX_J", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "RAM_J", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Mod%c6", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Totl%C0", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Any%C0", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "GFX%C0", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "CPUGFX%", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Module", NULL, 0, 0, 0, NULL, 0 },
{ 0x0, "Core", NULL, 0, 0, 0, NULL, 0 },
Annotation
- Immediate include surface: `stdarg.h`, `stdio.h`, `err.h`, `unistd.h`, `sys/types.h`, `sys/wait.h`, `sys/stat.h`, `sys/select.h`.
- Detected declarations: `struct perf_counter_info`, `struct sysfs_path`, `struct msr_counter`, `struct gfx_sysfs_info`, `struct platform_features`, `struct platform_data`, `struct perf_l2_events`, `struct perf_model_support`, `struct rapl_counter_info_t`, `struct rapl_counter_arch_info`.
- 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.