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"
48 * struct perf_pmu_alias - An event either read from sysfs or builtin in
49 * pmu-events.c, created by parsing the pmu-events json files.
52 /** @name: Name of the event like "mem-loads". */
56 /** @long_desc: Optional long description. */
78 * <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.per-pkg or
100 * struct perf_pmu_format - Values from a format file read from
104 * "config:0-7" and will be represented here as name="event",
134 format->name = strdup(name); in perf_pmu__new_format()
135 if (!format->name) { in perf_pmu__new_format()
139 list_add_tail(&format->list, list); in perf_pmu__new_format()
144 void perf_pmu_format__set_value(void *vformat, int config, unsigned long *bits) in perf_pmu_format__set_value()
148 format->value = config; in perf_pmu_format__set_value()
149 memcpy(format->bits, bits, sizeof(format->bits)); in perf_pmu_format__set_value()
164 format->loaded = true; in __perf_pmu_format__load()
172 if (format->loaded) in perf_pmu_format__load()
175 if (!perf_pmu__pathname_scnprintf(path, sizeof(path), pmu->name, "format")) in perf_pmu_format__load()
178 assert(strlen(path) + strlen(format->name) + 2 < sizeof(path)); in perf_pmu_format__load()
180 strcat(path, format->name); in perf_pmu_format__load()
201 return -EINVAL; in perf_pmu__format_parse()
205 char *name = evt_ent->d_name; in perf_pmu__format_parse()
210 format = perf_pmu__new_format(&pmu->format, name); in perf_pmu__format_parse()
212 ret = -ENOMEM; in perf_pmu__format_parse()
221 ret = -errno; in perf_pmu__format_parse()
253 return -1; in pmu_format()
275 ret = -ENOMEM; in perf_pmu__convert_scale()
301 int fd, ret = -1; in perf_pmu__parse_scale()
307 scnprintf(path + len, sizeof(path) - len, "%s/events/%s.scale", pmu->name, alias->name); in perf_pmu__parse_scale()
310 if (fd == -1) in perf_pmu__parse_scale()
311 return -1; in perf_pmu__parse_scale()
316 sret = read(fd, scale, sizeof(scale)-1); in perf_pmu__parse_scale()
320 if (scale[sret - 1] == '\n') in perf_pmu__parse_scale()
321 scale[sret - 1] = '\0'; in perf_pmu__parse_scale()
325 ret = perf_pmu__convert_scale(scale, NULL, &alias->scale); in perf_pmu__parse_scale()
342 scnprintf(path + len, sizeof(path) - len, "%s/events/%s.unit", pmu->name, alias->name); in perf_pmu__parse_unit()
345 if (fd == -1) in perf_pmu__parse_unit()
346 return -1; in perf_pmu__parse_unit()
348 sret = read(fd, alias->unit, UNIT_MAX_LEN); in perf_pmu__parse_unit()
354 if (alias->unit[sret - 1] == '\n') in perf_pmu__parse_unit()
355 alias->unit[sret - 1] = '\0'; in perf_pmu__parse_unit()
357 alias->unit[sret] = '\0'; in perf_pmu__parse_unit()
362 alias->unit[0] = '\0'; in perf_pmu__parse_unit()
363 return -1; in perf_pmu__parse_unit()
377 scnprintf(path + len, sizeof(path) - len, "%s/events/%s.%s", pmu_name, event_name, suffix); in perf_pmu__parse_event_source_bool()
380 if (fd == -1) in perf_pmu__parse_event_source_bool()
399 alias->per_pkg = perf_pmu__parse_event_source_bool(pmu->name, alias->name, "per-pkg"); in perf_pmu__parse_per_pkg()
404 alias->snapshot = perf_pmu__parse_event_source_bool(pmu->name, alias->name, "snapshot"); in perf_pmu__parse_snapshot()
410 zfree(&newalias->name); in perf_pmu_free_alias()
411 zfree(&newalias->desc); in perf_pmu_free_alias()
412 zfree(&newalias->long_desc); in perf_pmu_free_alias()
413 zfree(&newalias->topic); in perf_pmu_free_alias()
414 zfree(&newalias->pmu_name); in perf_pmu_free_alias()
415 parse_events_terms__exit(&newalias->terms); in perf_pmu_free_alias()
423 list_for_each_entry_safe(alias, tmp, &pmu->aliases, list) { in perf_pmu__del_aliases()
424 list_del(&alias->list); in perf_pmu__del_aliases()
435 if (load && !pmu->sysfs_aliases_loaded) { in perf_pmu__find_alias()
459 list_for_each_entry(alias, &pmu->aliases, list) { in perf_pmu__find_alias()
460 if (!strcasecmp(alias->name, name)) in perf_pmu__find_alias()
486 if (!alias->from_sysfs || alias->info_loaded) in read_alias_info()
510 read_alias_info(data->pmu, data->alias); in update_alias()
511 assign_str(pe->name, "desc", &data->alias->desc, pe->desc); in update_alias()
512 assign_str(pe->name, "long_desc", &data->alias->long_desc, pe->long_desc); in update_alias()
513 assign_str(pe->name, "topic", &data->alias->topic, pe->topic); in update_alias()
514 data->alias->per_pkg = pe->perpkg; in update_alias()
515 if (pe->event) { in update_alias()
516 parse_events_terms__exit(&data->alias->terms); in update_alias()
517 ret = parse_events_terms(&data->alias->terms, pe->event, /*input=*/NULL); in update_alias()
519 if (!ret && pe->unit) { in update_alias()
522 ret = perf_pmu__convert_scale(pe->unit, &unit, &data->alias->scale); in update_alias()
524 snprintf(data->alias->unit, sizeof(data->alias->unit), "%s", unit); in update_alias()
544 long_desc = pe->long_desc; in perf_pmu__new_alias()
545 topic = pe->topic; in perf_pmu__new_alias()
546 unit = pe->unit; in perf_pmu__new_alias()
547 perpkg = pe->perpkg; in perf_pmu__new_alias()
548 deprecated = pe->deprecated; in perf_pmu__new_alias()
549 if (pe->pmu && strcmp(pe->pmu, "default_core")) in perf_pmu__new_alias()
550 pmu_name = pe->pmu; in perf_pmu__new_alias()
555 return -ENOMEM; in perf_pmu__new_alias()
557 parse_events_terms__init(&alias->terms); in perf_pmu__new_alias()
558 alias->scale = 1.0; in perf_pmu__new_alias()
559 alias->unit[0] = '\0'; in perf_pmu__new_alias()
560 alias->per_pkg = perpkg; in perf_pmu__new_alias()
561 alias->snapshot = false; in perf_pmu__new_alias()
562 alias->deprecated = deprecated; in perf_pmu__new_alias()
564 ret = parse_events_terms(&alias->terms, val, val_fd); in perf_pmu__new_alias()
571 alias->name = strdup(name); in perf_pmu__new_alias()
572 alias->desc = desc ? strdup(desc) : NULL; in perf_pmu__new_alias()
573 alias->long_desc = long_desc ? strdup(long_desc) : in perf_pmu__new_alias()
575 alias->topic = topic ? strdup(topic) : NULL; in perf_pmu__new_alias()
576 alias->pmu_name = pmu_name ? strdup(pmu_name) : NULL; in perf_pmu__new_alias()
578 if (perf_pmu__convert_scale(unit, (char **)&unit, &alias->scale) < 0) { in perf_pmu__new_alias()
580 return -1; in perf_pmu__new_alias()
582 snprintf(alias->unit, sizeof(alias->unit), "%s", unit); in perf_pmu__new_alias()
587 alias->from_sysfs = true; in perf_pmu__new_alias()
588 if (pmu->events_table) { in perf_pmu__new_alias()
594 if (pmu_events_table__find_event(pmu->events_table, pmu, name, in perf_pmu__new_alias()
596 pmu->cpu_json_aliases++; in perf_pmu__new_alias()
598 pmu->sysfs_aliases++; in perf_pmu__new_alias()
601 pmu->cpu_json_aliases++; in perf_pmu__new_alias()
604 pmu->sys_json_aliases++; in perf_pmu__new_alias()
608 list_add_tail(&alias->list, &pmu->aliases); in perf_pmu__new_alias()
617 if (len > 5 && !strcmp(name + len - 5, ".unit")) in pmu_alias_info_file()
619 if (len > 6 && !strcmp(name + len - 6, ".scale")) in pmu_alias_info_file()
621 if (len > 8 && !strcmp(name + len - 8, ".per-pkg")) in pmu_alias_info_file()
623 if (len > 9 && !strcmp(name + len - 9, ".snapshot")) in pmu_alias_info_file()
640 return -EINVAL; in __pmu_aliases_parse()
643 char *name = evt_ent->d_name; in __pmu_aliases_parse()
657 if (fd == -1) { in __pmu_aliases_parse()
675 pmu->sysfs_aliases_loaded = true; in __pmu_aliases_parse()
685 if (pmu->sysfs_aliases_loaded) in pmu_aliases_parse()
691 scnprintf(path + len, sizeof(path) - len, "%s/events", pmu->name); in pmu_aliases_parse()
694 if (events_dir_fd == -1) { in pmu_aliases_parse()
695 pmu->sysfs_aliases_loaded = true; in pmu_aliases_parse()
708 scnprintf(path, sizeof(path), "%s/events", pmu->name); in pmu_aliases_parse_eager()
710 if (events_dir_fd == -1) { in pmu_aliases_parse_eager()
711 pmu->sysfs_aliases_loaded = true; in pmu_aliases_parse_eager()
721 struct parse_events_term *term, *cloned; in pmu_alias_terms() local
725 list_for_each_entry(term, &alias->terms.terms, list) { in pmu_alias_terms()
726 int ret = parse_events_term__clone(&cloned, term); in pmu_alias_terms()
736 cloned->weak = true; in pmu_alias_terms()
737 cloned->err_term = cloned->err_val = err_loc; in pmu_alias_terms()
738 list_add_tail(&cloned->list, &clone_terms.terms); in pmu_alias_terms()
799 str[len - 1] = 0; /* remove line feed */ in pmu_id()
805 * is_sysfs_pmu_core() - PMU CORE devices have different name other than cpu in
857 return skip_duplicate_pmus && !pmu->is_core in pmu_deduped_name_len()
863 * perf_pmu__match_ignoring_suffix - Does the pmu_name match tok ignoring any
897 return (p - suffix) > 2; in perf_pmu__match_ignoring_suffix()
903 * pmu_uncore_alias_match - does name match the PMU name?
931 * Match more complex aliases where the alias name is a comma-delimited in pmu_uncore_alias_match()
987 perf_pmu__new_alias(pmu, pe->name, pe->desc, pe->event, /*val_fd=*/ NULL, in pmu_add_cpu_aliases_map_callback()
1003 if (!pmu->events_table) in pmu_add_cpu_aliases()
1006 if (pmu->cpu_aliases_added) in pmu_add_cpu_aliases()
1009 pmu_add_cpu_aliases_table(pmu, pmu->events_table); in pmu_add_cpu_aliases()
1010 pmu->cpu_aliases_added = true; in pmu_add_cpu_aliases()
1019 if (!pe->compat || !pe->pmu) in pmu_add_sys_aliases_iter_fn()
1022 if (pmu_uncore_alias_match(pe->pmu, pmu->name) && in pmu_add_sys_aliases_iter_fn()
1023 pmu_uncore_identifier_match(pe->compat, pmu->id)) { in pmu_add_sys_aliases_iter_fn()
1025 pe->name, in pmu_add_sys_aliases_iter_fn()
1026 pe->desc, in pmu_add_sys_aliases_iter_fn()
1027 pe->event, in pmu_add_sys_aliases_iter_fn()
1038 if (!pmu->id) in pmu_add_sys_aliases()
1060 if (ret > 0 && line[ret - 1] == '\n') in pmu_find_alias_name()
1061 line[--ret] = '\0'; in pmu_find_alias_name()
1069 int max_precise = -1; in pmu_max_precise()
1078 if (pmu->is_core) in perf_pmu__arch_init()
1079 pmu->mem_events = perf_mem_events; in perf_pmu__arch_init()
1092 pmu->name = strdup(name); in perf_pmu__lookup()
1093 if (!pmu->name) in perf_pmu__lookup()
1103 INIT_LIST_HEAD(&pmu->format); in perf_pmu__lookup()
1104 INIT_LIST_HEAD(&pmu->aliases); in perf_pmu__lookup()
1105 INIT_LIST_HEAD(&pmu->caps); in perf_pmu__lookup()
1115 pmu->is_core = is_pmu_core(name); in perf_pmu__lookup()
1116 pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core); in perf_pmu__lookup()
1118 pmu->type = type; in perf_pmu__lookup()
1119 pmu->is_uncore = pmu_is_uncore(dirfd, name); in perf_pmu__lookup()
1120 if (pmu->is_uncore) in perf_pmu__lookup()
1121 pmu->id = pmu_id(name); in perf_pmu__lookup()
1122 pmu->max_precise = pmu_max_precise(dirfd, pmu); in perf_pmu__lookup()
1123 pmu->alias_name = pmu_find_alias_name(pmu, dirfd); in perf_pmu__lookup()
1124 pmu->events_table = perf_pmu__find_events_table(pmu); in perf_pmu__lookup()
1132 list_add_tail(&pmu->list, pmus); in perf_pmu__lookup()
1141 zfree(&pmu->name); in perf_pmu__lookup()
1154 pmu->name = strdup("cpu"); in perf_pmu__create_placeholder_core_pmu()
1155 if (!pmu->name) { in perf_pmu__create_placeholder_core_pmu()
1160 pmu->is_core = true; in perf_pmu__create_placeholder_core_pmu()
1161 pmu->type = PERF_TYPE_RAW; in perf_pmu__create_placeholder_core_pmu()
1162 pmu->cpus = cpu_map__online(); in perf_pmu__create_placeholder_core_pmu()
1164 INIT_LIST_HEAD(&pmu->format); in perf_pmu__create_placeholder_core_pmu()
1165 INIT_LIST_HEAD(&pmu->aliases); in perf_pmu__create_placeholder_core_pmu()
1166 INIT_LIST_HEAD(&pmu->caps); in perf_pmu__create_placeholder_core_pmu()
1167 list_add_tail(&pmu->list, core_pmus); in perf_pmu__create_placeholder_core_pmu()
1173 return pmu->type == PERF_PMU_TYPE_FAKE; in perf_pmu__is_fake()
1180 if (pmu->formats_checked) in perf_pmu__warn_invalid_formats()
1183 pmu->formats_checked = true; in perf_pmu__warn_invalid_formats()
1189 list_for_each_entry(format, &pmu->format, list) { in perf_pmu__warn_invalid_formats()
1191 if (format->value >= PERF_PMU_FORMAT_VALUE_CONFIG_END) { in perf_pmu__warn_invalid_formats()
1194 pmu->name, format->name, format->value); in perf_pmu__warn_invalid_formats()
1204 if (evsel->needs_auxtrace_mmap) in evsel__is_aux_event()
1208 return pmu && pmu->auxtrace; in evsel__is_aux_event()
1212 * Set @config_name to @val as long as the user hasn't already set or cleared it
1213 * by passing a config term on the command line.
1219 #define field_prep(_mask, _val) (((_val) << (ffsll(_mask) - 1)) & (_mask))
1224 struct evsel_config_term *term = evsel__get_config_term(evsel, CFG_CHG); in evsel__set_config_if_unset() local
1226 if (term) in evsel__set_config_if_unset()
1227 user_bits = term->val.cfg_chg; in evsel__set_config_if_unset()
1236 evsel->core.attr.config &= ~bits; in evsel__set_config_if_unset()
1237 evsel->core.attr.config |= field_prep(bits, val); in evsel__set_config_if_unset()
1246 if (!strcmp(format->name, name)) in pmu_find_format()
1254 struct perf_pmu_format *format = pmu_find_format(&pmu->format, name); in perf_pmu__format_bits()
1261 for_each_set_bit(fbit, format->bits, PERF_PMU_FORMAT_BITS) in perf_pmu__format_bits()
1269 struct perf_pmu_format *format = pmu_find_format(&pmu->format, name); in perf_pmu__format_type()
1272 return -1; in perf_pmu__format_type()
1275 return format->value; in perf_pmu__format_type()
1282 static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v, in pmu_format_value()
1285 unsigned long fbit, vbit; in pmu_format_value()
1299 static __u64 pmu_format_max_value(const unsigned long *format) in pmu_format_max_value()
1307 return (1ULL << w) - 1; in pmu_format_max_value()
1308 return -1; in pmu_format_max_value()
1312 * Term is a string term, and might be a param-term. Try to look up it's value
1314 * - We have a term like "base-or-format-term=param-term",
1315 * - We need to find the value supplied for "param-term" (with param-term named
1316 * in a config string) later on in the term list.
1318 static int pmu_resolve_param_term(struct parse_events_term *term, in pmu_resolve_param_term() argument
1324 list_for_each_entry(t, &head_terms->terms, list) { in pmu_resolve_param_term()
1325 if (t->type_val == PARSE_EVENTS__TERM_TYPE_NUM && in pmu_resolve_param_term()
1326 t->config && !strcmp(t->config, term->config)) { in pmu_resolve_param_term()
1327 t->used = true; in pmu_resolve_param_term()
1328 *value = t->val.num; in pmu_resolve_param_term()
1334 printf("Required parameter '%s' not specified\n", term->config); in pmu_resolve_param_term()
1336 return -1; in pmu_resolve_param_term()
1351 if (strbuf_addf(&buf, i++ ? ",%s" : "%s", format->name) < 0) in pmu_formats_string()
1363 * user input data - term parameter.
1367 struct parse_events_term *term, in pmu_config_term() argument
1376 * If this is a parameter we've already used for parameterized-eval, in pmu_config_term()
1379 if (term->used) in pmu_config_term()
1386 if (parse_events__is_hardcoded_term(term)) in pmu_config_term()
1389 format = pmu_find_format(&pmu->format, term->config); in pmu_config_term()
1391 char *pmu_term = pmu_formats_string(&pmu->format); in pmu_config_term()
1396 "unknown term '%s' for pmu '%s'", in pmu_config_term()
1397 term->config, pmu->name) < 0) in pmu_config_term()
1401 parse_events_error__handle(err, term->err_term, in pmu_config_term()
1409 return -EINVAL; in pmu_config_term()
1412 switch (format->value) { in pmu_config_term()
1414 vp = &attr->config; in pmu_config_term()
1417 vp = &attr->config1; in pmu_config_term()
1420 vp = &attr->config2; in pmu_config_term()
1423 vp = &attr->config3; in pmu_config_term()
1426 return -EINVAL; in pmu_config_term()
1430 * Either directly use a numeric term, or try to translate string terms in pmu_config_term()
1433 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) { in pmu_config_term()
1434 if (term->no_value && in pmu_config_term()
1435 bitmap_weight(format->bits, PERF_PMU_FORMAT_BITS) > 1) { in pmu_config_term()
1437 parse_events_error__handle(err, term->err_val, in pmu_config_term()
1438 strdup("no value assigned for term"), in pmu_config_term()
1441 return -EINVAL; in pmu_config_term()
1444 val = term->val.num; in pmu_config_term()
1445 } else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) { in pmu_config_term()
1446 if (strcmp(term->val.str, "?")) { in pmu_config_term()
1449 term->config, term->val.str); in pmu_config_term()
1452 parse_events_error__handle(err, term->err_val, in pmu_config_term()
1456 return -EINVAL; in pmu_config_term()
1459 if (pmu_resolve_param_term(term, head_terms, &val)) in pmu_config_term()
1460 return -EINVAL; in pmu_config_term()
1462 return -EINVAL; in pmu_config_term()
1464 max_val = pmu_format_max_value(format->bits); in pmu_config_term()
1469 parse_events_error__handle(err, term->err_val, in pmu_config_term()
1472 format->name, (unsigned long long)max_val) < 0 in pmu_config_term()
1476 return -EINVAL; in pmu_config_term()
1484 pmu_format_value(format->bits, val, vp, zero); in pmu_config_term()
1493 struct parse_events_term *term; in perf_pmu__config_terms() local
1495 list_for_each_entry(term, &terms->terms, list) { in perf_pmu__config_terms()
1496 if (pmu_config_term(pmu, attr, term, terms, zero, err)) in perf_pmu__config_terms()
1497 return -EINVAL; in perf_pmu__config_terms()
1505 * 1) users input - specified in terms parameter
1506 * 2) pmu format definitions - specified by pmu parameter
1512 bool zero = !!pmu->perf_event_attr_init_default; in perf_pmu__config()
1522 struct parse_events_term *term) in pmu_find_alias() argument
1527 if (parse_events__is_hardcoded_term(term)) in pmu_find_alias()
1530 if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM) { in pmu_find_alias()
1531 if (!term->no_value) in pmu_find_alias()
1533 if (pmu_find_format(&pmu->format, term->config)) in pmu_find_alias()
1535 name = term->config; in pmu_find_alias()
1537 } else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) { in pmu_find_alias()
1538 if (strcasecmp(term->config, "event")) in pmu_find_alias()
1540 name = term->val.str; in pmu_find_alias()
1546 if (alias || pmu->cpu_aliases_added) in pmu_find_alias()
1550 if (pmu->events_table && in pmu_find_alias()
1551 pmu_events_table__find_event(pmu->events_table, pmu, name, in pmu_find_alias()
1568 * Only one term in event definition can in check_info_data()
1572 if (info->unit && alias->unit[0]) { in check_info_data()
1576 return -EINVAL; in check_info_data()
1578 if (info->scale && alias->scale) { in check_info_data()
1582 return -EINVAL; in check_info_data()
1584 if (info->snapshot && alias->snapshot) { in check_info_data()
1588 return -EINVAL; in check_info_data()
1591 if (alias->unit[0]) in check_info_data()
1592 info->unit = alias->unit; in check_info_data()
1594 if (alias->scale) in check_info_data()
1595 info->scale = alias->scale; in check_info_data()
1597 if (alias->snapshot) in check_info_data()
1598 info->snapshot = alias->snapshot; in check_info_data()
1611 struct parse_events_term *term, *h; in perf_pmu__check_alias() local
1616 info->per_pkg = false; in perf_pmu__check_alias()
1622 info->unit = NULL; in perf_pmu__check_alias()
1623 info->scale = 0.0; in perf_pmu__check_alias()
1624 info->snapshot = false; in perf_pmu__check_alias()
1630 list_for_each_entry_safe(term, h, &head_terms->terms, list) { in perf_pmu__check_alias()
1631 alias = pmu_find_alias(pmu, term); in perf_pmu__check_alias()
1634 ret = pmu_alias_terms(alias, term->err_term, &term->list); in perf_pmu__check_alias()
1636 parse_events_error__handle(err, term->err_term, in perf_pmu__check_alias()
1642 ret = check_info_data(pmu, alias, info, err, term->err_term); in perf_pmu__check_alias()
1646 if (alias->per_pkg) in perf_pmu__check_alias()
1647 info->per_pkg = true; in perf_pmu__check_alias()
1649 list_del_init(&term->list); in perf_pmu__check_alias()
1650 parse_events_term__delete(term); in perf_pmu__check_alias()
1658 if (info->unit == NULL) in perf_pmu__check_alias()
1659 info->unit = ""; in perf_pmu__check_alias()
1661 if (info->scale == 0.0) in perf_pmu__check_alias()
1662 info->scale = 1.0; in perf_pmu__check_alias()
1677 if (!strcmp(args->event, info->name)) in find_event_callback()
1678 return args->cb(args->state, info); in find_event_callback()
1691 /* Sub-optimal, but function is only used by tests. */ in perf_pmu__find_event()
1701 list_del(&fmt->list); in perf_pmu__del_formats()
1702 zfree(&fmt->name); in perf_pmu__del_formats()
1711 list_for_each_entry(format, &pmu->format, list) { in perf_pmu__has_format()
1712 if (!strcmp(format->name, name)) in perf_pmu__has_format()
1730 "call-graph=(fp|dwarf|lbr)", in perf_pmu__for_each_format()
1731 "stack-size=number", in perf_pmu__for_each_format()
1732 "max-stack=number", in perf_pmu__for_each_format()
1735 "no-inherit", in perf_pmu__for_each_format()
1737 "no-overwrite", in perf_pmu__for_each_format()
1739 "aux-output", in perf_pmu__for_each_format()
1740 "aux-sample-size=number", in perf_pmu__for_each_format()
1746 * max-events and driver-config are missing above as are the internal in perf_pmu__for_each_format()
1747 * types user, metric-id, raw, legacy cache and hardware. Assert against in perf_pmu__for_each_format()
1750 _Static_assert(ARRAY_SIZE(terms) == __PARSE_EVENTS__TERM_TYPE_NR - 6, in perf_pmu__for_each_format()
1752 list_for_each_entry(format, &pmu->format, list) { in perf_pmu__for_each_format()
1754 ret = cb(state, format->name, (int)format->value, format->bits); in perf_pmu__for_each_format()
1758 if (!pmu->is_core) in perf_pmu__for_each_format()
1781 return pmu->is_core; in perf_pmu__supports_legacy_cache()
1786 return !pmu->is_core || perf_pmus__num_core_pmus() == 1; in perf_pmu__auto_merge_stats()
1795 if (pmu->cpu_aliases_added || !pmu->events_table) in perf_pmu__have_event()
1797 return pmu_events_table__find_event(pmu->events_table, pmu, name, NULL, NULL) == 0; in perf_pmu__have_event()
1805 nr = pmu->sysfs_aliases + pmu->sys_json_aliases; in perf_pmu__num_events()
1807 if (pmu->cpu_aliases_added) in perf_pmu__num_events()
1808 nr += pmu->cpu_json_aliases; in perf_pmu__num_events()
1809 else if (pmu->events_table) in perf_pmu__num_events()
1810 nr += pmu_events_table__num_events(pmu->events_table, pmu) - pmu->cpu_json_aliases; in perf_pmu__num_events()
1812 assert(pmu->cpu_json_aliases == 0); in perf_pmu__num_events()
1814 return pmu->selectable ? nr + 1 : nr; in perf_pmu__num_events()
1821 return a - b; in sub_non_neg()
1827 struct parse_events_term *term; in format_alias() local
1828 size_t pmu_name_len = pmu_deduped_name_len(pmu, pmu->name, in format_alias()
1830 int used = snprintf(buf, len, "%.*s/%s", (int)pmu_name_len, pmu->name, alias->name); in format_alias()
1832 list_for_each_entry(term, &alias->terms.terms, list) { in format_alias()
1833 if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR) in format_alias()
1835 ",%s=%s", term->config, in format_alias()
1836 term->val.str); in format_alias()
1847 buf[len - 1] = '\0'; in format_alias()
1867 list_for_each_entry(event, &pmu->aliases, list) { in perf_pmu__for_each_event()
1870 info.pmu_name = event->pmu_name ?: pmu->name; in perf_pmu__for_each_event()
1874 if (event->desc) { in perf_pmu__for_each_event()
1875 info.name = event->name; in perf_pmu__for_each_event()
1880 if (pmu->is_core) { in perf_pmu__for_each_event()
1882 info.name = event->name; in perf_pmu__for_each_event()
1887 if (strlen(event->unit) || event->scale != 1.0) { in perf_pmu__for_each_event()
1889 buf_used += snprintf(buf + buf_used, sizeof(buf) - buf_used, in perf_pmu__for_each_event()
1890 "%G%s", event->scale, event->unit) + 1; in perf_pmu__for_each_event()
1892 info.desc = event->desc; in perf_pmu__for_each_event()
1893 info.long_desc = event->long_desc; in perf_pmu__for_each_event()
1895 parse_events_terms__to_strbuf(&event->terms, &sb); in perf_pmu__for_each_event()
1896 buf_used += snprintf(buf + buf_used, sizeof(buf) - buf_used, in perf_pmu__for_each_event()
1898 info.topic = event->topic; in perf_pmu__for_each_event()
1900 info.deprecated = event->deprecated; in perf_pmu__for_each_event()
1906 if (pmu->selectable) { in perf_pmu__for_each_event()
1908 snprintf(buf, sizeof(buf), "%s//", pmu->name); in perf_pmu__for_each_event()
1915 info.pmu_name = pmu->name; in perf_pmu__for_each_event()
1926 return !strcmp(pmu->name, pmu_name) || in pmu__name_match()
1927 (pmu->is_uncore && pmu_uncore_alias_match(pmu_name, pmu->name)) || in pmu__name_match()
1932 (pmu->is_core && !strcmp(pmu_name, "default_core")); in pmu__name_match()
1943 if (pmu->is_core || pmu->is_uncore || pmu->auxtrace) in perf_pmu__is_software()
1945 switch (pmu->type) { in perf_pmu__is_software()
1955 if (!strcmp(pmu->name, known_sw_pmus[i])) in perf_pmu__is_software()
1965 if (!perf_pmu__pathname_scnprintf(path, sizeof(path), pmu->name, name) || in perf_pmu__open_file()
1976 fd = perf_pmu__pathname_fd(dirfd, pmu->name, name, O_RDONLY); in perf_pmu__open_file_at()
2021 if (!perf_pmu__pathname_scnprintf(path, sizeof(path), pmu->name, name)) in perf_pmu__file_exists()
2032 return -ENOMEM; in perf_pmu__new_caps()
2034 caps->name = strdup(name); in perf_pmu__new_caps()
2035 if (!caps->name) in perf_pmu__new_caps()
2037 caps->value = strndup(value, strlen(value) - 1); in perf_pmu__new_caps()
2038 if (!caps->value) in perf_pmu__new_caps()
2040 list_add_tail(&caps->list, list); in perf_pmu__new_caps()
2044 zfree(&caps->name); in perf_pmu__new_caps()
2048 return -ENOMEM; in perf_pmu__new_caps()
2055 list_for_each_entry_safe(caps, tmp, &pmu->caps, list) { in perf_pmu__del_caps()
2056 list_del(&caps->list); in perf_pmu__del_caps()
2057 zfree(&caps->name); in perf_pmu__del_caps()
2058 zfree(&caps->value); in perf_pmu__del_caps()
2076 if (pmu->caps_initialized) in perf_pmu__caps_parse()
2077 return pmu->nr_caps; in perf_pmu__caps_parse()
2079 pmu->nr_caps = 0; in perf_pmu__caps_parse()
2081 if (!perf_pmu__pathname_scnprintf(caps_path, sizeof(caps_path), pmu->name, "caps")) in perf_pmu__caps_parse()
2082 return -1; in perf_pmu__caps_parse()
2085 pmu->caps_initialized = true; in perf_pmu__caps_parse()
2091 return -EINVAL; in perf_pmu__caps_parse()
2096 char *name = evt_ent->d_name; in perf_pmu__caps_parse()
2105 if (fd == -1) in perf_pmu__caps_parse()
2114 (perf_pmu__new_caps(&pmu->caps, name, value) < 0)) { in perf_pmu__caps_parse()
2119 pmu->nr_caps++; in perf_pmu__caps_parse()
2125 pmu->caps_initialized = true; in perf_pmu__caps_parse()
2126 return pmu->nr_caps; in perf_pmu__caps_parse()
2133 if (pmu->config_masks_computed) in perf_pmu__compute_config_masks()
2136 list_for_each_entry(format, &pmu->format, list) { in perf_pmu__compute_config_masks()
2140 if (format->value >= PERF_PMU_FORMAT_VALUE_CONFIG_END) in perf_pmu__compute_config_masks()
2143 pmu->config_masks_present = true; in perf_pmu__compute_config_masks()
2144 mask = &pmu->config_masks[format->value]; in perf_pmu__compute_config_masks()
2146 for_each_set_bit(i, format->bits, PERF_PMU_FORMAT_BITS) in perf_pmu__compute_config_masks()
2149 pmu->config_masks_computed = true; in perf_pmu__compute_config_masks()
2164 if (!pmu->config_masks_present) in perf_pmu__warn_invalid_config()
2167 bits = config & ~pmu->config_masks[config_num]; in perf_pmu__warn_invalid_config()
2171 bitmap_scnprintf((unsigned long *)&bits, sizeof(bits) * 8, buf, sizeof(buf)); in perf_pmu__warn_invalid_config()
2180 const char *name = pmu->name; in perf_pmu__match()
2192 name = pmu->alias_name; in perf_pmu__match()
2223 return -1; in perf_pmu__event_source_devices_fd()
2247 return scnprintf(buf + len, size - len, "%s/%s", pmu_name, filename); in perf_pmu__pathname_scnprintf()
2260 perf_pmu__del_formats(&pmu->format); in perf_pmu__delete()
2264 perf_cpu_map__put(pmu->cpus); in perf_pmu__delete()
2266 zfree(&pmu->name); in perf_pmu__delete()
2267 zfree(&pmu->alias_name); in perf_pmu__delete()
2268 zfree(&pmu->id); in perf_pmu__delete()
2281 list_for_each_entry(event, &pmu->aliases, list) { in perf_pmu__name_from_config()
2283 int ret = perf_pmu__config(pmu, &attr, &event->terms, NULL); in perf_pmu__name_from_config()
2286 return event->name; in perf_pmu__name_from_config()