Skip to content

perf: Use e_machine and lazily compute symbols

Ian Rogers linux-perf-users linux-s390 lkml 10 versions – Applied

Status from this message: Thanks, applied to perf-tools-next, for v7.2.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v12 Latest19 patches 5 repliesApplied
  2. v1119 patches 0 repliesSuperseded
  3. v1018 patches 0 repliesSuperseded
Earlier versions · 7
VersionPostedPatchesRepliesStatus
v918 patches1 replySuperseded
v817 patches0 repliesSuperseded
v74 patches0 repliesSuperseded
v63 patches0 repliesSuperseded
v53 patches0 repliesSuperseded
v42 patches4 repliesSuperseded
v32 patches1 replySuperseded

Patches in v12 Applied

#Subject and filesSizeRepliesApplied
1/19perf env: Add perf_env__e_machine helper and use in perf_env__archtools/perf/util/env.c tools/perf/util/env.h tools/perf/util/header.c +1 more+282 -640 replies
2/19perf tests topology: Switch env->arch use to env->e_machinetools/perf/tests/topology.c+6 -20 replies
3/19perf env, dso, thread: Add _endian variants for e_machine helperstools/perf/util/dso.c tools/perf/util/dso.h tools/perf/util/env.c +3 more+108 -230 replies
4/19perf capstone: Determine architecture from e_machinetools/perf/util/capstone.c+88 -440 replies
5/19perf print_insn: Use e_machine for fallback IP length checktools/perf/util/print_insn.c tools/perf/util/print_insn.h+16 -90 replies
6/19perf symbol: Avoid use of machine__istools/perf/util/symbol.c+22 -60 replies
7/19perf machine: Use perf_env e_machine rather than archtools/perf/util/machine.c tools/perf/util/machine.h+18 -190 replies
8/19perf sample-raw: Use perf_env e_machine rather than archtools/perf/util/sample-raw.c tools/perf/util/sample-raw.h+16 -110 replies
9/19perf sort: Use perf_env e_machine rather than archtools/perf/util/sort.c+32 -260 replies
10/19perf arch common: Use perf_env e_machine rather than archtools/perf/arch/common.c+69 -230 replies
11/19perf header: In print_pmu_caps use perf_env e_machinetools/perf/util/header.c+4 -30 replies
12/19perf c2c: Use perf_env e_machine rather than archtools/perf/builtin-c2c.c+22 -180 replies
13/19perf lock-contention: Use perf_env e_machine rather than archtools/perf/util/lock-contention.c+3 -30 replies
14/19perf env: Refactor perf_env__arch_strerrnotools/perf/builtin-trace.c tools/perf/trace/beauty/Build tools/perf/trace/beauty/arch_errno_names.sh +2 more+58 -220 replies
15/19perf env: Remove unused perf_env__raw_archtools/perf/util/env.c tools/perf/util/env.h+0 -190 replies
16/19perf env: Add mutex to protect lazy environment initializationtools/perf/util/env.c tools/perf/util/env.h+8 -00 replies
17/19perf env: Add helper to lazily compute the os_releasetools/perf/util/data-convert-bt.c tools/perf/util/data-convert-json.c tools/perf/util/env.c +3 more+57 -100 replies
18/19perf symbol: Add setters for bitfields sharing a byte to avoid concurrent update issuestools/perf/builtin-inject.c tools/perf/builtin-kwork.c tools/perf/builtin-report.c +23 more+183 -800 replies
19/19perf symbol: Lazily compute idletools/perf/util/symbol-elf.c tools/perf/util/symbol.c tools/perf/util/symbol.h+100 -520 replies

Reviews trailers per patch

None of the 19 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNamhyung Kim
SeriesA-b
1/19
2/19
3/19
4/19
5/19
6/19
7/19
8/19
9/19
10/19
11/19
12/19
13/19
14/19
15/19
16/19
17/19
18/19
19/19

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v12 thread

Cover letter [PATCH v12 00/19] perf: Use e_machine and lazily compute symbols

Add a helper to perf_env to compute the e_machine if it is EM_NONE. Derive the value from the arch string if available. Similarly derive the arch string from the ELF machine if available, for consistency. This means perf's arch (machine type) is no longer determined by uname but set to match that of the perf ELF executable.

Migrate code away from strcmp on env->arch to using the e_machine comparisons that are more accurate and not prone to uname and other naming differences. While cleaning this up, also clean up the capstone initialization code to cover more architectures and to set the big endian flag based on ELF header information.

Refactor perf_env__arch_strerrno to take an e_machine instead of an architecture string, removing the HAVE_LIBTRACEEVENT dependency entirely and making it unconditionally available. The generated errno table includes fallback definitions for newer ELF machine constants to ensure compatibility with older host glibc versions.

Introduce a mutex in perf_env to safely protect lazy metadata setup, such as os_release or e_machine resolution, preventing concurrent initialization data races and memory leaks during multi-threaded profiling or symbol loading. Properly initialize stack-allocated perf_env instances to ensure safe mutex destruction.

Switch the idle computation to the point of use and lazily compute it, rather than computing it for every symbol. The current only user is perf top. At the point of use the perf_env is available and this can be used to make sure the idle function computation correctly accounts for architecture-specific and kernel-version-specific patterns. To prevent concurrent updates to shared symbol bitfield flags, migrate bitfield variables in struct symbol to C11 atomic flags.

Ian Rogers (19):
perf env: Add perf_env__e_machine helper and use in perf_env__arch perf tests topology: Switch env->arch use to env->e_machine perf env, dso, thread: Add _endian variants for e_machine helpers perf capstone: Determine architecture from e_machine perf print_insn: Use e_machine for fallback IP length check perf symbol: Avoid use of machine__is
perf machine: Use perf_env e_machine rather than arch perf sample-raw: Use perf_env e_machine rather than arch perf sort: Use perf_env e_machine rather than arch
perf arch common: Use perf_env e_machine rather than arch perf header: In print_pmu_caps use perf_env e_machine perf c2c: Use perf_env e_machine rather than arch
perf lock-contention: Use perf_env e_machine rather than arch perf env: Refactor perf_env__arch_strerrno
perf env: Remove unused perf_env__raw_arch
perf env: Add mutex to protect lazy environment initialization perf env: Add helper to lazily compute the os_release perf symbol: Add setters for bitfields sharing a byte to avoid
concurrent update issues
perf symbol: Lazily compute idle

 tools/perf/arch/common.c                      |  92 +++--
 tools/perf/builtin-c2c.c                      |  40 +-
 tools/perf/builtin-inject.c                   |  10 +-
 tools/perf/builtin-kwork.c                    |   2 +-
 tools/perf/builtin-report.c                   |   2 +-
 tools/perf/builtin-sched.c                    |   4 +-
 tools/perf/builtin-top.c                      |   7 +-
 tools/perf/builtin-trace.c                    |   7 +-
 tools/perf/tests/symbols.c                    |   2 +-
 tools/perf/tests/topology.c                   |   8 +-
 tools/perf/tests/vmlinux-kallsyms.c           |   2 +-
 tools/perf/trace/beauty/Build                 |   1 +
 tools/perf/trace/beauty/arch_errno_names.sh   |  53 ++-
 tools/perf/ui/browsers/annotate.c             |   2 +-
 tools/perf/ui/browsers/map.c                  |   4 +-
 tools/perf/util/annotate.c                    |   5 +-
 tools/perf/util/auxtrace.c                    |   6 +-
 tools/perf/util/callchain.c                   |   4 +-
 tools/perf/util/capstone.c                    | 132 ++++--
 tools/perf/util/data-convert-bt.c             |   2 +-
 tools/perf/util/data-convert-json.c           |   6 +-
 tools/perf/util/dlfilter.c                    |   2 +-
 tools/perf/util/dso.c                         |  19 +-
 tools/perf/util/dso.h                         |  14 +-
 tools/perf/util/env.c                         | 376 ++++++++++++++----
 tools/perf/util/env.h                         |  14 +-
 tools/perf/util/evsel_fprintf.c               |   6 +-
 tools/perf/util/header.c                      |  55 ++-
 tools/perf/util/intel-pt.c                    |   2 +-
 tools/perf/util/libdw.c                       |   2 +-
 tools/perf/util/lock-contention.c             |   6 +-
 tools/perf/util/machine.c                     |  37 +-
 tools/perf/util/machine.h                     |   2 -
 tools/perf/util/print_insn.c                  |  23 +-
 tools/perf/util/print_insn.h                  |   2 +
 tools/perf/util/probe-event.c                 |   4 +-
 tools/perf/util/sample-raw.c                  |  21 +-
 tools/perf/util/sample-raw.h                  |   6 +-
 .../util/scripting-engines/trace-event-perl.c |   2 +-
 .../scripting-engines/trace-event-python.c    |   4 +-
 tools/perf/util/session.c                     |  26 +-
 tools/perf/util/sort.c                        |  66 +--
 tools/perf/util/srcline.c                     |  10 +-
 tools/perf/util/symbol-elf.c                  |   5 +-
 tools/perf/util/symbol.c                      | 238 ++++++++---
 tools/perf/util/symbol.h                      |  80 +++-
 tools/perf/util/symbol_fprintf.c              |   4 +-
 tools/perf/util/thread.c                      |  58 ++-
 tools/perf/util/thread.h                      |  23 +-
 49 files changed, 1078 insertions(+), 420 deletions(-)
Signature · 1 line
2.54.0.929.g9b7fa37559-goog