tools/power/cpupower/utils/cpuidle-set.c
Source file repositories/reference/linux-study-clean/tools/power/cpupower/utils/cpuidle-set.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/utils/cpuidle-set.c- Extension
.c- Size
- 4254 bytes
- Lines
- 186
- 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
unistd.hstdio.herrno.hstdlib.hlimits.hstring.hctype.hgetopt.hcpufreq.hcpuidle.hhelpers/helpers.h
Detected Declarations
function cmd_idle_set
Annotated Snippet
switch (ret) {
case '?':
param = '?';
cont = 0;
break;
case 'd':
case 'e':
if (param) {
param = -1;
cont = 0;
break;
}
param = ret;
strtol(optarg, &endptr, 10);
if (*endptr != '\0') {
printf(_("Bad value: %s, Integer expected\n"), optarg);
exit(EXIT_FAILURE);
} else {
idlestate = atoi(optarg);
}
break;
case 'D':
if (param) {
param = -1;
cont = 0;
break;
}
param = ret;
latency = strtoull(optarg, &endptr, 10);
if (*endptr != '\0') {
printf(_("Bad latency value: %s\n"), optarg);
exit(EXIT_FAILURE);
}
break;
case 'E':
if (param) {
param = -1;
cont = 0;
break;
}
param = ret;
break;
case -1:
cont = 0;
break;
}
} while (cont);
switch (param) {
case -1:
printf(_("You can't specify more than one "
"output-specific argument\n"));
exit(EXIT_FAILURE);
case '?':
printf(_("invalid or unknown argument\n"));
exit(EXIT_FAILURE);
}
get_cpustate();
/* Default is: set all CPUs */
if (bitmask_isallclear(cpus_chosen))
bitmask_setall(cpus_chosen);
for (cpu = bitmask_first(cpus_chosen);
cpu <= bitmask_last(cpus_chosen); cpu++) {
if (!bitmask_isbitset(cpus_chosen, cpu))
continue;
if (cpupower_is_cpu_online(cpu) != 1)
continue;
idlestates = cpuidle_state_count(cpu);
if (idlestates <= 0)
continue;
switch (param) {
case 'd':
ret = cpuidle_state_disable(cpu, idlestate, 1);
if (ret == 0)
printf(_("Idlestate %u disabled on CPU %u\n"), idlestate, cpu);
else if (ret == -1)
printf(_("Idlestate %u not available on CPU %u\n"),
idlestate, cpu);
else if (ret == -2)
printf(_("Idlestate disabling not supported by kernel\n"));
else
printf(_("Idlestate %u not disabled on CPU %u\n"),
idlestate, cpu);
Annotation
- Immediate include surface: `unistd.h`, `stdio.h`, `errno.h`, `stdlib.h`, `limits.h`, `string.h`, `ctype.h`, `getopt.h`.
- Detected declarations: `function cmd_idle_set`.
- 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.