From nobody Thu Oct 2 03:32:44 2025 Received: from mail-oa1-f73.google.com (mail-oa1-f73.google.com [209.85.160.73]) (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 0B92B312807 for ; Tue, 23 Sep 2025 22:33:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758666815; cv=none; b=NLOXiNkZCt0yKf42MNMvl4RBYLLPRBoEG0TLPUamzf/FRF09SB74mZMHzV1XMPyejL7CwjLiGWOYBvWP+W2LuaTugTWZsc6Slt4hoFe4MlucJZUFyo1sNrQpc7y3m8BpuwN289tYkrifLKdqpDk3infMgCrT/8wRmc78kl2zcu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758666815; c=relaxed/simple; bh=9U8Qkaut51IFpJiGPepgidw+gFVSykeXVGEwCAxdADI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=F3XE1lnLs8xrfSBBuJcKbBo3iCA3i5IfzxODi8a2mN/wBxjwsEN+7AEJsaG69KQzI+Omk37h1OW7oV0i0r2SNSjwAKUR2hpTuNkTS3S2vPjYxnLOBN/Z09GM3nEec2bhG16eh1IdtjMCraTYDcSQdzvZ8W6aE52hs1TlPRyIVQM= 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=XQWFWEvt; arc=none smtp.client-ip=209.85.160.73 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="XQWFWEvt" Received: by mail-oa1-f73.google.com with SMTP id 586e51a60fabf-35229d35e82so820069fac.2 for ; Tue, 23 Sep 2025 15:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1758666812; x=1759271612; 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=0ZXMJZTB+guKcD1xbFn0gN7kFBWjFPMzx8qjMl0pf+Q=; b=XQWFWEvt8vYRrimDgZO2pkmlBaIAu3aMVtwDCe6j2Aa9kPJXm0Gi6QjajnYLI0dkUx UdYRI2KhL/Wl1qT38Oi72gVzHmjKB3YuvDuINKxpWkvxiGopXsgl4WH7vibkx+yKTLVj QCRXmfgk1xqnKWuYlGKyW3DkwrSQsne9WPnJj+o01WG+QnyS7KSRFnXMdy+SNuoOs5Cl AADk4v0o6kqyDg8Au7tfGDteYQrwWNBAmUyeP0eNHybwGelnGDO0tCf+/LINsjSTjWM3 vNhUilWahKUxPKlard5B/6X0UVkxp2Nm04tPT2Jf0JqBrQmbO7OddGFBWWgZiiCFmtJ2 hbuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758666812; x=1759271612; 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=0ZXMJZTB+guKcD1xbFn0gN7kFBWjFPMzx8qjMl0pf+Q=; b=QCNWHaGnakxKHXD+BO5n4z/juW8PUiq1+taOclYMG2ITUIvIJrxe8YN0/xz+amebhT fTqcBr18AE7U1mmOt6JHGIzFRtLwvNKuWGKOo3mjBbRdchPVOnHvwdy51NhPV60xjTh+ PmYCp+To6s++wjQRWscL447UP6uWYCQ7ii0J3U/FwZ6zZsgPGoWT+mHVkiR+wSZ4+e9V MZZTDGld3iwQgsfv9JO4Ky7H64/Y86JFQq0xC13NDW4qs62EwWCNxrIOAHvhGI5xjkVQ eaK7iuXGNoliNV286sZALo6F/ylkJnwTxykZAimq+J5nkO9CzRhJo4D++b5tWxPpOibW jzcQ== X-Forwarded-Encrypted: i=1; AJvYcCVl5MXydRLTy3bQQMl5Qv4w+2trLKoe5qPew0GwSujw2HS7GypLxFOiOxdCE3yP65fMGeKvi1/KfQqfHp0=@vger.kernel.org X-Gm-Message-State: AOJu0YwIJtIxl7YhaP9BnW7OAE1xB93w5BpydY+5GlqISRLauE0bbZ7z rZTsBmmY81XFPP35t+mUvpnYHhHg5B0LpqnIzT03D+X/L6fQjbGKc26uZT72LIprPhI3iMEcpVK l3atr1igU6w== X-Google-Smtp-Source: AGHT+IHDmPvQP9y72FRag7C6x/ZfQtY3hGADwRqBIolqSG/ttyHpW7j2Y0F1bNlXSvM9Sn7ongVPnNxKUgtW X-Received: from oabgz15.prod.google.com ([2002:a05:6870:280f:b0:331:10b5:c8d3]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6870:d8d:b0:314:b6a6:6862 with SMTP id 586e51a60fabf-34c88545ce3mr2355145fac.48.1758666812126; Tue, 23 Sep 2025 15:33:32 -0700 (PDT) Date: Tue, 23 Sep 2025 15:32:51 -0700 In-Reply-To: <20250923223312.238185-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: <20250923223312.238185-1-irogers@google.com> X-Mailer: git-send-email 2.51.0.534.gc79095c0ca-goog Message-ID: <20250923223312.238185-8-irogers@google.com> Subject: [PATCH v6 07/28] 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, 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 particular 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%. Tested-by: Thomas Richter Signed-off-by: Ian Rogers --- 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 d5675471afc5..9ec1738a5a64 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 { @@ -2854,7 +2855,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 be8d2ac1e4e4..9c975bb09fe8 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.534.gc79095c0ca-goog