]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf pmu: Don't eagerly parse event terms
authorIan Rogers <irogers@google.com>
Sun, 5 Oct 2025 18:24:09 +0000 (11:24 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 15 Oct 2025 14:59:10 +0000 (23:59 +0900)
commit84bae3af20d0b6c5d23b4f7558c2eaa7d59c9157
treeb0ff69f86cbfdf71ba642fedfa7e28716e7f256a
parent4bb55de4ff03db3e8b204c9c804cef3cad29a271
perf pmu: Don't eagerly parse event terms

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 <tmricht@linux.ibm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/tests/pmu-events.c
tools/perf/util/parse-events.c
tools/perf/util/parse-events.h
tools/perf/util/pmu.c