tools/perf/arch/x86/util/evsel.c
Source file repositories/reference/linux-study-clean/tools/perf/arch/x86/util/evsel.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/arch/x86/util/evsel.c- Extension
.c- Size
- 6515 bytes
- Lines
- 230
- 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.hutil/evlist.hutil/evsel.hutil/evsel_config.hutil/env.hutil/pmu.hutil/pmus.hutil/stat.hutil/strbuf.hlinux/string.htopdown.hevsel.hutil/debug.henv.h
Detected Declarations
function arch_evsel__set_sample_weightfunction evsel__sys_has_perf_metricsfunction arch_evsel__must_be_in_groupfunction arch_evsel__hw_namefunction arch_evsel__apply_ratio_to_prevfunction ibs_l3miss_warnfunction arch__post_evsel_configfunction amd_evsel__open_strerrorfunction intel_evsel__open_strerrorfunction evlist__for_each_entryfunction arch_evsel__open_strerror
Annotated Snippet
if (attr->config & IBS_FETCH_L3MISSONLY) {
ibs_l3miss_warn();
warned_once = 1;
}
} else if (ibs_op_pmu && ibs_op_pmu->type == evsel_pmu->type) {
if (attr->config & IBS_OP_L3MISSONLY) {
ibs_l3miss_warn();
warned_once = 1;
}
}
}
static int amd_evsel__open_strerror(struct evsel *evsel, char *msg, size_t size)
{
struct perf_pmu *pmu;
if (evsel->core.attr.precise_ip == 0)
return 0;
pmu = evsel__find_pmu(evsel);
if (!pmu || strncmp(pmu->name, "ibs", 3))
return 0;
/* More verbose IBS errors. */
if (evsel->core.attr.exclude_kernel || evsel->core.attr.exclude_user ||
evsel->core.attr.exclude_hv || evsel->core.attr.exclude_idle ||
evsel->core.attr.exclude_host || evsel->core.attr.exclude_guest) {
return scnprintf(msg, size, "AMD IBS doesn't support privilege filtering. Try "
"again without the privilege modifiers (like 'k') at the end.");
}
return 0;
}
static int intel_evsel__open_strerror(struct evsel *evsel, int err, char *msg, size_t size)
{
struct strbuf sb = STRBUF_INIT;
int ret;
if (err != EINVAL)
return 0;
if (!topdown_sys_has_perf_metrics())
return 0;
if (arch_is_topdown_slots(evsel)) {
if (!evsel__is_group_leader(evsel)) {
evlist__uniquify_evsel_names(evsel->evlist, &stat_config);
evlist__format_evsels(evsel->evlist, &sb, 2048);
ret = scnprintf(msg, size, "Topdown slots event can only be group leader "
"in '%s'.", sb.buf);
strbuf_release(&sb);
return ret;
}
} else if (arch_is_topdown_metrics(evsel)) {
struct evsel *pos;
evlist__for_each_entry(evsel->evlist, pos) {
if (pos == evsel || !arch_is_topdown_metrics(pos))
continue;
if (pos->core.attr.config != evsel->core.attr.config)
continue;
evlist__uniquify_evsel_names(evsel->evlist, &stat_config);
evlist__format_evsels(evsel->evlist, &sb, 2048);
ret = scnprintf(msg, size, "Perf metric event '%s' is duplicated "
"in the same group (only one event is allowed) in '%s'.",
evsel__name(evsel), sb.buf);
strbuf_release(&sb);
return ret;
}
}
return 0;
}
int arch_evsel__open_strerror(struct evsel *evsel, int err, char *msg, size_t size)
{
return x86__is_amd_cpu()
? amd_evsel__open_strerror(evsel, msg, size)
: intel_evsel__open_strerror(evsel, err, msg, size);
}
Annotation
- Immediate include surface: `errno.h`, `stdio.h`, `stdlib.h`, `util/evlist.h`, `util/evsel.h`, `util/evsel_config.h`, `util/env.h`, `util/pmu.h`.
- Detected declarations: `function arch_evsel__set_sample_weight`, `function evsel__sys_has_perf_metrics`, `function arch_evsel__must_be_in_group`, `function arch_evsel__hw_name`, `function arch_evsel__apply_ratio_to_prev`, `function ibs_l3miss_warn`, `function arch__post_evsel_config`, `function amd_evsel__open_strerror`, `function intel_evsel__open_strerror`, `function evlist__for_each_entry`.
- 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.