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.

Dependency Surface

Detected Declarations

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

Implementation Notes