tools/perf/builtin-config.c
Source file repositories/reference/linux-study-clean/tools/perf/builtin-config.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/builtin-config.c- Extension
.c- Size
- 6777 bytes
- Lines
- 299
- 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
builtin.hutil/cache.hsubcmd/parse-options.hutil/debug.hutil/config.hlinux/string.hlimits.hstdio.hstdlib.h
Detected Declarations
function set_configfunction perf_config_items__for_each_entryfunction show_spec_configfunction perf_config_items__for_each_entryfunction perf_config_items__for_each_entryfunction show_configfunction perf_config_set__for_each_entryfunction parse_config_argfunction perf_config__set_variablefunction cmd_config
Annotated Snippet
perf_config_items__for_each_entry(§ion->items, item) {
if (!use_system_config && item->from_system_config)
continue;
if (item->value)
fprintf(fp, "\t%s = %s\n",
item->name, item->value);
}
}
fclose(fp);
return 0;
}
static int show_spec_config(struct perf_config_set *set, const char *var)
{
struct perf_config_section *section;
struct perf_config_item *item;
if (set == NULL)
return -1;
perf_config_items__for_each_entry(&set->sections, section) {
if (!strstarts(var, section->name))
continue;
perf_config_items__for_each_entry(§ion->items, item) {
const char *name = var + strlen(section->name) + 1;
if (strcmp(name, item->name) == 0) {
char *value = item->value;
if (value) {
printf("%s=%s\n", var, value);
return 0;
}
}
}
}
return 0;
}
static int show_config(struct perf_config_set *set)
{
struct perf_config_section *section;
struct perf_config_item *item;
if (set == NULL)
return -1;
perf_config_set__for_each_entry(set, section, item) {
char *value = item->value;
if (value)
printf("%s.%s=%s\n", section->name,
item->name, value);
}
return 0;
}
static int parse_config_arg(char *arg, char **var, char **value)
{
const char *last_dot = strchr(arg, '.');
/*
* Since "var" actually contains the section name and the real
* config variable name separated by a dot, we have to know where the dot is.
*/
if (last_dot == NULL || last_dot == arg) {
pr_err("The config variable does not contain a section name: %s\n", arg);
return -1;
}
if (!last_dot[1]) {
pr_err("The config variable does not contain a variable name: %s\n", arg);
return -1;
}
*value = strchr(arg, '=');
if (*value == NULL)
*var = arg;
else if (!strcmp(*value, "=")) {
pr_err("The config variable does not contain a value: %s\n", arg);
return -1;
} else {
*value = *value + 1; /* excluding a first character '=' */
*var = strsep(&arg, "=");
if (*var[0] == '\0') {
pr_err("invalid config variable: %s\n", arg);
Annotation
- Immediate include surface: `builtin.h`, `util/cache.h`, `subcmd/parse-options.h`, `util/debug.h`, `util/config.h`, `linux/string.h`, `limits.h`, `stdio.h`.
- Detected declarations: `function set_config`, `function perf_config_items__for_each_entry`, `function show_spec_config`, `function perf_config_items__for_each_entry`, `function perf_config_items__for_each_entry`, `function show_config`, `function perf_config_set__for_each_entry`, `function parse_config_arg`, `function perf_config__set_variable`, `function cmd_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.