tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c
Source file repositories/reference/linux-study-clean/tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/utils/idle_monitor/hsw_ext_idle.c- Extension
.c- Size
- 4726 bytes
- Lines
- 195
- 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
stdio.hstdint.hstdlib.hstring.hhelpers/helpers.hidle_monitor/cpupower-monitor.h
Detected Declarations
enum intel_hsw_ext_idfunction hsw_ext_get_countfunction hsw_ext_get_count_percentfunction hsw_ext_startfunction hsw_ext_stopfunction hsw_ext_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* (C) 2010,2011 Thomas Renninger <trenn@suse.de>, Novell Inc.
*
* Based on SandyBridge monitor. Implements the new package C-states
* (PC8, PC9, PC10) coming with a specific Haswell (family 0x45) CPU.
*/
#if defined(__i386__) || defined(__x86_64__)
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "helpers/helpers.h"
#include "idle_monitor/cpupower-monitor.h"
#define MSR_PKG_C8_RESIDENCY 0x00000630
#define MSR_PKG_C9_RESIDENCY 0x00000631
#define MSR_PKG_C10_RESIDENCY 0x00000632
#define MSR_TSC 0x10
enum intel_hsw_ext_id { PC8 = 0, PC9, PC10, HSW_EXT_CSTATE_COUNT,
TSC = 0xFFFF };
static int hsw_ext_get_count_percent(unsigned int self_id, double *percent,
unsigned int cpu);
static cstate_t hsw_ext_cstates[HSW_EXT_CSTATE_COUNT] = {
{
.name = "PC8",
.desc = N_("Processor Package C8"),
.id = PC8,
.range = RANGE_PACKAGE,
.get_count_percent = hsw_ext_get_count_percent,
},
{
.name = "PC9",
.desc = N_("Processor Package C9"),
.id = PC9,
.range = RANGE_PACKAGE,
.get_count_percent = hsw_ext_get_count_percent,
},
{
.name = "PC10",
.desc = N_("Processor Package C10"),
.id = PC10,
.range = RANGE_PACKAGE,
.get_count_percent = hsw_ext_get_count_percent,
},
};
static unsigned long long tsc_at_measure_start;
static unsigned long long tsc_at_measure_end;
static unsigned long long *previous_count[HSW_EXT_CSTATE_COUNT];
static unsigned long long *current_count[HSW_EXT_CSTATE_COUNT];
/* valid flag for all CPUs. If a MSR read failed it will be zero */
static int *is_valid;
static int hsw_ext_get_count(enum intel_hsw_ext_id id, unsigned long long *val,
unsigned int cpu)
{
int msr;
switch (id) {
case PC8:
msr = MSR_PKG_C8_RESIDENCY;
break;
case PC9:
msr = MSR_PKG_C9_RESIDENCY;
break;
case PC10:
msr = MSR_PKG_C10_RESIDENCY;
break;
case TSC:
msr = MSR_TSC;
break;
default:
return -1;
}
if (read_msr(cpu, msr, val))
return -1;
return 0;
}
static int hsw_ext_get_count_percent(unsigned int id, double *percent,
unsigned int cpu)
{
Annotation
- Immediate include surface: `stdio.h`, `stdint.h`, `stdlib.h`, `string.h`, `helpers/helpers.h`, `idle_monitor/cpupower-monitor.h`.
- Detected declarations: `enum intel_hsw_ext_id`, `function hsw_ext_get_count`, `function hsw_ext_get_count_percent`, `function hsw_ext_start`, `function hsw_ext_stop`, `function hsw_ext_unregister`.
- 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.