From nobody Thu Oct 2 18:06:27 2025 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BBD52DFA27 for ; Sun, 14 Sep 2025 18:11:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757873498; cv=none; b=e47wLRFpKqrFw9lk/d9b8mRpRgxtnNvCM0D6N3s87RB2Qu2bQBT4AbGGYvjmYqMLZlNFCkJ5H2z6AZnV0w2TdXIo/QpTsVCdwa+JyhMPIVI/G4GMFHPOiQenwnT8o5uzErrdKTzlxER0MhzZFdj1ErMAFAq5AGzyyRLgltfaX9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757873498; c=relaxed/simple; bh=zRjn0K8l/MA5b4qrJdDHhsBtGhBMJQ0ges1VWoeYUgo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YV1eyHq51TYcU0fMYnCtqUwJoeuEQ/EQNNyBVBzwqfirqpOd06cN8eUnqJJZZSs4vOcJfcsOR6VqAlfoOoEr/C6Bx2wA4VU4gF6eff9l01dAAchoGiViSZ0g3edoAzyhLt7IQjb5fuE+jDsAGi59MarMctEDeff8UQDVIphTMBA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cYKrBn6O; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cYKrBn6O" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-265e92cc3aeso3486135ad.3 for ; Sun, 14 Sep 2025 11:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1757873496; x=1758478296; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OztVkxhLWyYxaV1gBN/RBPBoyDIYcONc/mNFIE8MkYo=; b=cYKrBn6OiNCfR/LC6JKVnAPJNxJS63g6UUvfkEUOmU2QxaGRJr0XGkAwgJsJxxokQW GCyBIfNcC6z9wxEMf/f/fsxG015nSAxximyCN5ISrBQ8ppntFVgWXpyR1W9VoGreHPER j9F23ye0RsjPekHFIbW1cUqw56nh8lcKJuzkMUrlhS1AMMfQ9YNefxZmnhYAaFRDJ/Qv 1enodzvHJbQRn/Ie9pQFGux8ihQeiiGhBYiOXL1WF6Z9roJIdZyp/T6x5polhaA3aJyY 4KivvQW+sihELEGPht9Ohfegr8i8ynXxIe5Gzw36DUvXaGPNZ69rcYt1oZsfejVmfpxL 2h+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757873496; x=1758478296; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OztVkxhLWyYxaV1gBN/RBPBoyDIYcONc/mNFIE8MkYo=; b=o7uS0cuykQLwcb5GwpNEdISXTOUhZN3NGHO5WDnsLVVKnHmZQgn3wx4USK/gLumHcg 0HmSb+EjuY7PJfIekoj5jnQU5uKNmlQL7ufNeOPovgW0vGyqVIwhpZa8+kwjt+mruG62 WRxNtdk//o/PesYp9kEE/JDcrZK8dtcq5rXxJ1pPXxFChlU0ncvp/WXOITg6Oveu3yEg CsRTHwsrUQuD50ob+clJbcn6VoSkFipE8gybUrRKL8Rc5gcliSK+aA3FlPb8HmfuGiaH wRuUpgcXKSMmlv+WRR/aLUMpZeDyynQA8MV5H11NRKjGHKVFSGal0sdY9dLVcHayyzm0 nWEQ== X-Forwarded-Encrypted: i=1; AJvYcCWD8TBIpW3LoFMSmSp82SKNdYityCmHYtB903cvw7WbO1glCkpcIg0U8gXsEaGKyS59xM7Pwxa02yJYjWg=@vger.kernel.org X-Gm-Message-State: AOJu0YzzJmZIEXet3dElPN5puR1qzImiFCRh0WtblBfhR9q+pvOh56cx tP/b7BKkF8Sm6Wtvdb4c4K61XeT71hjmhyOCiuNRJZ1idVbZRkSGwct9mGtZQLzQ5FDssf80wS4 rNjxyJz6q0g== X-Google-Smtp-Source: AGHT+IHadHezzLjBjvuQGL0EfLDJKHKQwtP2B8GbZv8RLKcFyjyJ1nY9VQ/gpV45g0UCWt9e0U5dO2Wk+QIp X-Received: from plf16.prod.google.com ([2002:a17:903:35d0:b0:24c:a63d:ed5e]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ce90:b0:264:4e4a:904e with SMTP id d9443c01a7336-2644e4a928bmr45605175ad.23.1757873495746; Sun, 14 Sep 2025 11:11:35 -0700 (PDT) Date: Sun, 14 Sep 2025 11:11:05 -0700 In-Reply-To: <20250914181121.1952748-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250914181121.1952748-1-irogers@google.com> X-Mailer: git-send-email 2.51.0.384.g4c02a37b29-goog Message-ID: <20250914181121.1952748-6-irogers@google.com> Subject: [PATCH v4 05/21] perf pmu: Don't eagerly parse event terms From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Xu Yang , Thomas Falcon , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org, Atish Patra , Beeman Strong , Leo Yan , Vince Weaver Cc: Thomas Richter Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When an event/alias is created for a PMU the terms are eagerly parsed using parse_events_terms. For a command like perf stat or perf record, the particularly event/alias will be found, the terms parsed, the terms cloned for use in the event parsing, and then the terms used to configure the perf_event_attr. Events/aliases may be eagerly loaded, such as from sysfs or in perf list, in which case the aliases terms will be little or never used. To avoid redundant work, to avoid cloning, and to reduce memory overhead, hold the terms for an event as a string until they need handling as a term list. This may introduce duplicate parsing if an event is repeated in a list, but this situation is expected to be uncommon. Measuring the number of instructions before and after with a sysfs event and perf stat, there is a minor reduction in the number of instructions executed by 0.3%. Signed-off-by: Ian Rogers Tested-by: Thomas Richter --- tools/perf/tests/pmu-events.c | 24 +------ tools/perf/util/parse-events.c | 3 +- tools/perf/util/parse-events.h | 1 - tools/perf/util/pmu.c | 111 ++++++++++++++++++++------------- 4 files changed, 70 insertions(+), 69 deletions(-) diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c index 95fd9f671a22..f40a828c9861 100644 --- a/tools/perf/tests/pmu-events.c +++ b/tools/perf/tests/pmu-events.c @@ -22,10 +22,6 @@ struct perf_pmu_test_event { /* used for matching against events from generated pmu-events.c */ struct pmu_event event; =20 - /* used for matching against event aliases */ - /* extra events for aliases */ - const char *alias_str; - /* * Note: For when PublicDescription does not exist in the JSON, we * will have no long_desc in pmu_event.long_desc, but long_desc may @@ -52,7 +48,6 @@ static const struct perf_pmu_test_event bp_l1_btb_correct= =3D { .desc =3D "L1 BTB Correction", .topic =3D "branch", }, - .alias_str =3D "event=3D0x8a", }; =20 static const struct perf_pmu_test_event bp_l2_btb_correct =3D { @@ -63,7 +58,6 @@ static const struct perf_pmu_test_event bp_l2_btb_correct= =3D { .desc =3D "L2 BTB Correction", .topic =3D "branch", }, - .alias_str =3D "event=3D0x8b", }; =20 static const struct perf_pmu_test_event segment_reg_loads_any =3D { @@ -74,7 +68,6 @@ static const struct perf_pmu_test_event segment_reg_loads= _any =3D { .desc =3D "Number of segment register loads", .topic =3D "other", }, - .alias_str =3D "event=3D0x6,period=3D0x30d40,umask=3D0x80", }; =20 static const struct perf_pmu_test_event dispatch_blocked_any =3D { @@ -85,7 +78,6 @@ static const struct perf_pmu_test_event dispatch_blocked_= any =3D { .desc =3D "Memory cluster signals to block micro-op dispatch for any rea= son", .topic =3D "other", }, - .alias_str =3D "event=3D0x9,period=3D0x30d40,umask=3D0x20", }; =20 static const struct perf_pmu_test_event eist_trans =3D { @@ -96,7 +88,6 @@ static const struct perf_pmu_test_event eist_trans =3D { .desc =3D "Number of Enhanced Intel SpeedStep(R) Technology (EIST) trans= itions", .topic =3D "other", }, - .alias_str =3D "event=3D0x3a,period=3D0x30d40", }; =20 static const struct perf_pmu_test_event l3_cache_rd =3D { @@ -108,7 +99,6 @@ static const struct perf_pmu_test_event l3_cache_rd =3D { .long_desc =3D "Attributable Level 3 cache access, read", .topic =3D "cache", }, - .alias_str =3D "event=3D0x40", .alias_long_desc =3D "Attributable Level 3 cache access, read", }; =20 @@ -130,7 +120,6 @@ static const struct perf_pmu_test_event uncore_hisi_ddr= c_flux_wcmd =3D { .topic =3D "uncore", .pmu =3D "hisi_sccl,ddrc", }, - .alias_str =3D "event=3D0x2", .matching_pmu =3D "hisi_sccl1_ddrc2", }; =20 @@ -142,7 +131,6 @@ static const struct perf_pmu_test_event unc_cbo_xsnp_re= sponse_miss_eviction =3D { .topic =3D "uncore", .pmu =3D "uncore_cbox", }, - .alias_str =3D "event=3D0x22,umask=3D0x81", .matching_pmu =3D "uncore_cbox_0", }; =20 @@ -154,7 +142,6 @@ static const struct perf_pmu_test_event uncore_hyphen = =3D { .topic =3D "uncore", .pmu =3D "uncore_cbox", }, - .alias_str =3D "event=3D0xe0", .matching_pmu =3D "uncore_cbox_0", }; =20 @@ -166,7 +153,6 @@ static const struct perf_pmu_test_event uncore_two_hyph= =3D { .topic =3D "uncore", .pmu =3D "uncore_cbox", }, - .alias_str =3D "event=3D0xc0", .matching_pmu =3D "uncore_cbox_0", }; =20 @@ -178,7 +164,6 @@ static const struct perf_pmu_test_event uncore_hisi_l3c= _rd_hit_cpipe =3D { .topic =3D "uncore", .pmu =3D "hisi_sccl,l3c", }, - .alias_str =3D "event=3D0x7", .matching_pmu =3D "hisi_sccl3_l3c7", }; =20 @@ -190,7 +175,6 @@ static const struct perf_pmu_test_event uncore_imc_free= _running_cache_miss =3D { .topic =3D "uncore", .pmu =3D "uncore_imc_free_running", }, - .alias_str =3D "event=3D0x12", .matching_pmu =3D "uncore_imc_free_running_0", }; =20 @@ -202,7 +186,6 @@ static const struct perf_pmu_test_event uncore_imc_cach= e_hits =3D { .topic =3D "uncore", .pmu =3D "uncore_imc", }, - .alias_str =3D "event=3D0x34", .matching_pmu =3D "uncore_imc_0", }; =20 @@ -226,7 +209,6 @@ static const struct perf_pmu_test_event sys_ddr_pmu_wri= te_cycles =3D { .pmu =3D "uncore_sys_ddr_pmu", .compat =3D "v8", }, - .alias_str =3D "event=3D0x2b", .matching_pmu =3D "uncore_sys_ddr_pmu0", }; =20 @@ -239,7 +221,6 @@ static const struct perf_pmu_test_event sys_ccn_pmu_rea= d_cycles =3D { .pmu =3D "uncore_sys_ccn_pmu", .compat =3D "0x01", }, - .alias_str =3D "config=3D0x2c", .matching_pmu =3D "uncore_sys_ccn_pmu4", }; =20 @@ -252,7 +233,6 @@ static const struct perf_pmu_test_event sys_cmn_pmu_hnf= _cache_miss =3D { .pmu =3D "uncore_sys_cmn_pmu", .compat =3D "(434|436|43c|43a).*", }, - .alias_str =3D "eventid=3D0x1,type=3D0x5", .matching_pmu =3D "uncore_sys_cmn_pmu0", }; =20 @@ -374,9 +354,9 @@ static int compare_alias_to_test_event(struct pmu_event= _info *alias, return -1; } =20 - if (!is_same(alias->str, test_event->alias_str)) { + if (!is_same(alias->str, test_event->event.event)) { pr_debug("testing aliases PMU %s: mismatched str, %s vs %s\n", - pmu_name, alias->str, test_event->alias_str); + pmu_name, alias->str, test_event->event.event); return -1; } =20 diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index c219e3ffae65..cc677d9b2d5a 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -40,6 +40,7 @@ static int get_config_terms(const struct parse_events_ter= ms *head_config, struct list_head *head_terms); static int parse_events_terms__copy(const struct parse_events_terms *src, struct parse_events_terms *dest); +static int parse_events_terms__to_strbuf(const struct parse_events_terms *= terms, struct strbuf *sb); =20 const struct event_symbol event_symbols_hw[PERF_COUNT_HW_MAX] =3D { [PERF_COUNT_HW_CPU_CYCLES] =3D { @@ -2849,7 +2850,7 @@ void parse_events_terms__delete(struct parse_events_t= erms *terms) free(terms); } =20 -int parse_events_terms__to_strbuf(const struct parse_events_terms *terms, = struct strbuf *sb) +static int parse_events_terms__to_strbuf(const struct parse_events_terms *= terms, struct strbuf *sb) { struct parse_events_term *term; bool first =3D true; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index c498d896badf..34a5ec21d5e8 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -199,7 +199,6 @@ void parse_events_terms__delete(struct parse_events_ter= ms *terms); void parse_events_terms__init(struct parse_events_terms *terms); void parse_events_terms__exit(struct parse_events_terms *terms); int parse_events_terms(struct parse_events_terms *terms, const char *str, = FILE *input); -int parse_events_terms__to_strbuf(const struct parse_events_terms *terms, = struct strbuf *sb); =20 struct parse_events_modifier { u8 precise; /* Number of repeated 'p' for precision. */ diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 5a291f1380ed..ddcd4918832d 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -67,8 +67,8 @@ struct perf_pmu_alias { * json events. */ char *topic; - /** @terms: Owned list of the original parsed parameters. */ - struct parse_events_terms terms; + /** @terms: Owned copy of the event terms. */ + char *terms; /** * @pmu_name: The name copied from the json struct pmu_event. This can * differ from the PMU name as it won't have suffixes. @@ -429,7 +429,7 @@ static void perf_pmu_free_alias(struct perf_pmu_alias *= alias) zfree(&alias->long_desc); zfree(&alias->topic); zfree(&alias->pmu_name); - parse_events_terms__exit(&alias->terms); + zfree(&alias->terms); free(alias); } =20 @@ -537,8 +537,8 @@ static int update_alias(const struct pmu_event *pe, assign_str(pe->name, "topic", &data->alias->topic, pe->topic); data->alias->per_pkg =3D pe->perpkg; if (pe->event) { - parse_events_terms__exit(&data->alias->terms); - ret =3D parse_events_terms(&data->alias->terms, pe->event, /*input=3D*/N= ULL); + zfree(&data->alias->terms); + data->alias->terms =3D strdup(pe->event); } if (!ret && pe->unit) { char *unit; @@ -590,7 +590,6 @@ static int perf_pmu__new_alias(struct perf_pmu *pmu, co= nst char *name, if (!alias) return -ENOMEM; =20 - parse_events_terms__init(&alias->terms); alias->scale =3D 1.0; alias->unit[0] =3D '\0'; alias->per_pkg =3D perpkg; @@ -615,11 +614,16 @@ static int perf_pmu__new_alias(struct perf_pmu *pmu, = const char *name, if (ret) return ret; =20 - ret =3D parse_events_terms(&alias->terms, val, val_fd); - if (ret) { - pr_err("Cannot parse alias %s: %d\n", val, ret); - free(alias); - return ret; + if (!val_fd) { + alias->terms =3D strdup(val); + } else { + size_t line_len; + + ret =3D getline(&alias->terms, &line_len, val_fd) < 0 ? -errno : 0; + if (ret) { + pr_err("Failed to read alias %s\n", name); + return ret; + } } =20 alias->name =3D strdup(name); @@ -767,29 +771,21 @@ static int pmu_aliases_parse_eager(struct perf_pmu *p= mu, int sysfs_fd) return ret; } =20 -static int pmu_alias_terms(struct perf_pmu_alias *alias, int err_loc, stru= ct list_head *terms) +static int pmu_alias_terms(struct perf_pmu_alias *alias, struct list_head = *terms) { - struct parse_events_term *term, *cloned; - struct parse_events_terms clone_terms; - - parse_events_terms__init(&clone_terms); - list_for_each_entry(term, &alias->terms.terms, list) { - int ret =3D parse_events_term__clone(&cloned, term); + struct parse_events_terms alias_terms; + int ret; =20 - if (ret) { - parse_events_terms__exit(&clone_terms); - return ret; - } - /* - * Weak terms don't override command line options, - * which we don't want for implicit terms in aliases. - */ - cloned->weak =3D true; - cloned->err_term =3D cloned->err_val =3D err_loc; - list_add_tail(&cloned->list, &clone_terms.terms); + parse_events_terms__init(&alias_terms); + ret =3D parse_events_terms(&alias_terms, alias->terms, /*input=3D*/NULL); + if (ret) { + pr_err("Cannot parse '%s' terms '%s': %d\n", + alias->name, alias->terms, ret); + parse_events_terms__exit(&alias_terms); + return ret; } - list_splice_init(&clone_terms.terms, terms); - parse_events_terms__exit(&clone_terms); + list_splice_init(&alias_terms.terms, terms); + parse_events_terms__exit(&alias_terms); return 0; } =20 @@ -1813,10 +1809,10 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, str= uct parse_events_terms *head_ alias =3D pmu_find_alias(pmu, term); if (!alias) continue; - ret =3D pmu_alias_terms(alias, term->err_term, &term->list); + ret =3D pmu_alias_terms(alias, &term->list); if (ret) { parse_events_error__handle(err, term->err_term, - strdup("Failure to duplicate terms"), + strdup("Failed to parse terms"), NULL); return ret; } @@ -2035,18 +2031,37 @@ static int sub_non_neg(int a, int b) static char *format_alias(char *buf, int len, const struct perf_pmu *pmu, const struct perf_pmu_alias *alias, bool skip_duplicate_pmus) { + struct parse_events_terms terms; struct parse_events_term *term; + int ret, used; size_t pmu_name_len =3D pmu_deduped_name_len(pmu, pmu->name, skip_duplicate_pmus); - int used =3D snprintf(buf, len, "%.*s/%s", (int)pmu_name_len, pmu->name, = alias->name); =20 - list_for_each_entry(term, &alias->terms.terms, list) { + /* Paramemterized events have the parameters shown. */ + if (strstr(alias->terms, "=3D?")) { + /* No parameters. */ + snprintf(buf, len, "%.*s/%s/", (int)pmu_name_len, pmu->name, alias->name= ); + return buf; + } + + parse_events_terms__init(&terms); + ret =3D parse_events_terms(&terms, alias->terms, /*input=3D*/NULL); + if (ret) { + pr_err("Failure to parse '%s' terms '%s': %d\n", + alias->name, alias->terms, ret); + parse_events_terms__exit(&terms); + snprintf(buf, len, "%.*s/%s/", (int)pmu_name_len, pmu->name, alias->name= ); + return buf; + } + used =3D snprintf(buf, len, "%.*s/%s", (int)pmu_name_len, pmu->name, alia= s->name); + + list_for_each_entry(term, &terms.terms, list) { if (term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_STR) used +=3D snprintf(buf + used, sub_non_neg(len, used), ",%s=3D%s", term->config, term->val.str); } - + parse_events_terms__exit(&terms); if (sub_non_neg(len, used) > 0) { buf[used] =3D '/'; used++; @@ -2069,7 +2084,6 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, bo= ol skip_duplicate_pmus, .event_type_desc =3D "Kernel PMU event", }; int ret =3D 0; - struct strbuf sb; struct hashmap_entry *entry; size_t bkt; =20 @@ -2080,7 +2094,6 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, bo= ol skip_duplicate_pmus, if (perf_pmu__is_drm(pmu)) return drm_pmu__for_each_event(pmu, state, cb); =20 - strbuf_init(&sb, /*hint=3D*/ 0); pmu_aliases_parse(pmu); pmu_add_cpu_aliases(pmu); hashmap__for_each_entry(pmu->aliases, entry, bkt) { @@ -2115,16 +2128,14 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, = bool skip_duplicate_pmus, info.desc =3D event->desc; info.long_desc =3D event->long_desc; info.encoding_desc =3D buf + buf_used; - parse_events_terms__to_strbuf(&event->terms, &sb); buf_used +=3D snprintf(buf + buf_used, sizeof(buf) - buf_used, - "%.*s/%s/", (int)pmu_name_len, info.pmu_name, sb.buf) + 1; + "%.*s/%s/", (int)pmu_name_len, info.pmu_name, event->terms) + 1; + info.str =3D event->terms; info.topic =3D event->topic; - info.str =3D sb.buf; info.deprecated =3D event->deprecated; ret =3D cb(state, &info); if (ret) goto out; - strbuf_setlen(&sb, /*len=3D*/ 0); } if (pmu->selectable) { info.name =3D buf; @@ -2140,7 +2151,6 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, bo= ol skip_duplicate_pmus, ret =3D cb(state, &info); } out: - strbuf_release(&sb); return ret; } =20 @@ -2588,10 +2598,21 @@ const char *perf_pmu__name_from_config(struct perf_= pmu *pmu, u64 config) hashmap__for_each_entry(pmu->aliases, entry, bkt) { struct perf_pmu_alias *event =3D entry->pvalue; struct perf_event_attr attr =3D {.config =3D 0,}; + struct parse_events_terms terms; + int ret; =20 - int ret =3D perf_pmu__config(pmu, &attr, &event->terms, /*apply_hardcode= d=3D*/true, - /*err=3D*/NULL); + parse_events_terms__init(&terms); + ret =3D parse_events_terms(&terms, event->terms, /*input=3D*/NULL); + if (ret) { + pr_debug("Failed to parse '%s' terms '%s': %d\n", + event->name, event->terms, ret); + parse_events_terms__exit(&terms); + continue; + } + ret =3D perf_pmu__config(pmu, &attr, &terms, /*apply_hardcoded=3D*/true, + /*err=3D*/NULL); =20 + parse_events_terms__exit(&terms); if (ret =3D=3D 0 && config =3D=3D attr.config) return event->name; } --=20 2.51.0.384.g4c02a37b29-goog