tools/power/cpupower/bench/parse.c
Source file repositories/reference/linux-study-clean/tools/power/cpupower/bench/parse.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/cpupower/bench/parse.c- Extension
.c- Size
- 4981 bytes
- Lines
- 231
- 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
errno.hstdio.hstdlib.hstdarg.hstring.htime.hdirent.hsys/utsname.hsys/types.hsys/stat.hparse.hconfig.h
Detected Declarations
function Copyrightfunction prepare_config
Annotated Snippet
if (mkdir(dirname, 0755)) {
perror("mkdir");
fprintf(stderr, "error: Cannot create dir %s\n",
dirname);
return NULL;
}
}
len = strlen(dirname) + 30;
filename = malloc(sizeof(char) * len);
if (!filename) {
perror("malloc");
goto out_dir;
}
if (uname(&sysdata) == 0) {
len += strlen(sysdata.nodename) + strlen(sysdata.release);
filename_tmp = realloc(filename, sizeof(*filename) * len);
if (filename_tmp == NULL) {
free(filename);
perror("realloc");
goto out_dir;
}
filename = filename_tmp;
snprintf(filename, len - 1, "%s/benchmark_%s_%s_%li.log",
dirname, sysdata.nodename, sysdata.release, time(NULL));
} else {
snprintf(filename, len - 1, "%s/benchmark_%li.log",
dirname, time(NULL));
}
dprintf("logfilename: %s\n", filename);
output = fopen(filename, "w+");
if (output == NULL) {
perror("fopen");
fprintf(stderr, "error: unable to open logfile\n");
goto out;
}
fprintf(stdout, "Logfile: %s\n", filename);
fprintf(output, "#round load sleep performance powersave percentage\n");
out:
free(filename);
out_dir:
closedir(dir);
return output;
}
/**
* returns the default config
*
* @retval default config on success
* @retval NULL when the output file can't be created
**/
struct config *prepare_default_config()
{
struct config *config = malloc(sizeof(struct config));
if (!config) {
perror("malloc");
return NULL;
}
dprintf("loading defaults\n");
config->sleep = 500000;
config->load = 500000;
config->sleep_step = 500000;
config->load_step = 500000;
config->cycles = 5;
config->rounds = 50;
config->cpu = 0;
config->prio = SCHED_HIGH;
config->verbose = 0;
strncpy(config->governor, "ondemand", sizeof(config->governor));
config->output = stdout;
#ifdef DEFAULT_CONFIG_FILE
if (prepare_config(DEFAULT_CONFIG_FILE, config))
return NULL;
#endif
return config;
}
/**
Annotation
- Immediate include surface: `errno.h`, `stdio.h`, `stdlib.h`, `stdarg.h`, `string.h`, `time.h`, `dirent.h`, `sys/utsname.h`.
- Detected declarations: `function Copyright`, `function prepare_config`.
- 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.