• Home
  • Raw
  • Download

Lines Matching +full:long +full:- +full:term

1 // SPDX-License-Identifier: GPL-2.0
22 #include <util/pmu-bison.h>
23 #include <util/pmu-flex.h>
24 #include "parse-events.h"
25 #include "print-events.h"
52 * struct perf_pmu_alias - An event either read from sysfs or builtin in
53 * pmu-events.c, created by parsing the pmu-events json files.
56 /** @name: Name of the event like "mem-loads". */
60 /** @long_desc: Optional long description. */
82 * <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.per-pkg or
104 * struct perf_pmu_format - Values from a format file read from
108 * "config:0-7" and will be represented here as name="event",
138 format->name = strdup(name); in perf_pmu__new_format()
139 if (!format->name) { in perf_pmu__new_format()
143 list_add_tail(&format->list, list); in perf_pmu__new_format()
148 void perf_pmu_format__set_value(void *vformat, int config, unsigned long *bits) in perf_pmu_format__set_value()
152 format->value = config; in perf_pmu_format__set_value()
153 memcpy(format->bits, bits, sizeof(format->bits)); in perf_pmu_format__set_value()
168 format->loaded = true; in __perf_pmu_format__load()
176 if (format->loaded) in perf_pmu_format__load()
179 if (!perf_pmu__pathname_scnprintf(path, sizeof(path), pmu->name, "format")) in perf_pmu_format__load()
182 assert(strlen(path) + strlen(format->name) + 2 < sizeof(path)); in perf_pmu_format__load()
184 strcat(path, format->name); in perf_pmu_format__load()
205 return -EINVAL; in perf_pmu__format_parse()
209 char *name = evt_ent->d_name; in perf_pmu__format_parse()
214 format = perf_pmu__new_format(&pmu->format, name); in perf_pmu__format_parse()
216 ret = -ENOMEM; in perf_pmu__format_parse()
225 ret = -errno; in perf_pmu__format_parse()
257 return -1; in pmu_format()
279 ret = -ENOMEM; in perf_pmu__convert_scale()
305 int fd, ret = -1; in perf_pmu__parse_scale()
311 scnprintf(path + len, sizeof(path) - len, "%s/events/%s.scale", pmu->name, alias->name); in perf_pmu__parse_scale()
314 if (fd == -1) in perf_pmu__parse_scale()
315 return -1; in perf_pmu__parse_scale()
320 sret = read(fd, scale, sizeof(scale)-1); in perf_pmu__parse_scale()
324 if (scale[sret - 1] == '\n') in perf_pmu__parse_scale()
325 scale[sret - 1] = '\0'; in perf_pmu__parse_scale()
329 ret = perf_pmu__convert_scale(scale, NULL, &alias->scale); in perf_pmu__parse_scale()
346 scnprintf(path + len, sizeof(path) - len, "%s/events/%s.unit", pmu->name, alias->name); in perf_pmu__parse_unit()
349 if (fd == -1) in perf_pmu__parse_unit()
350 return -1; in perf_pmu__parse_unit()
352 sret = read(fd, alias->unit, UNIT_MAX_LEN); in perf_pmu__parse_unit()
358 if (alias->unit[sret - 1] == '\n') in perf_pmu__parse_unit()
359 alias->unit[sret - 1] = '\0'; in perf_pmu__parse_unit()
361 alias->unit[sret] = '\0'; in perf_pmu__parse_unit()
366 alias->unit[0] = '\0'; in perf_pmu__parse_unit()
367 return -1; in perf_pmu__parse_unit()
380 scnprintf(path + len, sizeof(path) - len, "%s/events/%s.per-pkg", pmu->name, alias->name); in perf_pmu__parse_per_pkg()
383 if (fd == -1) in perf_pmu__parse_per_pkg()
384 return -1; in perf_pmu__parse_per_pkg()
388 alias->per_pkg = true; in perf_pmu__parse_per_pkg()
401 scnprintf(path + len, sizeof(path) - len, "%s/events/%s.snapshot", pmu->name, alias->name); in perf_pmu__parse_snapshot()
404 if (fd == -1) in perf_pmu__parse_snapshot()
405 return -1; in perf_pmu__parse_snapshot()
407 alias->snapshot = true; in perf_pmu__parse_snapshot()
415 zfree(&newalias->name); in perf_pmu_free_alias()
416 zfree(&newalias->desc); in perf_pmu_free_alias()
417 zfree(&newalias->long_desc); in perf_pmu_free_alias()
418 zfree(&newalias->topic); in perf_pmu_free_alias()
419 zfree(&newalias->pmu_name); in perf_pmu_free_alias()
420 parse_events_terms__purge(&newalias->terms); in perf_pmu_free_alias()
428 list_for_each_entry_safe(alias, tmp, &pmu->aliases, list) { in perf_pmu__del_aliases()
429 list_del(&alias->list); in perf_pmu__del_aliases()
440 if (load && !pmu->sysfs_aliases_loaded) { in perf_pmu__find_alias()
464 list_for_each_entry(alias, &pmu->aliases, list) { in perf_pmu__find_alias()
465 if (!strcasecmp(alias->name, name)) in perf_pmu__find_alias()
491 if (!alias->from_sysfs || alias->info_loaded) in read_alias_info()
515 read_alias_info(data->pmu, data->alias); in update_alias()
516 assign_str(pe->name, "desc", &data->alias->desc, pe->desc); in update_alias()
517 assign_str(pe->name, "long_desc", &data->alias->long_desc, pe->long_desc); in update_alias()
518 assign_str(pe->name, "topic", &data->alias->topic, pe->topic); in update_alias()
519 data->alias->per_pkg = pe->perpkg; in update_alias()
520 if (pe->event) { in update_alias()
521 parse_events_terms__purge(&data->alias->terms); in update_alias()
522 ret = parse_events_terms(&data->alias->terms, pe->event, /*input=*/NULL); in update_alias()
524 if (!ret && pe->unit) { in update_alias()
527 ret = perf_pmu__convert_scale(pe->unit, &unit, &data->alias->scale); in update_alias()
529 snprintf(data->alias->unit, sizeof(data->alias->unit), "%s", unit); in update_alias()
549 long_desc = pe->long_desc; in perf_pmu__new_alias()
550 topic = pe->topic; in perf_pmu__new_alias()
551 unit = pe->unit; in perf_pmu__new_alias()
552 perpkg = pe->perpkg; in perf_pmu__new_alias()
553 deprecated = pe->deprecated; in perf_pmu__new_alias()
554 pmu_name = pe->pmu; in perf_pmu__new_alias()
559 return -ENOMEM; in perf_pmu__new_alias()
561 INIT_LIST_HEAD(&alias->terms); in perf_pmu__new_alias()
562 alias->scale = 1.0; in perf_pmu__new_alias()
563 alias->unit[0] = '\0'; in perf_pmu__new_alias()
564 alias->per_pkg = perpkg; in perf_pmu__new_alias()
565 alias->snapshot = false; in perf_pmu__new_alias()
566 alias->deprecated = deprecated; in perf_pmu__new_alias()
568 ret = parse_events_terms(&alias->terms, val, val_fd); in perf_pmu__new_alias()
575 alias->name = strdup(name); in perf_pmu__new_alias()
576 alias->desc = desc ? strdup(desc) : NULL; in perf_pmu__new_alias()
577 alias->long_desc = long_desc ? strdup(long_desc) : in perf_pmu__new_alias()
579 alias->topic = topic ? strdup(topic) : NULL; in perf_pmu__new_alias()
580 alias->pmu_name = pmu_name ? strdup(pmu_name) : NULL; in perf_pmu__new_alias()
582 if (perf_pmu__convert_scale(unit, (char **)&unit, &alias->scale) < 0) { in perf_pmu__new_alias()
584 return -1; in perf_pmu__new_alias()
586 snprintf(alias->unit, sizeof(alias->unit), "%s", unit); in perf_pmu__new_alias()
591 alias->from_sysfs = true; in perf_pmu__new_alias()
592 if (pmu->events_table) { in perf_pmu__new_alias()
598 if (pmu_events_table__find_event(pmu->events_table, pmu, name, in perf_pmu__new_alias()
600 pmu->cpu_common_json_aliases++; in perf_pmu__new_alias()
602 pmu->sysfs_aliases++; in perf_pmu__new_alias()
605 pmu->cpu_json_aliases++; in perf_pmu__new_alias()
608 pmu->sys_json_aliases++; in perf_pmu__new_alias()
612 list_add_tail(&alias->list, &pmu->aliases); in perf_pmu__new_alias()
621 if (len > 5 && !strcmp(name + len - 5, ".unit")) in pmu_alias_info_file()
623 if (len > 6 && !strcmp(name + len - 6, ".scale")) in pmu_alias_info_file()
625 if (len > 8 && !strcmp(name + len - 8, ".per-pkg")) in pmu_alias_info_file()
627 if (len > 9 && !strcmp(name + len - 9, ".snapshot")) in pmu_alias_info_file()
648 scnprintf(path + len, sizeof(path) - len, "%s/events", pmu->name); in pmu_aliases_parse()
651 if (dir_fd == -1) { in pmu_aliases_parse()
652 pmu->sysfs_aliases_loaded = true; in pmu_aliases_parse()
659 return -EINVAL; in pmu_aliases_parse()
663 char *name = evt_ent->d_name; in pmu_aliases_parse()
676 if (fd == -1) { in pmu_aliases_parse()
695 pmu->sysfs_aliases_loaded = true; in pmu_aliases_parse()
702 struct parse_events_term *term, *cloned; in pmu_alias_terms() local
706 list_for_each_entry(term, &alias->terms, list) { in pmu_alias_terms()
707 ret = parse_events_term__clone(&cloned, term); in pmu_alias_terms()
716 cloned->weak = true; in pmu_alias_terms()
717 list_add_tail(&cloned->list, &list); in pmu_alias_terms()
777 str[len - 1] = 0; /* remove line feed */ in pmu_id()
783 * is_sysfs_pmu_core() - PMU CORE devices have different name other than cpu in
829 * perf_pmu__match_ignoring_suffix - Does the pmu_name match tok ignoring any
861 * pmu_uncore_alias_match - does name match the PMU name?
889 * Match more complex aliases where the alias name is a comma-delimited in pmu_uncore_alias_match()
945 perf_pmu__new_alias(pmu, pe->name, pe->desc, pe->event, /*val_fd=*/ NULL, in pmu_add_cpu_aliases_map_callback()
961 if (!pmu->events_table) in pmu_add_cpu_aliases()
964 if (pmu->cpu_aliases_added) in pmu_add_cpu_aliases()
967 pmu_add_cpu_aliases_table(pmu, pmu->events_table); in pmu_add_cpu_aliases()
968 pmu->cpu_aliases_added = true; in pmu_add_cpu_aliases()
977 if (!pe->compat || !pe->pmu) in pmu_add_sys_aliases_iter_fn()
980 if (pmu_uncore_alias_match(pe->pmu, pmu->name) && in pmu_add_sys_aliases_iter_fn()
981 pmu_uncore_identifier_match(pe->compat, pmu->id)) { in pmu_add_sys_aliases_iter_fn()
983 pe->name, in pmu_add_sys_aliases_iter_fn()
984 pe->desc, in pmu_add_sys_aliases_iter_fn()
985 pe->event, in pmu_add_sys_aliases_iter_fn()
996 if (!pmu->id) in pmu_add_sys_aliases()
1022 int max_precise = -1; in pmu_max_precise()
1039 pmu->name = strdup(name); in perf_pmu__lookup()
1040 if (!pmu->name) in perf_pmu__lookup()
1050 INIT_LIST_HEAD(&pmu->format); in perf_pmu__lookup()
1051 INIT_LIST_HEAD(&pmu->aliases); in perf_pmu__lookup()
1052 INIT_LIST_HEAD(&pmu->caps); in perf_pmu__lookup()
1062 pmu->is_core = is_pmu_core(name); in perf_pmu__lookup()
1063 pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core); in perf_pmu__lookup()
1067 pmu->alias_name = strdup(alias_name); in perf_pmu__lookup()
1068 if (!pmu->alias_name) in perf_pmu__lookup()
1072 pmu->type = type; in perf_pmu__lookup()
1073 pmu->is_uncore = pmu_is_uncore(dirfd, name); in perf_pmu__lookup()
1074 if (pmu->is_uncore) in perf_pmu__lookup()
1075 pmu->id = pmu_id(name); in perf_pmu__lookup()
1076 pmu->max_precise = pmu_max_precise(dirfd, pmu); in perf_pmu__lookup()
1077 pmu->events_table = perf_pmu__find_events_table(pmu); in perf_pmu__lookup()
1085 list_add_tail(&pmu->list, pmus); in perf_pmu__lookup()
1087 pmu->default_config = perf_pmu__get_default_config(pmu); in perf_pmu__lookup()
1091 zfree(&pmu->name); in perf_pmu__lookup()
1104 pmu->name = strdup("cpu"); in perf_pmu__create_placeholder_core_pmu()
1105 if (!pmu->name) { in perf_pmu__create_placeholder_core_pmu()
1110 pmu->is_core = true; in perf_pmu__create_placeholder_core_pmu()
1111 pmu->type = PERF_TYPE_RAW; in perf_pmu__create_placeholder_core_pmu()
1112 pmu->cpus = cpu_map__online(); in perf_pmu__create_placeholder_core_pmu()
1114 INIT_LIST_HEAD(&pmu->format); in perf_pmu__create_placeholder_core_pmu()
1115 INIT_LIST_HEAD(&pmu->aliases); in perf_pmu__create_placeholder_core_pmu()
1116 INIT_LIST_HEAD(&pmu->caps); in perf_pmu__create_placeholder_core_pmu()
1117 list_add_tail(&pmu->list, core_pmus); in perf_pmu__create_placeholder_core_pmu()
1125 if (pmu->formats_checked) in perf_pmu__warn_invalid_formats()
1128 pmu->formats_checked = true; in perf_pmu__warn_invalid_formats()
1134 list_for_each_entry(format, &pmu->format, list) { in perf_pmu__warn_invalid_formats()
1136 if (format->value >= PERF_PMU_FORMAT_VALUE_CONFIG_END) { in perf_pmu__warn_invalid_formats()
1139 pmu->name, format->name, format->value); in perf_pmu__warn_invalid_formats()
1149 return pmu && pmu->auxtrace; in evsel__is_aux_event()
1153 * Set @config_name to @val as long as the user hasn't already set or cleared it
1154 * by passing a config term on the command line.
1160 #define field_prep(_mask, _val) (((_val) << (ffsll(_mask) - 1)) & (_mask))
1165 struct evsel_config_term *term = evsel__get_config_term(evsel, CFG_CHG); in evsel__set_config_if_unset() local
1167 if (term) in evsel__set_config_if_unset()
1168 user_bits = term->val.cfg_chg; in evsel__set_config_if_unset()
1177 evsel->core.attr.config &= ~bits; in evsel__set_config_if_unset()
1178 evsel->core.attr.config |= field_prep(bits, val); in evsel__set_config_if_unset()
1187 if (!strcmp(format->name, name)) in pmu_find_format()
1195 struct perf_pmu_format *format = pmu_find_format(&pmu->format, name); in perf_pmu__format_bits()
1202 for_each_set_bit(fbit, format->bits, PERF_PMU_FORMAT_BITS) in perf_pmu__format_bits()
1210 struct perf_pmu_format *format = pmu_find_format(&pmu->format, name); in perf_pmu__format_type()
1213 return -1; in perf_pmu__format_type()
1216 return format->value; in perf_pmu__format_type()
1223 static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v, in pmu_format_value()
1226 unsigned long fbit, vbit; in pmu_format_value()
1240 static __u64 pmu_format_max_value(const unsigned long *format) in pmu_format_max_value()
1248 return (1ULL << w) - 1; in pmu_format_max_value()
1249 return -1; in pmu_format_max_value()
1253 * Term is a string term, and might be a param-term. Try to look up it's value
1255 * - We have a term like "base-or-format-term=param-term",
1256 * - We need to find the value supplied for "param-term" (with param-term named
1257 * in a config string) later on in the term list.
1259 static int pmu_resolve_param_term(struct parse_events_term *term, in pmu_resolve_param_term() argument
1266 if (t->type_val == PARSE_EVENTS__TERM_TYPE_NUM && in pmu_resolve_param_term()
1267 t->config && !strcmp(t->config, term->config)) { in pmu_resolve_param_term()
1268 t->used = true; in pmu_resolve_param_term()
1269 *value = t->val.num; in pmu_resolve_param_term()
1275 printf("Required parameter '%s' not specified\n", term->config); in pmu_resolve_param_term()
1277 return -1; in pmu_resolve_param_term()
1292 if (strbuf_addf(&buf, i++ ? ",%s" : "%s", format->name) < 0) in pmu_formats_string()
1304 * user input data - term parameter.
1308 struct parse_events_term *term, in pmu_config_term() argument
1317 * If this is a parameter we've already used for parameterized-eval, in pmu_config_term()
1320 if (term->used) in pmu_config_term()
1327 if (parse_events__is_hardcoded_term(term)) in pmu_config_term()
1330 format = pmu_find_format(&pmu->format, term->config); in pmu_config_term()
1332 char *pmu_term = pmu_formats_string(&pmu->format); in pmu_config_term()
1337 "unknown term '%s' for pmu '%s'", in pmu_config_term()
1338 term->config, pmu->name) < 0) in pmu_config_term()
1342 parse_events_error__handle(err, term->err_term, in pmu_config_term()
1350 return -EINVAL; in pmu_config_term()
1353 switch (format->value) { in pmu_config_term()
1355 vp = &attr->config; in pmu_config_term()
1358 vp = &attr->config1; in pmu_config_term()
1361 vp = &attr->config2; in pmu_config_term()
1364 vp = &attr->config3; in pmu_config_term()
1367 return -EINVAL; in pmu_config_term()
1371 * Either directly use a numeric term, or try to translate string terms in pmu_config_term()
1374 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) { in pmu_config_term()
1375 if (term->no_value && in pmu_config_term()
1376 bitmap_weight(format->bits, PERF_PMU_FORMAT_BITS) > 1) { in pmu_config_term()
1378 parse_events_error__handle(err, term->err_val, in pmu_config_term()
1379 strdup("no value assigned for term"), in pmu_config_term()
1382 return -EINVAL; in pmu_config_term()
1385 val = term->val.num; in pmu_config_term()
1386 } else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) { in pmu_config_term()
1387 if (strcmp(term->val.str, "?")) { in pmu_config_term()
1390 term->config, term->val.str); in pmu_config_term()
1393 parse_events_error__handle(err, term->err_val, in pmu_config_term()
1397 return -EINVAL; in pmu_config_term()
1400 if (pmu_resolve_param_term(term, head_terms, &val)) in pmu_config_term()
1401 return -EINVAL; in pmu_config_term()
1403 return -EINVAL; in pmu_config_term()
1405 max_val = pmu_format_max_value(format->bits); in pmu_config_term()
1410 parse_events_error__handle(err, term->err_val, in pmu_config_term()
1413 (unsigned long long)max_val) < 0 in pmu_config_term()
1417 return -EINVAL; in pmu_config_term()
1425 pmu_format_value(format->bits, val, vp, zero); in pmu_config_term()
1434 struct parse_events_term *term; in perf_pmu__config_terms() local
1436 list_for_each_entry(term, head_terms, list) { in perf_pmu__config_terms()
1437 if (pmu_config_term(pmu, attr, term, head_terms, zero, err)) in perf_pmu__config_terms()
1438 return -EINVAL; in perf_pmu__config_terms()
1446 * 1) users input - specified in terms parameter
1447 * 2) pmu format definitions - specified by pmu parameter
1453 bool zero = !!pmu->default_config; in perf_pmu__config()
1459 struct parse_events_term *term) in pmu_find_alias() argument
1464 if (parse_events__is_hardcoded_term(term)) in pmu_find_alias()
1467 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) { in pmu_find_alias()
1468 if (!term->no_value) in pmu_find_alias()
1470 if (pmu_find_format(&pmu->format, term->config)) in pmu_find_alias()
1472 name = term->config; in pmu_find_alias()
1474 } else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) { in pmu_find_alias()
1475 if (strcasecmp(term->config, "event")) in pmu_find_alias()
1477 name = term->val.str; in pmu_find_alias()
1483 if (alias || pmu->cpu_aliases_added) in pmu_find_alias()
1487 if (pmu->events_table && in pmu_find_alias()
1488 pmu_events_table__find_event(pmu->events_table, pmu, name, in pmu_find_alias()
1505 * Only one term in event definition can in check_info_data()
1509 if (info->unit && alias->unit[0]) { in check_info_data()
1513 return -EINVAL; in check_info_data()
1515 if (info->scale && alias->scale) { in check_info_data()
1519 return -EINVAL; in check_info_data()
1521 if (info->snapshot && alias->snapshot) { in check_info_data()
1525 return -EINVAL; in check_info_data()
1528 if (alias->unit[0]) in check_info_data()
1529 info->unit = alias->unit; in check_info_data()
1531 if (alias->scale) in check_info_data()
1532 info->scale = alias->scale; in check_info_data()
1534 if (alias->snapshot) in check_info_data()
1535 info->snapshot = alias->snapshot; in check_info_data()
1547 struct parse_events_term *term, *h; in perf_pmu__check_alias() local
1551 info->per_pkg = false; in perf_pmu__check_alias()
1557 info->unit = NULL; in perf_pmu__check_alias()
1558 info->scale = 0.0; in perf_pmu__check_alias()
1559 info->snapshot = false; in perf_pmu__check_alias()
1561 list_for_each_entry_safe(term, h, head_terms, list) { in perf_pmu__check_alias()
1562 alias = pmu_find_alias(pmu, term); in perf_pmu__check_alias()
1565 ret = pmu_alias_terms(alias, &term->list); in perf_pmu__check_alias()
1567 parse_events_error__handle(err, term->err_term, in perf_pmu__check_alias()
1573 ret = check_info_data(pmu, alias, info, err, term->err_term); in perf_pmu__check_alias()
1577 if (alias->per_pkg) in perf_pmu__check_alias()
1578 info->per_pkg = true; in perf_pmu__check_alias()
1580 list_del_init(&term->list); in perf_pmu__check_alias()
1581 parse_events_term__delete(term); in perf_pmu__check_alias()
1589 if (info->unit == NULL) in perf_pmu__check_alias()
1590 info->unit = ""; in perf_pmu__check_alias()
1592 if (info->scale == 0.0) in perf_pmu__check_alias()
1593 info->scale = 1.0; in perf_pmu__check_alias()
1608 if (!strcmp(args->event, info->name)) in find_event_callback()
1609 return args->cb(args->state, info); in find_event_callback()
1622 /* Sub-optimal, but function is only used by tests. */ in perf_pmu__find_event()
1632 list_del(&fmt->list); in perf_pmu__del_formats()
1633 zfree(&fmt->name); in perf_pmu__del_formats()
1642 list_for_each_entry(format, &pmu->format, list) { in perf_pmu__has_format()
1643 if (!strcmp(format->name, name)) in perf_pmu__has_format()
1656 return pmu->is_core; in perf_pmu__supports_legacy_cache()
1661 return !pmu->is_core || perf_pmus__num_core_pmus() == 1; in perf_pmu__auto_merge_stats()
1668 if (pmu->cpu_aliases_added || !pmu->events_table) in perf_pmu__have_event()
1670 return pmu_events_table__find_event(pmu->events_table, pmu, name, NULL, NULL) == 0; in perf_pmu__have_event()
1678 nr = pmu->sysfs_aliases + pmu->sys_json_aliases;; in perf_pmu__num_events()
1680 if (pmu->cpu_aliases_added) in perf_pmu__num_events()
1681 nr += pmu->cpu_json_aliases; in perf_pmu__num_events()
1682 else if (pmu->events_table) in perf_pmu__num_events()
1683 nr += pmu_events_table__num_events(pmu->events_table, pmu) - in perf_pmu__num_events()
1684 pmu->cpu_common_json_aliases; in perf_pmu__num_events()
1686 assert(pmu->cpu_json_aliases == 0 && pmu->cpu_common_json_aliases == 0); in perf_pmu__num_events()
1688 return pmu->selectable ? nr + 1 : nr; in perf_pmu__num_events()
1695 return a - b; in sub_non_neg()
1701 struct parse_events_term *term; in format_alias() local
1703 ? pmu_name_len_no_suffix(pmu->name, /*num=*/NULL) in format_alias()
1704 : (int)strlen(pmu->name); in format_alias()
1705 int used = snprintf(buf, len, "%.*s/%s", pmu_name_len, pmu->name, alias->name); in format_alias()
1707 list_for_each_entry(term, &alias->terms, list) { in format_alias()
1708 if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) in format_alias()
1710 ",%s=%s", term->config, in format_alias()
1711 term->val.str); in format_alias()
1722 buf[len - 1] = '\0'; in format_alias()
1741 list_for_each_entry(event, &pmu->aliases, list) { in perf_pmu__for_each_event()
1744 info.pmu_name = event->pmu_name ?: pmu->name; in perf_pmu__for_each_event()
1746 if (event->desc) { in perf_pmu__for_each_event()
1747 info.name = event->name; in perf_pmu__for_each_event()
1752 if (pmu->is_core) { in perf_pmu__for_each_event()
1754 info.name = event->name; in perf_pmu__for_each_event()
1759 if (strlen(event->unit) || event->scale != 1.0) { in perf_pmu__for_each_event()
1761 buf_used += snprintf(buf + buf_used, sizeof(buf) - buf_used, in perf_pmu__for_each_event()
1762 "%G%s", event->scale, event->unit) + 1; in perf_pmu__for_each_event()
1764 info.desc = event->desc; in perf_pmu__for_each_event()
1765 info.long_desc = event->long_desc; in perf_pmu__for_each_event()
1767 parse_events_term__to_strbuf(&event->terms, &sb); in perf_pmu__for_each_event()
1768 buf_used += snprintf(buf + buf_used, sizeof(buf) - buf_used, in perf_pmu__for_each_event()
1770 info.topic = event->topic; in perf_pmu__for_each_event()
1772 info.deprecated = event->deprecated; in perf_pmu__for_each_event()
1778 if (pmu->selectable) { in perf_pmu__for_each_event()
1780 snprintf(buf, sizeof(buf), "%s//", pmu->name); in perf_pmu__for_each_event()
1787 info.pmu_name = pmu->name; in perf_pmu__for_each_event()
1798 return !strcmp(pmu->name, pmu_name) || in pmu__name_match()
1799 (pmu->is_uncore && pmu_uncore_alias_match(pmu_name, pmu->name)) || in pmu__name_match()
1804 (pmu->is_core && !strcmp(pmu_name, "default_core")); in pmu__name_match()
1815 if (pmu->is_core || pmu->is_uncore || pmu->auxtrace) in perf_pmu__is_software()
1817 switch (pmu->type) { in perf_pmu__is_software()
1827 if (!strcmp(pmu->name, known_sw_pmus[i])) in perf_pmu__is_software()
1837 if (!perf_pmu__pathname_scnprintf(path, sizeof(path), pmu->name, name) || in perf_pmu__open_file()
1848 fd = perf_pmu__pathname_fd(dirfd, pmu->name, name, O_RDONLY); in perf_pmu__open_file_at()
1893 if (!perf_pmu__pathname_scnprintf(path, sizeof(path), pmu->name, name)) in perf_pmu__file_exists()
1904 return -ENOMEM; in perf_pmu__new_caps()
1906 caps->name = strdup(name); in perf_pmu__new_caps()
1907 if (!caps->name) in perf_pmu__new_caps()
1909 caps->value = strndup(value, strlen(value) - 1); in perf_pmu__new_caps()
1910 if (!caps->value) in perf_pmu__new_caps()
1912 list_add_tail(&caps->list, list); in perf_pmu__new_caps()
1916 zfree(&caps->name); in perf_pmu__new_caps()
1920 return -ENOMEM; in perf_pmu__new_caps()
1927 list_for_each_entry_safe(caps, tmp, &pmu->caps, list) { in perf_pmu__del_caps()
1928 list_del(&caps->list); in perf_pmu__del_caps()
1929 zfree(&caps->name); in perf_pmu__del_caps()
1930 zfree(&caps->value); in perf_pmu__del_caps()
1948 if (pmu->caps_initialized) in perf_pmu__caps_parse()
1949 return pmu->nr_caps; in perf_pmu__caps_parse()
1951 pmu->nr_caps = 0; in perf_pmu__caps_parse()
1953 if (!perf_pmu__pathname_scnprintf(caps_path, sizeof(caps_path), pmu->name, "caps")) in perf_pmu__caps_parse()
1954 return -1; in perf_pmu__caps_parse()
1957 pmu->caps_initialized = true; in perf_pmu__caps_parse()
1963 return -EINVAL; in perf_pmu__caps_parse()
1968 char *name = evt_ent->d_name; in perf_pmu__caps_parse()
1977 if (fd == -1) in perf_pmu__caps_parse()
1986 (perf_pmu__new_caps(&pmu->caps, name, value) < 0)) { in perf_pmu__caps_parse()
1991 pmu->nr_caps++; in perf_pmu__caps_parse()
1997 pmu->caps_initialized = true; in perf_pmu__caps_parse()
1998 return pmu->nr_caps; in perf_pmu__caps_parse()
2005 if (pmu->config_masks_computed) in perf_pmu__compute_config_masks()
2008 list_for_each_entry(format, &pmu->format, list) { in perf_pmu__compute_config_masks()
2012 if (format->value >= PERF_PMU_FORMAT_VALUE_CONFIG_END) in perf_pmu__compute_config_masks()
2015 pmu->config_masks_present = true; in perf_pmu__compute_config_masks()
2016 mask = &pmu->config_masks[format->value]; in perf_pmu__compute_config_masks()
2018 for_each_set_bit(i, format->bits, PERF_PMU_FORMAT_BITS) in perf_pmu__compute_config_masks()
2021 pmu->config_masks_computed = true; in perf_pmu__compute_config_masks()
2036 if (!pmu->config_masks_present) in perf_pmu__warn_invalid_config()
2039 bits = config & ~pmu->config_masks[config_num]; in perf_pmu__warn_invalid_config()
2043 bitmap_scnprintf((unsigned long *)&bits, sizeof(bits) * 8, buf, sizeof(buf)); in perf_pmu__warn_invalid_config()
2053 return -1; in perf_pmu__match()
2056 return -1; in perf_pmu__match()
2059 return -1; in perf_pmu__match()
2084 return -1; in perf_pmu__event_source_devices_fd()
2108 return scnprintf(buf + len, size - len, "%s/%s", pmu_name, filename); in perf_pmu__pathname_scnprintf()
2121 perf_pmu__del_formats(&pmu->format); in perf_pmu__delete()
2125 perf_cpu_map__put(pmu->cpus); in perf_pmu__delete()
2127 zfree(&pmu->default_config); in perf_pmu__delete()
2128 zfree(&pmu->name); in perf_pmu__delete()
2129 zfree(&pmu->alias_name); in perf_pmu__delete()
2130 zfree(&pmu->id); in perf_pmu__delete()
2143 list_for_each_entry(event, &pmu->aliases, list) { in perf_pmu__name_from_config()
2145 int ret = perf_pmu__config(pmu, &attr, &event->terms, NULL); in perf_pmu__name_from_config()
2148 return event->name; in perf_pmu__name_from_config()