tools/perf/util/pmu.c
Source file repositories/reference/linux-study-clean/tools/perf/util/pmu.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/pmu.c- Extension
.c- Size
- 67778 bytes
- Lines
- 2746
- 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
linux/list.hlinux/compiler.hlinux/string.hlinux/zalloc.hlinux/ctype.hsys/types.hfcntl.hsys/stat.hunistd.hstdio.hstdbool.hdirent.hapi/fs/fs.hapi/io.hapi/io_dir.hlocale.hfnmatch.hmath.hdebug.hevsel.hpmu.hdrm_pmu.hhwmon_pmu.hpmus.htool_pmu.htp_pmu.hutil/pmu-bison.hutil/pmu-flex.hparse-events.hprint-events.hhashmap.hheader.h
Detected Declarations
struct perf_pmu_aliasstruct update_alias_datastruct find_event_argsenum event_sourcefunction perf_pmu_format__set_valuefunction __perf_pmu_format__loadfunction perf_pmu_format__loadfunction perf_pmu__format_parsefunction pmu_formatfunction parse_doublefunction perf_pmu__convert_scalefunction perf_pmu__parse_scalefunction perf_pmu__parse_unitfunction perf_pmu__parse_event_source_boolfunction perf_pmu__parse_per_pkgfunction perf_pmu__parse_snapshotfunction perf_pmu_free_aliasfunction perf_pmu__del_aliasesfunction assign_strfunction read_alias_infofunction update_aliasfunction perf_pmu__new_aliasfunction pmu_alias_info_filefunction __pmu_aliases_parsefunction pmu_aliases_parsefunction pmu_aliases_parse_eagerfunction pmu_alias_termsfunction pmu_is_uncorefunction is_sysfs_pmu_corefunction pmu_deduped_name_lenfunction perf_pmu__match_wildcardfunction perf_pmu__match_ignoring_suffix_uncorefunction perf_pmu__match_wildcard_uncorefunction pmu_uncore_identifier_matchfunction pmu_add_cpu_aliases_map_callbackfunction pmu_add_cpu_aliases_tablefunction pmu_add_cpu_aliasesfunction pmu_add_sys_aliases_iter_fnfunction pmu_add_sys_aliasesfunction pmu_max_precisefunction perf_pmu__arch_initfunction aliases__hashfunction aliases__equalfunction perf_pmu__initfunction wellknown_pmu_typefunction assignedfunction perf_pmu__is_fakefunction perf_pmu__warn_invalid_formats
Annotated Snippet
struct perf_pmu_alias {
/** @name: Name of the event like "mem-loads". */
char *name;
/** @desc: Optional short description of the event. */
char *desc;
/** @long_desc: Optional long description. */
char *long_desc;
/**
* @topic: Optional topic such as cache or pipeline, particularly for
* json events.
*/
char *topic;
/** @terms: Owned copy of the event terms. */
char *terms;
/**
* @legacy_terms: If the event aliases a legacy event, holds a copy
* ofthe legacy event string.
*/
char *legacy_terms;
/**
* @pmu_name: The name copied from the json struct pmu_event. This can
* differ from the PMU name as it won't have suffixes.
*/
char *pmu_name;
/** @unit: Units for the event, such as bytes or cache lines. */
char unit[UNIT_MAX_LEN+1];
/** @scale: Value to scale read counter values by. */
double scale;
/** @retirement_latency_mean: Value to be given for unsampled retirement latency mean. */
double retirement_latency_mean;
/** @retirement_latency_min: Value to be given for unsampled retirement latency min. */
double retirement_latency_min;
/** @retirement_latency_max: Value to be given for unsampled retirement latency max. */
double retirement_latency_max;
/**
* @per_pkg: Does the file
* <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.per-pkg or
* equivalent json value exist and have the value 1.
*/
bool per_pkg;
/**
* @snapshot: Does the file
* <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.snapshot
* exist and have the value 1.
*/
bool snapshot;
/**
* @deprecated: Is the event hidden and so not shown in perf list by
* default.
*/
bool deprecated;
/**
* @legacy_deprecated_checked: Legacy events may not be supported by the
* PMU need to be checked. If they aren't supported they are marked
* deprecated.
*/
bool legacy_deprecated_checked;
/** @from_sysfs: Was the alias from sysfs or a json event? */
bool from_sysfs;
/** @info_loaded: Have the scale, unit and other values been read from disk? */
bool info_loaded;
};
static int pmu_aliases_parse(struct perf_pmu *pmu);
static struct perf_pmu_format *perf_pmu__new_format(struct list_head *list, char *name)
{
struct perf_pmu_format *format;
format = zalloc(sizeof(*format));
if (!format)
return NULL;
format->name = strdup(name);
if (!format->name) {
free(format);
return NULL;
}
list_add_tail(&format->list, list);
return format;
}
/* Called at the end of parsing a format. */
void perf_pmu_format__set_value(void *vformat, int config, unsigned long *bits)
{
struct perf_pmu_format *format = vformat;
format->value = config;
memcpy(format->bits, bits, sizeof(format->bits));
}
Annotation
- Immediate include surface: `linux/list.h`, `linux/compiler.h`, `linux/string.h`, `linux/zalloc.h`, `linux/ctype.h`, `sys/types.h`, `fcntl.h`, `sys/stat.h`.
- Detected declarations: `struct perf_pmu_alias`, `struct update_alias_data`, `struct find_event_args`, `enum event_source`, `function perf_pmu_format__set_value`, `function __perf_pmu_format__load`, `function perf_pmu_format__load`, `function perf_pmu__format_parse`, `function pmu_format`, `function parse_double`.
- 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.