tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
Source file repositories/reference/linux-study-clean/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c- Extension
.c- Size
- 5025 bytes
- Lines
- 213
- 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.hstdlib.hstdint.hstring.hlimits.hcpuidle.hhelpers/helpers.hidle_monitor/cpupower-monitor.h
Detected Declarations
function cpuidle_get_count_percentfunction cpuidle_startfunction cpuidle_stopfunction fix_up_intel_idle_driver_namefunction map_power_idle_state_namefunction map_power_idle_state_namefunction cpuidle_unregister
Annotated Snippet
switch (num) {
case 1:
strcpy(tmp, "C1");
break;
case 2:
strcpy(tmp, "C3");
break;
case 3:
strcpy(tmp, "C6");
break;
}
} else if (!strncmp(tmp, "SNB-", 4)) {
switch (num) {
case 1:
strcpy(tmp, "C1");
break;
case 2:
strcpy(tmp, "C3");
break;
case 3:
strcpy(tmp, "C6");
break;
case 4:
strcpy(tmp, "C7");
break;
}
} else if (!strncmp(tmp, "ATM-", 4)) {
switch (num) {
case 1:
strcpy(tmp, "C1");
break;
case 2:
strcpy(tmp, "C2");
break;
case 3:
strcpy(tmp, "C4");
break;
case 4:
strcpy(tmp, "C6");
break;
}
}
}
#ifdef __powerpc__
void map_power_idle_state_name(char *tmp)
{
if (!strncmp(tmp, "stop0_lite", CSTATE_NAME_LEN))
strcpy(tmp, "stop0L");
else if (!strncmp(tmp, "stop1_lite", CSTATE_NAME_LEN))
strcpy(tmp, "stop1L");
else if (!strncmp(tmp, "stop2_lite", CSTATE_NAME_LEN))
strcpy(tmp, "stop2L");
}
#else
void map_power_idle_state_name(char *tmp) { }
#endif
static struct cpuidle_monitor *cpuidle_register(void)
{
int num;
char *tmp;
int this_cpu;
this_cpu = sched_getcpu();
/* Assume idle state count is the same for all CPUs */
cpuidle_sysfs_monitor.hw_states_num = cpuidle_state_count(this_cpu);
if (cpuidle_sysfs_monitor.hw_states_num <= 0)
return NULL;
for (num = 0; num < cpuidle_sysfs_monitor.hw_states_num; num++) {
tmp = cpuidle_state_name(this_cpu, num);
if (tmp == NULL)
continue;
map_power_idle_state_name(tmp);
fix_up_intel_idle_driver_name(tmp, num);
strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1);
free(tmp);
tmp = cpuidle_state_desc(this_cpu, num);
if (tmp == NULL)
continue;
strncpy(cpuidle_cstates[num].desc, tmp, CSTATE_DESC_LEN - 1);
free(tmp);
cpuidle_cstates[num].range = RANGE_THREAD;
cpuidle_cstates[num].id = num;
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `stdint.h`, `string.h`, `limits.h`, `cpuidle.h`, `helpers/helpers.h`, `idle_monitor/cpupower-monitor.h`.
- Detected declarations: `function cpuidle_get_count_percent`, `function cpuidle_start`, `function cpuidle_stop`, `function fix_up_intel_idle_driver_name`, `function map_power_idle_state_name`, `function map_power_idle_state_name`, `function cpuidle_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.