Lines Matching defs:pmu
17 #include "pmu.h"
26 * must have pmu->is_core=1. If there are more than one PMU in
36 * must have pmu->is_core=0 but pmu->is_uncore could be 0 or 1.
93 struct perf_pmu *pmu, *tmp;
95 list_for_each_entry_safe(pmu, tmp, &core_pmus, list) {
96 list_del(&pmu->list);
98 perf_pmu__delete(pmu);
100 list_for_each_entry_safe(pmu, tmp, &other_pmus, list) {
101 list_del(&pmu->list);
103 perf_pmu__delete(pmu);
111 struct perf_pmu *pmu;
113 list_for_each_entry(pmu, &core_pmus, list) {
114 if (!strcmp(pmu->name, name) ||
115 (pmu->alias_name && !strcmp(pmu->alias_name, name)))
116 return pmu;
118 list_for_each_entry(pmu, &other_pmus, list) {
119 if (!strcmp(pmu->name, name) ||
120 (pmu->alias_name && !strcmp(pmu->alias_name, name)))
121 return pmu;
129 struct perf_pmu *pmu;
136 * the pmu format definitions.
138 pmu = pmu_find(name);
139 if (pmu)
140 return pmu;
150 pmu = perf_pmu__lookup(core_pmu ? &core_pmus : &other_pmus, dirfd, name,
154 if (!pmu) {
160 pmu = pmu_find(name);
162 return pmu;
167 struct perf_pmu *pmu;
173 * the pmu format definitions.
175 pmu = pmu_find(name);
176 if (pmu)
177 return pmu;
199 /* Add all pmus in sysfs to pmu list: */
250 struct perf_pmu *pmu;
252 list_for_each_entry(pmu, &core_pmus, list) {
253 if (pmu->type == type)
254 return pmu;
257 list_for_each_entry(pmu, &other_pmus, list) {
258 if (pmu->type == type)
259 return pmu;
266 struct perf_pmu *pmu = __perf_pmus__find_by_type(type);
268 if (pmu || read_sysfs_all_pmus)
269 return pmu;
272 pmu = __perf_pmus__find_by_type(type);
273 return pmu;
277 * pmu iterator: If pmu is NULL, we start at the begin, otherwise return the
278 * next pmu. Returns NULL on end.
280 struct perf_pmu *perf_pmus__scan(struct perf_pmu *pmu)
282 bool use_core_pmus = !pmu || pmu->is_core;
284 if (!pmu) {
286 pmu = list_prepare_entry(pmu, &core_pmus, list);
289 list_for_each_entry_continue(pmu, &core_pmus, list)
290 return pmu;
292 pmu = NULL;
293 pmu = list_prepare_entry(pmu, &other_pmus, list);
295 list_for_each_entry_continue(pmu, &other_pmus, list)
296 return pmu;
300 struct perf_pmu *perf_pmus__scan_core(struct perf_pmu *pmu)
302 if (!pmu) {
304 return list_first_entry_or_null(&core_pmus, typeof(*pmu), list);
306 list_for_each_entry_continue(pmu, &core_pmus, list)
307 return pmu;
312 static struct perf_pmu *perf_pmus__scan_skip_duplicates(struct perf_pmu *pmu)
314 bool use_core_pmus = !pmu || pmu->is_core;
316 const char *last_pmu_name = (pmu && pmu->name) ? pmu->name : "";
318 if (!pmu) {
320 pmu = list_prepare_entry(pmu, &core_pmus, list);
322 last_pmu_name_len = pmu_name_len_no_suffix(pmu->name ?: "");
325 list_for_each_entry_continue(pmu, &core_pmus, list) {
326 int pmu_name_len = pmu_name_len_no_suffix(pmu->name ?: "");
329 !strncmp(last_pmu_name, pmu->name ?: "", pmu_name_len))
332 return pmu;
334 pmu = NULL;
335 pmu = list_prepare_entry(pmu, &other_pmus, list);
337 list_for_each_entry_continue(pmu, &other_pmus, list) {
338 int pmu_name_len = pmu_name_len_no_suffix(pmu->name ?: "");
341 !strncmp(last_pmu_name, pmu->name ?: "", pmu_name_len))
344 return pmu;
351 struct perf_pmu *pmu = NULL;
353 while ((pmu = perf_pmus__scan(pmu)) != NULL) {
354 if (!strcmp(pmu->name, str))
355 return pmu;
357 if (!strncmp(pmu->name, "uncore_", 7)) {
358 if (!strcmp(pmu->name + 7, str))
359 return pmu;
362 if (!strncmp(pmu->name, "cpu_", 4)) {
363 if (!strcmp(pmu->name + 4, str))
364 return pmu;
373 const struct perf_pmu *pmu;
403 a_iscpu = as->pmu ? as->pmu->is_core : true;
404 b_iscpu = bs->pmu ? bs->pmu->is_core : true;
409 if (as->pmu != bs->pmu) {
442 pr_err("Unexpected event %s/%s/\n", info->pmu->name, info->name);
445 assert(info->pmu != NULL || info->name != NULL);
447 s->pmu = info->pmu;
466 struct perf_pmu *pmu;
479 pmu = NULL;
481 while ((pmu = scan_fn(pmu)) != NULL)
482 len += perf_pmu__num_events(pmu);
489 pmu = NULL;
495 while ((pmu = scan_fn(pmu)) != NULL) {
496 perf_pmu__for_each_event(pmu, skip_duplicate_pmus, &state,
580 struct perf_pmu *pmu = NULL;
587 while ((pmu = scan_fn(pmu)) != NULL) {
593 int len = pmu_name_len_no_suffix(pmu->name);
596 if (!pmu->is_core)
599 strbuf_addf(&format_args.short_string, "%.*s/", len, pmu->name);
600 strbuf_addf(&format_args.long_string, "%.*s/", len, pmu->name);
601 perf_pmu__for_each_format(pmu, &format_args, build_format_string);
628 struct perf_pmu *pmu = perf_pmus__find(pname);
630 return pmu && perf_pmu__have_event(pmu, name);
638 struct perf_pmu *pmu = NULL;
640 while ((pmu = perf_pmus__scan_core(pmu)) != NULL)
648 struct perf_pmu *pmu = NULL;
653 while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
654 if (!is_event_supported(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES | ((__u64)pmu->type << PERF_PMU_TYPE_SHIFT)))
712 struct perf_pmu *pmu = evsel->pmu;
714 if (!pmu) {
715 pmu = perf_pmus__find_by_type(evsel->core.attr.type);
716 ((struct evsel *)evsel)->pmu = pmu;
718 return pmu;