tools/perf/util/drm_pmu.c
Source file repositories/reference/linux-study-clean/tools/perf/util/drm_pmu.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/drm_pmu.c- Extension
.c- Size
- 16350 bytes
- Lines
- 686
- 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
drm_pmu.hcounts.hcpumap.hdebug.hevsel.hpmu.hperf/threadmap.hapi/fs/fs.hapi/io.hctype.hdirent.herrno.hfcntl.hunistd.hlinux/unistd.hlinux/kcmp.hlinux/string.hlinux/zalloc.hsys/stat.hsys/syscall.hsys/sysmacros.hsys/types.h
Detected Declarations
struct drm_pmu_eventstruct drm_pmustruct minor_infostruct read_drm_event_cb_argsenum drm_pmu_unitfunction perf_pmu__is_drmfunction evsel__is_drmfunction list_for_each_entryfunction add_eventfunction read_drm_pmus_cbfunction drm_pmu__exitfunction drm_pmu__have_eventfunction drm_pmu__for_each_eventfunction drm_pmu__num_eventsfunction drm_pmu__index_for_eventfunction drm_pmu__config_termfunction drm_pmu__config_termsfunction list_for_each_entryfunction drm_pmu__check_aliasfunction for_each_drm_fdinfo_in_dirfunction for_each_drm_fdinfofunction perf_pmus__read_drm_pmusfunction evsel__drm_pmu_openfunction read_count_and_apply_unitfunction read_drm_eventfunction read_drm_event_cbfunction drm_pmu__read_system_widefunction drm_pmu__read_for_pidfunction evsel__drm_pmu_read
Annotated Snippet
struct drm_pmu_event {
const char *name;
const char *desc;
enum drm_pmu_unit unit;
};
struct drm_pmu {
struct perf_pmu pmu;
struct drm_pmu_event *events;
int num_events;
};
static const char * const drm_pmu_unit_strs[DRM_PMU_UNIT_MAX] = {
"bytes",
"capacity",
"cycles",
"hz",
"ns",
};
static const char * const drm_pmu_scale_unit_strs[DRM_PMU_UNIT_MAX] = {
"1bytes",
"1capacity",
"1cycles",
"1hz",
"1ns",
};
bool perf_pmu__is_drm(const struct perf_pmu *pmu)
{
return pmu && pmu->type >= PERF_PMU_TYPE_DRM_START &&
pmu->type <= PERF_PMU_TYPE_DRM_END;
}
bool evsel__is_drm(const struct evsel *evsel)
{
return perf_pmu__is_drm(evsel->pmu);
}
static struct drm_pmu *add_drm_pmu(struct list_head *pmus, char *line, size_t line_len)
{
struct drm_pmu *drm;
struct perf_pmu *pmu;
const char *name;
__u32 max_drm_pmu_type = 0, type;
int i = 12;
if (line[line_len - 1] == '\n')
line[line_len - 1] = '\0';
while (isspace(line[i]))
i++;
line[--i] = '_';
line[--i] = 'm';
line[--i] = 'r';
line[--i] = 'd';
name = &line[i];
list_for_each_entry(pmu, pmus, list) {
if (!perf_pmu__is_drm(pmu))
continue;
if (pmu->type > max_drm_pmu_type)
max_drm_pmu_type = pmu->type;
if (!strcmp(pmu->name, name)) {
/* PMU already exists. */
return NULL;
}
}
if (max_drm_pmu_type != 0)
type = max_drm_pmu_type + 1;
else
type = PERF_PMU_TYPE_DRM_START;
if (type > PERF_PMU_TYPE_DRM_END) {
zfree(&drm);
pr_err("Unable to encode DRM PMU type for %s\n", name);
return NULL;
}
drm = zalloc(sizeof(*drm));
if (!drm)
return NULL;
if (perf_pmu__init(&drm->pmu, type, name) != 0) {
perf_pmu__delete(&drm->pmu);
return NULL;
}
drm->pmu.cpus = perf_cpu_map__new_int(0);
Annotation
- Immediate include surface: `drm_pmu.h`, `counts.h`, `cpumap.h`, `debug.h`, `evsel.h`, `pmu.h`, `perf/threadmap.h`, `api/fs/fs.h`.
- Detected declarations: `struct drm_pmu_event`, `struct drm_pmu`, `struct minor_info`, `struct read_drm_event_cb_args`, `enum drm_pmu_unit`, `function perf_pmu__is_drm`, `function evsel__is_drm`, `function list_for_each_entry`, `function add_event`, `function read_drm_pmus_cb`.
- 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.