]> git.ipfire.org Git - thirdparty/linux.git/commit
perf parse-events: Refactor get_config_terms() to remove macros
authorJames Clark <james.clark@linaro.org>
Wed, 14 Jan 2026 15:57:13 +0000 (15:57 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 15 Jan 2026 02:13:36 +0000 (23:13 -0300)
commit159ca97cd97ce8cc65364fee37319823b5ffb5bd
tree6241a8400a02d2d59d94b206c42444f42d18ab2a
parentbac74dcbd48b5b441e47841fd0fe507c7b0bcbaf
perf parse-events: Refactor get_config_terms() to remove macros

The ADD_CONFIG_TERM() macros build the __type argument out of a partial
EVSEL__CONFIG_TERM_x enum name. This means that they can't be called
from a function where __type is a variable and it's also impossible to
grep the codebase to find usages of these enums as they're never typed
in full.

Fix this by removing the macros and replacing them with an
add_config_term() function. It seems the main reason these existed in
the first place was to avoid type punning and to write to a specific
field in the union, but the same thing can be achieved with a single
write to a u64 'val' field.

Running the Perf tests with "-fsanitize=undefined -fno-sanitize-recover"
results in no new issues as a result of this change.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evsel_config.h
tools/perf/util/parse-events.c