tools/power/cpupower/bench/main.c
Source file repositories/reference/linux-study-clean/tools/power/cpupower/bench/main.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/bench/main.c- Extension
.c- Size
- 4738 bytes
- Lines
- 190
- 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.hstring.hunistd.hgetopt.herrno.hconfig.hsystem.hbenchmark.h
Detected Declarations
function usagefunction main
Annotated Snippet
switch (c) {
case 'o':
if (config->output != NULL)
fclose(config->output);
config->output = prepare_output(optarg);
if (config->output == NULL)
return EXIT_FAILURE;
dprintf("user output path -> %s\n", optarg);
break;
case 's':
sscanf(optarg, "%li", &config->sleep);
dprintf("user sleep time -> %s\n", optarg);
break;
case 'l':
sscanf(optarg, "%li", &config->load);
dprintf("user load time -> %s\n", optarg);
break;
case 'c':
sscanf(optarg, "%u", &config->cpu);
dprintf("user cpu -> %s\n", optarg);
break;
case 'g':
strncpy(config->governor, optarg, 14);
dprintf("user governor -> %s\n", optarg);
break;
case 'p':
if (string_to_prio(optarg) != SCHED_ERR) {
config->prio = string_to_prio(optarg);
dprintf("user prio -> %s\n", optarg);
} else {
if (config != NULL) {
if (config->output != NULL)
fclose(config->output);
free(config);
}
usage();
}
break;
case 'n':
sscanf(optarg, "%u", &config->cycles);
dprintf("user cycles -> %s\n", optarg);
break;
case 'r':
sscanf(optarg, "%u", &config->rounds);
dprintf("user rounds -> %s\n", optarg);
break;
case 'x':
sscanf(optarg, "%li", &config->load_step);
dprintf("user load_step -> %s\n", optarg);
break;
case 'y':
sscanf(optarg, "%li", &config->sleep_step);
dprintf("user sleep_step -> %s\n", optarg);
break;
case 'f':
if (prepare_config(optarg, config))
return EXIT_FAILURE;
break;
case 'v':
config->verbose = 1;
dprintf("verbose output enabled\n");
break;
case 'h':
case '?':
default:
if (config != NULL) {
if (config->output != NULL)
fclose(config->output);
free(config);
}
usage();
}
}
if (config->verbose) {
printf("starting benchmark with parameters:\n");
printf("config:\n\t"
"sleep=%li\n\t"
"load=%li\n\t"
"sleep_step=%li\n\t"
"load_step=%li\n\t"
"cpu=%u\n\t"
"cycles=%u\n\t"
"rounds=%u\n\t"
"governor=%s\n\n",
config->sleep,
config->load,
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `unistd.h`, `getopt.h`, `errno.h`, `config.h`, `system.h`.
- Detected declarations: `function usage`, `function main`.
- 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.