]> Git Repo - J-linux.git/commitdiff
Merge tag 'perf-tools-for-v6.4-3-2023-05-06' of git://git.kernel.org/pub/scm/linux...
authorLinus Torvalds <[email protected]>
Sun, 7 May 2023 18:32:18 +0000 (11:32 -0700)
committerLinus Torvalds <[email protected]>
Sun, 7 May 2023 18:32:18 +0000 (11:32 -0700)
Pull perf tool updates from Arnaldo Carvalho de Melo:
 "Third version of perf tool updates, with the build problems with with
  using a 'vmlinux.h' generated from the main build fixed, and the bpf
  skeleton build disabled by default.

  Build:

   - Require libtraceevent to build, one can disable it using
     NO_LIBTRACEEVENT=1.

     It is required for tools like 'perf sched', 'perf kvm', 'perf
     trace', etc.

     libtraceevent is available in most distros so installing
     'libtraceevent-devel' should be a one-time event to continue
     building perf as usual.

     Using NO_LIBTRACEEVENT=1 produces tooling that is functional and
     sufficient for lots of users not interested in those libtraceevent
     dependent features.

   - Allow Python support in 'perf script' when libtraceevent isn't
     linked, as not all features requires it, for instance Intel PT does
     not use tracepoints.

   - Error if the python interpreter needed for jevents to work isn't
     available and NO_JEVENTS=1 isn't set, preventing a build without
     support for JSON vendor events, which is a rare but possible
     condition. The two check error messages:

        $(error ERROR: No python interpreter needed for jevents generation. Install python or build with NO_JEVENTS=1.)
        $(error ERROR: Python interpreter needed for jevents generation too old (older than 3.6). Install a newer python or build with NO_JEVENTS=1.)

   - Make libbpf 1.0 the minimum required when building with out of
     tree, distro provided libbpf.

   - Use libsdtc++'s and LLVM's libcxx's __cxa_demangle, a portable C++
     demangler, add 'perf test' entry for it.

   - Make binutils libraries opt in, as distros disable building with it
     due to licensing, they were used for C++ demangling, for instance.

   - Switch libpfm4 to opt-out rather than opt-in, if libpfm-devel (or
     equivalent) isn't installed, we'll just have a build warning:

       Makefile.config:1144: libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev

   - Add a feature test for scandirat(), that is not implemented so far
     in musl and uclibc, disabling features that need it, such as
     scanning for tracepoints in /sys/kernel/tracing/events.

  perf BPF filters:

   - New feature where BPF can be used to filter samples, for instance:

      $ sudo ./perf record -e cycles --filter 'period > 1000' true
      $ sudo ./perf script
           perf-exec 2273949 546850.708501:       5029 cycles:  ffffffff826f9e25 finish_wait+0x5 ([kernel.kallsyms])
           perf-exec 2273949 546850.708508:      32409 cycles:  ffffffff826f9e25 finish_wait+0x5 ([kernel.kallsyms])
           perf-exec 2273949 546850.708526:     143369 cycles:  ffffffff82b4cdbf xas_start+0x5f ([kernel.kallsyms])
           perf-exec 2273949 546850.708600:     372650 cycles:  ffffffff8286b8f7 __pagevec_lru_add+0x117 ([kernel.kallsyms])
           perf-exec 2273949 546850.708791:     482953 cycles:  ffffffff829190de __mod_memcg_lruvec_state+0x4e ([kernel.kallsyms])
                true 2273949 546850.709036:     501985 cycles:  ffffffff828add7c tlb_gather_mmu+0x4c ([kernel.kallsyms])
                true 2273949 546850.709292:     503065 cycles:      7f2446d97c03 _dl_map_object_deps+0x973 (/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)

   - In addition to 'period' (PERF_SAMPLE_PERIOD), the other
     PERF_SAMPLE_ can be used for filtering, and also some other sample
     accessible values, from tools/perf/Documentation/perf-record.txt:

        Essentially the BPF filter expression is:

        <term> <operator> <value> (("," | "||") <term> <operator> <value>)*

     The <term> can be one of:
        ip, id, tid, pid, cpu, time, addr, period, txn, weight, phys_addr,
        code_pgsz, data_pgsz, weight1, weight2, weight3, ins_lat, retire_lat,
        p_stage_cyc, mem_op, mem_lvl, mem_snoop, mem_remote, mem_lock,
        mem_dtlb, mem_blk, mem_hops

     The <operator> can be one of:
        ==, !=, >, >=, <, <=, &

     The <value> can be one of:
        <number> (for any term)
        na, load, store, pfetch, exec (for mem_op)
        l1, l2, l3, l4, cxl, io, any_cache, lfb, ram, pmem (for mem_lvl)
        na, none, hit, miss, hitm, fwd, peer (for mem_snoop)
        remote (for mem_remote)
        na, locked (for mem_locked)
        na, l1_hit, l1_miss, l2_hit, l2_miss, any_hit, any_miss, walk, fault (for mem_dtlb)
        na, by_data, by_addr (for mem_blk)
        hops0, hops1, hops2, hops3 (for mem_hops)

  perf lock contention:

   - Show lock type with address.

   - Track and show mmap_lock, siglock and per-cpu rq_lock with address.
     This is done for mmap_lock by following the current->mm pointer:

      $ sudo ./perf lock con -abl -- sleep 10
       contended   total wait     max wait     avg wait            address   symbol
       ...
           16344    312.30 ms      2.22 ms     19.11 us   ffff8cc702595640
           17686    310.08 ms      1.49 ms     17.53 us   ffff8cc7025952c0
               3     84.14 ms     45.79 ms     28.05 ms   ffff8cc78114c478   mmap_lock
            3557     76.80 ms     68.75 us     21.59 us   ffff8cc77ca3af58
               1     68.27 ms     68.27 ms     68.27 ms   ffff8cda745dfd70
               9     54.53 ms      7.96 ms      6.06 ms   ffff8cc7642a48b8   mmap_lock
           14629     44.01 ms     60.00 us      3.01 us   ffff8cc7625f9ca0
            3481     42.63 ms    140.71 us     12.24 us   ffffffff937906ac   vmap_area_lock
           16194     38.73 ms     42.15 us      2.39 us   ffff8cd397cbc560
              11     38.44 ms     10.39 ms      3.49 ms   ffff8ccd6d12fbb8   mmap_lock
               1      5.43 ms      5.43 ms      5.43 ms   ffff8cd70018f0d8
            1674      5.38 ms    422.93 us      3.21 us   ffffffff92e06080   tasklist_lock
             581      4.51 ms    130.68 us      7.75 us   ffff8cc9b1259058
               5      3.52 ms      1.27 ms    703.23 us   ffff8cc754510070
             112      3.47 ms     56.47 us     31.02 us   ffff8ccee38b3120
             381      3.31 ms     73.44 us      8.69 us   ffffffff93790690   purge_vmap_area_lock
             255      3.19 ms     36.35 us     12.49 us   ffff8d053ce30c80

   - Update default map size to 16384.

   - Allocate single letter option -M for --map-nr-entries, as it is
     proving being frequently used.

   - Fix struct rq lock access for older kernels with BPF's CO-RE
     (Compile once, run everywhere).

   - Fix problems found with MSAn.

  perf report/top:

   - Add inline information when using --call-graph=fp or lbr, as was
     already done to the --call-graph=dwarf callchain mode.

   - Improve the 'srcfile' sort key performance by really using an
     optimization introduced in 6.2 for the 'srcline' sort key that
     avoids calling addr2line for comparision with each sample.

  perf sched:

   - Make 'perf sched latency/map/replay' to use "sched:sched_waking"
     instead of "sched:sched_waking", consistent with 'perf record'
     since d566a9c2d482 ("perf sched: Prefer sched_waking event when it
     exists").

  perf ftrace:

   - Make system wide the default target for latency subcommand, run the
     following command then generate some network traffic and press
     control+C:

       # perf ftrace latency -T __kfree_skb
     ^C
         DURATION     |      COUNT | GRAPH                                          |
          0 - 1    us |         27 | #############                                  |
          1 - 2    us |         22 | ###########                                    |
          2 - 4    us |          8 | ####                                           |
          4 - 8    us |          5 | ##                                             |
          8 - 16   us |         24 | ############                                   |
         16 - 32   us |          2 | #                                              |
         32 - 64   us |          1 |                                                |
         64 - 128  us |          0 |                                                |
        128 - 256  us |          0 |                                                |
        256 - 512  us |          0 |                                                |
        512 - 1024 us |          0 |                                                |
          1 - 2    ms |          0 |                                                |
          2 - 4    ms |          0 |                                                |
          4 - 8    ms |          0 |                                                |
          8 - 16   ms |          0 |                                                |
         16 - 32   ms |          0 |                                                |
         32 - 64   ms |          0 |                                                |
         64 - 128  ms |          0 |                                                |
        128 - 256  ms |          0 |                                                |
        256 - 512  ms |          0 |                                                |
        512 - 1024 ms |          0 |                                                |
          1 - ...   s |          0 |                                                |
       #

  perf top:

   - Add --branch-history (LBR: Last Branch Record) option, just like
     already available for 'perf record'.

   - Fix segfault in thread__comm_len() where thread->comm was being
     used outside thread->comm_lock.

  perf annotate:

   - Allow configuring objdump and addr2line in ~/.perfconfig., so that
     you can use alternative binaries, such as llvm's.

  perf kvm:

   - Add TUI mode for 'perf kvm stat report'.

  Reference counting:

   - Add reference count checking infrastructure to check for use after
     free, done to the 'cpumap', 'namespaces', 'maps' and 'map' structs,
     more to come.

     To build with it use -DREFCNT_CHECKING=1 in the make command line
     to build tools/perf. Documented at:

       https://perf.wiki.kernel.org/index.php/Reference_Count_Checking

   - The above caught, for instance, fix, present in this series:

        - Fix maps use after put in 'perf test "Share thread maps"':

          'maps' is copied from leader, but the leader is put on line 79
          and then 'maps' is used to read the reference count below - so
          a use after put, with the put of maps happening within
          thread__put.

     Fixed by reversing the order of puts so that the leader is put
     last.

   - Also several fixes were made to places where reference counts were
     not being held.

   - Make this one of the tests in 'make -C tools/perf build-test' to
     regularly build test it and to make sure no direct access to the
     reference counted structs are made, doing that via accessors to
     check the validity of the struct pointer.

  ARM64:

   - Fix 'perf report' segfault when filtering coresight traces by
     sparse lists of CPUs.

   - Add support for 'simd' as a sort field for 'perf report', to show
     ARM's NEON SIMD's predicate flags: "partial" and "empty".

  arm64 vendor events:

   - Add N1 metrics.

  Intel vendor events:

   - Add graniterapids, grandridge and sierraforrest events.

   - Refresh events for: alderlake, aldernaken, broadwell, broadwellde,
     broadwellx, cascadelakx, haswell, haswellx, icelake, icelakex,
     jaketown, meteorlake, knightslanding, sandybridge, sapphirerapids,
     silvermont, skylake, tigerlake and westmereep-dp

   - Refresh metrics for alderlake-n, broadwell, broadwellde,
     broadwellx, haswell, haswellx, icelakex, ivybridge, ivytown and
     skylakex.

  perf stat:

   - Implement --topdown using JSON metrics.

   - Add TopdownL1 JSON metric as a default if present, but disable it
     for now for some Intel hybrid architectures, a series of patches
     addressing this is being reviewed and will be submitted for v6.5.

   - Use metrics for --smi-cost.

   - Update topdown documentation.

  Vendor events (JSON) infrastructure:

   - Add support for computing and printing metric threshold values. For
     instance, here is one found in thesapphirerapids json file:

       {
           "BriefDescription": "Percentage of cycles spent in System Management Interrupts.",
           "MetricExpr": "((msr@aperf@ - cycles) / msr@aperf@ if msr@smi@ > 0 else 0)",
           "MetricGroup": "smi",
           "MetricName": "smi_cycles",
           "MetricThreshold": "smi_cycles > 0.1",
           "ScaleUnit": "100%"
       },

   - Test parsing metric thresholds with the fake PMU in 'perf test
     pmu-events'.

   - Support for printing metric thresholds in 'perf list'.

   - Add --metric-no-threshold option to 'perf stat'.

   - Add rand (reverse and) and has_pmem (optane memory) support to
     metrics.

   - Sort list of input files to avoid depending on the order from
     readdir() helping in obtaining reproducible builds.

  S/390:

   - Add common metrics: - CPI (cycles per instruction), prbstate (ratio
     of instructions executed in problem state compared to total number
     of instructions), l1mp (Level one instruction and data cache misses
     per 100 instructions).

   - Add cache metrics for z13, z14, z15 and z16.

   - Add metric for TLB and cache.

  ARM:

   - Add raw decoding for SPE (Statistical Profiling Extension) v1.3 MTE
     (Memory Tagging Extension) and MOPS (Memory Operations) load/store.

  Intel PT hardware tracing:

   - Add event type names UINTR (User interrupt delivered) and UIRET
     (Exiting from user interrupt routine), documented in table 32-50
     "CFE Packet Type and Vector Fields Details" in the Intel Processor
     Trace chapter of The Intel SDM Volume 3 version 078.

   - Add support for new branch instructions ERETS and ERETU.

   - Fix CYC timestamps after standalone CBR

  ARM CoreSight hardware tracing:

   - Allow user to override timestamp and contextid settings.

   - Fix segfault in dso lookup.

   - Fix timeless decode mode detection.

   - Add separate decode paths for timeless and per-thread modes.

  auxtrace:

   - Fix address filter entire kernel size.

  Miscellaneous:

   - Fix use-after-free and unaligned bugs in the PLT handling routines.

   - Use zfree() to reduce chances of use after free.

   - Add missing 0x prefix for addresses printed in hexadecimal in 'perf
     probe'.

   - Suppress massive unsupported target platform errors in the unwind
     code.

   - Fix return incorrect build_id size in elf_read_build_id().

   - Fix 'perf scripts intel-pt-events.py' IPC output for Python 2 .

   - Add missing new parameter in kfree_skb tracepoint to the python
     scripts using it.

   - Add 'perf bench syscall fork' benchmark.

   - Add support for printing PERF_MEM_LVLNUM_UNC (Uncached access) in
     'perf mem'.

   - Fix wrong size expectation for perf test 'Setup struct
     perf_event_attr' caused by the patch adding
     perf_event_attr::config3.

   - Fix some spelling mistakes"

* tag 'perf-tools-for-v6.4-3-2023-05-06' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (365 commits)
  Revert "perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL"
  Revert "perf build: Warn for BPF skeletons if endian mismatches"
  perf metrics: Fix SEGV with --for-each-cgroup
  perf bpf skels: Stop using vmlinux.h generated from BTF, use subset of used structs + CO-RE
  perf stat: Separate bperf from bpf_profiler
  perf test record+probe_libc_inet_pton: Fix call chain match on x86_64
  perf test record+probe_libc_inet_pton: Fix call chain match on s390
  perf tracepoint: Fix memory leak in is_valid_tracepoint()
  perf cs-etm: Add fix for coresight trace for any range of CPUs
  perf build: Fix unescaped # in perf build-test
  perf unwind: Suppress massive unsupported target platform errors
  perf script: Add new parameter in kfree_skb tracepoint to the python scripts using it
  perf script: Print raw ip instead of binary offset for callchain
  perf symbols: Fix return incorrect build_id size in elf_read_build_id()
  perf list: Modify the warning message about scandirat(3)
  perf list: Fix memory leaks in print_tracepoint_events()
  perf lock contention: Rework offset calculation with BPF CO-RE
  perf lock contention: Fix struct rq lock access
  perf stat: Disable TopdownL1 on hybrid
  perf stat: Avoid SEGV on counter->name
  ...

1  2 
tools/perf/Makefile.config
tools/perf/arch/common.c
tools/perf/check-headers.sh
tools/perf/util/annotate.c
tools/perf/util/env.c
tools/perf/util/symbol-elf.c

index c0a208f9b67bccd8b67fe7a66ffd45dbb449b237,ee467af49b62d00a05b646def947f69b4f5dba51..4884520f954f4b2a6659705918d8673451139065
@@@ -38,7 -38,7 +38,7 @@@ ifneq ($(NO_SYSCALL_TABLE),1
        NO_SYSCALL_TABLE := 0
      endif
    else
 -    ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390 mips))
 +    ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390 mips loongarch))
        NO_SYSCALL_TABLE := 0
      endif
    endif
@@@ -80,12 -80,6 +80,12 @@@ ifeq ($(SRCARCH),arm64
    LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
  endif
  
 +ifeq ($(SRCARCH),loongarch)
 +  NO_PERF_REGS := 0
 +  CFLAGS += -I$(OUTPUT)arch/loongarch/include/generated
 +  LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64
 +endif
 +
  ifeq ($(SRCARCH),riscv)
    NO_PERF_REGS := 0
  endif
@@@ -113,7 -107,7 +113,7 @@@ endi
  # Disable it on all other architectures in case libdw unwind
  # support is detected in system. Add supported architectures
  # to the check.
 -ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv))
 +ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390 csky riscv loongarch))
    NO_LIBDW_DWARF_UNWIND := 1
  endif
  
@@@ -135,7 -129,7 +135,7 @@@ ende
  ifdef LIBUNWIND_DIR
    LIBUNWIND_CFLAGS  = -I$(LIBUNWIND_DIR)/include
    LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
 -  LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64
 +  LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 loongarch
    $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch)))
  endif
  
@@@ -234,6 -228,7 +234,7 @@@ ifndef DEBU
  endif
  
  ifeq ($(DEBUG),0)
+ CORE_CFLAGS += -DNDEBUG=1
  ifeq ($(CC_NO_CLANG), 0)
    CORE_CFLAGS += -O3
  else
@@@ -417,7 -412,6 +418,6 @@@ endi
  
  ifdef NO_LIBELF
    NO_DWARF := 1
-   NO_DEMANGLE := 1
    NO_LIBUNWIND := 1
    NO_LIBDW_DWARF_UNWIND := 1
    NO_LIBBPF := 1
@@@ -431,15 -425,7 +431,7 @@@ els
        LIBC_SUPPORT := 1
      endif
      ifeq ($(LIBC_SUPPORT),1)
-       msg := $(warning No libelf found. Disables 'probe' tool, jvmti and BPF support in 'perf record'. Please install libelf-dev, libelf-devel or elfutils-libelf-devel);
-       NO_LIBELF := 1
-       NO_DWARF := 1
-       NO_DEMANGLE := 1
-       NO_LIBUNWIND := 1
-       NO_LIBDW_DWARF_UNWIND := 1
-       NO_LIBBPF := 1
-       NO_JVMTI := 1
+       msg := $(error ERROR: No libelf found. Disables 'probe' tool, jvmti and BPF support. Please install libelf-dev, libelf-devel, elfutils-libelf-devel or build with NO_LIBELF=1.)
      else
        ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)
          ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)
    endif # libelf support
  endif # NO_LIBELF
  
- ifeq ($(feature-glibc), 1)
-   CFLAGS += -DHAVE_GLIBC_SUPPORT
- endif
  ifeq ($(feature-libaio), 1)
    ifndef NO_AIO
      CFLAGS += -DHAVE_AIO_SUPPORT
@@@ -495,6 -477,10 +483,10 @@@ ifdef NO_DWAR
    NO_LIBDW_DWARF_UNWIND := 1
  endif
  
+ ifeq ($(feature-scandirat), 1)
+   CFLAGS += -DHAVE_SCANDIRAT_SUPPORT
+ endif
  ifeq ($(feature-sched_getcpu), 1)
    CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
  endif
@@@ -571,54 -557,17 +563,17 @@@ ifndef NO_LIBEL
  
        # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status
        $(call feature_check,libbpf)
        ifdef LIBBPF_DYNAMIC
          ifeq ($(feature-libbpf), 1)
            EXTLIBS += -lbpf
            $(call detected,CONFIG_LIBBPF_DYNAMIC)
-           $(call feature_check,libbpf-btf__load_from_kernel_by_id)
-           ifeq ($(feature-libbpf-btf__load_from_kernel_by_id), 1)
-             CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
-           endif
-           $(call feature_check,libbpf-bpf_prog_load)
-           ifeq ($(feature-libbpf-bpf_prog_load), 1)
-             CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
-           endif
-           $(call feature_check,libbpf-bpf_object__next_program)
-           ifeq ($(feature-libbpf-bpf_object__next_program), 1)
-             CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
-           endif
-           $(call feature_check,libbpf-bpf_object__next_map)
-           ifeq ($(feature-libbpf-bpf_object__next_map), 1)
-             CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
-           endif
-           $(call feature_check,libbpf-bpf_program__set_insns)
-           ifeq ($(feature-libbpf-bpf_program__set_insns), 1)
-             CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
-           else
-             dummy := $(error Error: libbpf devel library needs to be >= 0.8.0 to build with LIBBPF_DYNAMIC, update or build statically with the version that comes with the kernel sources);
-           endif
-           $(call feature_check,libbpf-btf__raw_data)
-           ifeq ($(feature-libbpf-btf__raw_data), 1)
-             CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
-           endif
-           $(call feature_check,libbpf-bpf_map_create)
-           ifeq ($(feature-libbpf-bpf_map_create), 1)
-             CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
-           endif
          else
-           dummy := $(error Error: No libbpf devel library found, please install libbpf-devel);
+           dummy := $(error Error: No libbpf devel library found or older than v1.0, please install/update libbpf-devel);
          endif
        else
          # Libbpf will be built as a static library from tools/lib/bpf.
        LIBBPF_STATIC := 1
-       CFLAGS += -DHAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
-         CFLAGS += -DHAVE_LIBBPF_BPF_PROG_LOAD
-         CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_PROGRAM
-         CFLAGS += -DHAVE_LIBBPF_BPF_OBJECT__NEXT_MAP
-         CFLAGS += -DHAVE_LIBBPF_BPF_PROGRAM__SET_INSNS
-         CFLAGS += -DHAVE_LIBBPF_BTF__RAW_DATA
-         CFLAGS += -DHAVE_LIBBPF_BPF_MAP_CREATE
        endif
      endif
  
@@@ -802,10 -751,6 +757,6 @@@ ifndef NO_LIBCRYPT
    endif
  endif
  
- ifdef NO_NEWT
-   NO_SLANG=1
- endif
  ifndef NO_SLANG
    ifneq ($(feature-libslang), 1)
      ifneq ($(feature-libslang-include-subdir), 1)
@@@ -922,19 -867,17 +873,17 @@@ endi
  ifneq ($(NO_JEVENTS),1)
    NO_JEVENTS := 0
    ifndef PYTHON
-     $(warning No python interpreter disabling jevent generation)
-     NO_JEVENTS := 1
+     $(error ERROR: No python interpreter needed for jevents generation. Install python or build with NO_JEVENTS=1.)
    else
      # jevents.py uses f-strings present in Python 3.6 released in Dec. 2016.
      JEVENTS_PYTHON_GOOD := $(shell $(PYTHON) -c 'import sys;print("1" if(sys.version_info.major >= 3 and sys.version_info.minor >= 6) else "0")' 2> /dev/null)
      ifneq ($(JEVENTS_PYTHON_GOOD), 1)
-       $(warning Python interpreter too old (older than 3.6) disabling jevent generation)
-       NO_JEVENTS := 1
+       $(error ERROR: Python interpreter needed for jevents generation too old (older than 3.6). Install a newer python or build with NO_JEVENTS=1.)
      endif
    endif
  endif
  
- ifndef NO_LIBBFD
+ ifdef BUILD_NONDISTRO
    ifeq ($(feature-libbfd), 1)
      EXTLIBS += -lbfd -lopcodes
    else
      $(call feature_check,disassembler-init-styled)
    endif
  
+   CFLAGS += -DHAVE_LIBBFD_SUPPORT
+   CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
    ifeq ($(feature-libbfd-buildid), 1)
      CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
    else
    endif
  endif
  
- ifdef NO_DEMANGLE
-   CFLAGS += -DNO_DEMANGLE
- else
-   ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
-     EXTLIBS += -liberty
-   else
+ ifndef NO_DEMANGLE
+   $(call feature_check,cxa-demangle)
+   ifeq ($(feature-cxa-demangle), 1)
+     EXTLIBS += -lstdc++
+     CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
+     CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
+   endif
+   ifdef BUILD_NONDISTRO
      ifeq ($(filter -liberty,$(EXTLIBS)),)
        $(call feature_check,cplus-demangle)
-       # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
-       # or any of 'bfd iberty z' trinity
        ifeq ($(feature-cplus-demangle), 1)
          EXTLIBS += -liberty
-       else
-         msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
-         CFLAGS += -DNO_DEMANGLE
        endif
      endif
+     ifneq ($(filter -liberty,$(EXTLIBS)),)
+       CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
+       CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
+     endif
    endif
-   ifneq ($(filter -liberty,$(EXTLIBS)),)
-     CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
-   endif
- endif
- ifneq ($(filter -lbfd,$(EXTLIBS)),)
-   CFLAGS += -DHAVE_LIBBFD_SUPPORT
  endif
  
  ifndef NO_ZLIB
@@@ -1188,7 -1125,7 +1131,7 @@@ ifdef LIBCLANGLLV
    endif
  endif
  
- ifdef LIBPFM4
+ ifndef NO_LIBPFM4
    $(call feature_check,libpfm4)
    ifeq ($(feature-libpfm4), 1)
      CFLAGS += -DHAVE_LIBPFM
      $(call detected,CONFIG_LIBPFM4)
    else
      msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev);
-     NO_LIBPFM4 := 1
    endif
  endif
  
@@@ -1215,7 -1151,7 +1157,7 @@@ ifneq ($(NO_LIBTRACEEVENT),1
      CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)
      $(call detected,CONFIG_LIBTRACEEVENT)
    else
-     dummy := $(warning Warning: libtraceevent is missing limiting functionality, please install libtraceevent-dev/libtraceevent-devel)
+     dummy := $(error ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel or build with NO_LIBTRACEEVENT=1)
    endif
  
    $(call feature_check,libtracefs)
diff --combined tools/perf/arch/common.c
index cfe63dfab03a1d4558cd9af59eb26bdda2174699,28ac099979289d7d689a2735805ebb40cb43b52b..b951374bc49d52523ae23f1dfe9863bbef1ed3ef
@@@ -51,7 -51,9 +51,7 @@@ const char *const s390_triplets[] = 
  
  const char *const sh_triplets[] = {
        "sh-unknown-linux-gnu-",
 -      "sh64-unknown-linux-gnu-",
        "sh-linux-gnu-",
 -      "sh64-linux-gnu-",
        NULL
  };
  
@@@ -128,7 -130,7 +128,7 @@@ static int lookup_triplets(const char *
  }
  
  static int perf_env__lookup_binutils_path(struct perf_env *env,
-                                         const char *name, const char **path)
+                                         const char *name, char **path)
  {
        int idx;
        const char *arch = perf_env__arch(env), *cross_env;
@@@ -200,7 -202,7 +200,7 @@@ out_error
        return -1;
  }
  
- int perf_env__lookup_objdump(struct perf_env *env, const char **path)
+ int perf_env__lookup_objdump(struct perf_env *env, char **path)
  {
        /*
         * For live mode, env->arch will be NULL and we can use
index 9d6232f681ceefbd4757009fba51cccf106c6d47,e4a8b53486782c2a844ed43b8b059e372c749c98..6f831ee2f60f86f79ed7d6aaac5c477047eaa47c
@@@ -40,7 -40,6 +40,7 @@@ arch/x86/lib/x86-opcode-map.tx
  arch/x86/tools/gen-insn-attr-x86.awk
  arch/arm/include/uapi/asm/perf_regs.h
  arch/arm64/include/uapi/asm/perf_regs.h
 +arch/loongarch/include/uapi/asm/perf_regs.h
  arch/mips/include/uapi/asm/perf_regs.h
  arch/powerpc/include/uapi/asm/perf_regs.h
  arch/s390/include/uapi/asm/perf_regs.h
@@@ -53,7 -52,6 +53,6 @@@ arch/x86/include/uapi/asm/vmx.
  arch/powerpc/include/uapi/asm/kvm.h
  arch/s390/include/uapi/asm/kvm.h
  arch/s390/include/uapi/asm/kvm_perf.h
- arch/s390/include/uapi/asm/ptrace.h
  arch/s390/include/uapi/asm/sie.h
  arch/arm/include/uapi/asm/kvm.h
  arch/arm64/include/uapi/asm/kvm.h
index 0cc7710f32dab370b05860fb7d2b73cc04a15f2f,ca9f0add68f461e43b7f885dafa0d3ed8b0339c8..11992cfe271cf5f399342141b877c917890ceedb
@@@ -38,6 -38,7 +38,7 @@@
  #include <linux/bitops.h>
  #include <linux/kernel.h>
  #include <linux/string.h>
+ #include <linux/zalloc.h>
  #include <subcmd/parse-options.h>
  #include <subcmd/run-command.h>
  
  
  #include <linux/ctype.h>
  
- struct annotation_options annotation__default_options = {
-       .use_offset     = true,
-       .jump_arrows    = true,
-       .annotate_src   = true,
-       .offset_level   = ANNOTATION__OFFSET_JUMP_TARGETS,
-       .percent_type   = PERCENT_PERIOD_LOCAL,
- };
  static regex_t         file_lineno;
  
  static struct ins_ops *ins__find(struct arch *arch, const char *name);
@@@ -149,7 -142,6 +142,7 @@@ static int arch__associate_ins_ops(stru
  #include "arch/arm/annotate/instructions.c"
  #include "arch/arm64/annotate/instructions.c"
  #include "arch/csky/annotate/instructions.c"
 +#include "arch/loongarch/annotate/instructions.c"
  #include "arch/mips/annotate/instructions.c"
  #include "arch/x86/annotate/instructions.c"
  #include "arch/powerpc/annotate/instructions.c"
@@@ -212,13 -204,6 +205,13 @@@ static struct arch architectures[] = 
                        .comment_char = '#',
                },
        },
 +      {
 +              .name = "loongarch",
 +              .init = loongarch__annotate_init,
 +              .objdump = {
 +                      .comment_char = '#',
 +              },
 +      },
  };
  
  static void ins__delete(struct ins_operands *ops)
@@@ -288,7 -273,7 +281,7 @@@ find_target
        target.addr = map__objdump_2mem(map, ops->target.addr);
  
        if (maps__find_ams(ms->maps, &target) == 0 &&
-           map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
+           map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
                ops->target.sym = target.ms.sym;
  
        return 0;
@@@ -392,8 -377,8 +385,8 @@@ static int jump__parse(struct arch *arc
        }
  
        target.addr = map__objdump_2mem(map, ops->target.addr);
-       start = map->unmap_ip(map, sym->start),
-       end = map->unmap_ip(map, sym->end);
+       start = map__unmap_ip(map, sym->start);
+       end = map__unmap_ip(map, sym->end);
  
        ops->target.outside = target.addr < start || target.addr > end;
  
         * the symbol searching and disassembly should be done.
         */
        if (maps__find_ams(ms->maps, &target) == 0 &&
-           map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
+           map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
                ops->target.sym = target.ms.sym;
  
        if (!ops->target.outside) {
@@@ -897,7 -882,7 +890,7 @@@ static int __symbol__inc_addr_samples(s
        unsigned offset;
        struct sym_hist *h;
  
-       pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, ms->map->unmap_ip(ms->map, addr));
+       pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map__unmap_ip(ms->map, addr));
  
        if ((addr < sym->start || addr >= sym->end) &&
            (addr != sym->end || sym->start != sym->end)) {
@@@ -1024,13 -1009,13 +1017,13 @@@ int addr_map_symbol__account_cycles(str
        if (start &&
                (start->ms.sym == ams->ms.sym ||
                 (ams->ms.sym &&
-                  start->addr == ams->ms.sym->start + ams->ms.map->start)))
+                 start->addr == ams->ms.sym->start + map__start(ams->ms.map))))
                saddr = start->al_addr;
        if (saddr == 0)
                pr_debug2("BB with bad start: addr %"PRIx64" start %"PRIx64" sym %"PRIx64" saddr %"PRIx64"\n",
                        ams->addr,
                        start ? start->addr : 0,
-                       ams->ms.sym ? ams->ms.sym->start + ams->ms.map->start : 0,
+                       ams->ms.sym ? ams->ms.sym->start + map__start(ams->ms.map) : 0,
                        saddr);
        err = symbol__account_cycles(ams->al_addr, saddr, ams->ms.sym, cycles);
        if (err)
@@@ -1601,7 -1586,7 +1594,7 @@@ static void delete_last_nop(struct symb
  
  int symbol__strerror_disassemble(struct map_symbol *ms, int errnum, char *buf, size_t buflen)
  {
-       struct dso *dso = ms->map->dso;
+       struct dso *dso = map__dso(ms->map);
  
        BUG_ON(buflen == 0);
  
@@@ -1707,8 -1692,7 +1700,7 @@@ fallback
  
                mutex_lock(&dso->lock);
                if (access(filename, R_OK) && errno == ENOENT && dso->nsinfo) {
-                       char *new_name = filename_with_chroot(dso->nsinfo->pid,
-                                                             filename);
+                       char *new_name = dso__filename_with_chroot(dso, filename);
                        if (new_name) {
                                strlcpy(filename, new_name, filename_size);
                                free(new_name);
@@@ -1743,7 -1727,7 +1735,7 @@@ static int symbol__disassemble_bpf(stru
        struct map *map = args->ms.map;
        struct perf_bpil *info_linear;
        struct disassemble_info info;
-       struct dso *dso = map->dso;
+       struct dso *dso = map__dso(map);
        int pc = 0, count, sub_id;
        struct btf *btf = NULL;
        char tpath[PATH_MAX];
@@@ -1897,7 -1881,7 +1889,7 @@@ symbol__disassemble_bpf_image(struct sy
        if (dl)
                annotation_line__add(&dl->al, &notes->src->source);
  
-       free(args->line);
+       zfree(&args->line);
        return 0;
  }
  
@@@ -1966,7 -1950,7 +1958,7 @@@ static int symbol__disassemble(struct s
  {
        struct annotation_options *opts = args->options;
        struct map *map = args->ms.map;
-       struct dso *dso = map->dso;
+       struct dso *dso = map__dso(map);
        char *command;
        FILE *file;
        char symfs_filename[PATH_MAX];
                return err;
  
        pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__,
-                symfs_filename, sym->name, map->unmap_ip(map, sym->start),
-                map->unmap_ip(map, sym->end));
+                symfs_filename, sym->name, map__unmap_ip(map, sym->start),
+                map__unmap_ip(map, sym->end));
  
        pr_debug("annotating [%p] %30s : [%p] %30s\n",
                 dso, dso->long_name, sym, sym->name);
@@@ -2411,7 -2395,7 +2403,7 @@@ int symbol__annotate_printf(struct map_
  {
        struct map *map = ms->map;
        struct symbol *sym = ms->sym;
-       struct dso *dso = map->dso;
+       struct dso *dso = map__dso(map);
        char *filename;
        const char *d_filename;
        const char *evsel_name = evsel__name(evsel);
@@@ -2594,7 -2578,7 +2586,7 @@@ int map_symbol__annotation_dump(struct 
        }
  
        fprintf(fp, "%s() %s\nEvent: %s\n\n",
-               ms->sym->name, ms->map->dso->long_name, ev_name);
+               ms->sym->name, map__dso(ms->map)->long_name, ev_name);
        symbol__annotate_fprintf2(ms->sym, fp, opts);
  
        fclose(fp);
@@@ -2820,7 -2804,7 +2812,7 @@@ static void annotation__calc_lines(stru
                if (percent_max <= 0.5)
                        continue;
  
-               al->path = get_srcline(map->dso, notes->start + al->offset, NULL,
+               al->path = get_srcline(map__dso(map), notes->start + al->offset, NULL,
                                       false, true, notes->start + al->offset);
                insert_source_line(&tmp_root, al, opts);
        }
@@@ -2839,7 -2823,7 +2831,7 @@@ static void symbol__calc_lines(struct m
  int symbol__tty_annotate2(struct map_symbol *ms, struct evsel *evsel,
                          struct annotation_options *opts)
  {
-       struct dso *dso = ms->map->dso;
+       struct dso *dso = map__dso(ms->map);
        struct symbol *sym = ms->sym;
        struct rb_root source_line = RB_ROOT;
        struct hists *hists = evsel__hists(evsel);
  int symbol__tty_annotate(struct map_symbol *ms, struct evsel *evsel,
                         struct annotation_options *opts)
  {
-       struct dso *dso = ms->map->dso;
+       struct dso *dso = map__dso(ms->map);
        struct symbol *sym = ms->sym;
        struct rb_root source_line = RB_ROOT;
        int err;
@@@ -3222,7 -3206,23 +3214,23 @@@ static int annotation__config(const cha
        } else if (!strcmp(var, "annotate.use_offset")) {
                opt->use_offset = perf_config_bool("use_offset", value);
        } else if (!strcmp(var, "annotate.disassembler_style")) {
-               opt->disassembler_style = value;
+               opt->disassembler_style = strdup(value);
+               if (!opt->disassembler_style) {
+                       pr_err("Not enough memory for annotate.disassembler_style\n");
+                       return -1;
+               }
+       } else if (!strcmp(var, "annotate.objdump")) {
+               opt->objdump_path = strdup(value);
+               if (!opt->objdump_path) {
+                       pr_err("Not enough memory for annotate.objdump\n");
+                       return -1;
+               }
+       } else if (!strcmp(var, "annotate.addr2line")) {
+               symbol_conf.addr2line_path = strdup(value);
+               if (!symbol_conf.addr2line_path) {
+                       pr_err("Not enough memory for annotate.addr2line\n");
+                       return -1;
+               }
        } else if (!strcmp(var, "annotate.demangle")) {
                symbol_conf.demangle = perf_config_bool("demangle", value);
        } else if (!strcmp(var, "annotate.demangle_kernel")) {
        return 0;
  }
  
+ void annotation_options__init(struct annotation_options *opt)
+ {
+       memset(opt, 0, sizeof(*opt));
+       /* Default values. */
+       opt->use_offset = true;
+       opt->jump_arrows = true;
+       opt->annotate_src = true;
+       opt->offset_level = ANNOTATION__OFFSET_JUMP_TARGETS;
+       opt->percent_type = PERCENT_PERIOD_LOCAL;
+ }
+ void annotation_options__exit(struct annotation_options *opt)
+ {
+       zfree(&opt->disassembler_style);
+       zfree(&opt->objdump_path);
+ }
  void annotation_config__init(struct annotation_options *opt)
  {
        perf_config(annotation__config, opt);
diff --combined tools/perf/util/env.c
index 0d5d40cb997b6a4f28e072f1e5e12c95c5555f69,ebf2e801c275f97455fcb5f5d5d943fcc823d138..4a4fdad820d602d5282da48277fd9ec89ced0ad0
@@@ -149,7 -149,7 +149,7 @@@ static void perf_env__purge_bpf(struct 
                node = rb_entry(next, struct bpf_prog_info_node, rb_node);
                next = rb_next(&node->rb_node);
                rb_erase(&node->rb_node, root);
-               free(node->info_linear);
+               zfree(&node->info_linear);
                free(node);
        }
  
@@@ -435,8 -435,6 +435,8 @@@ static const char *normalize_arch(char 
                return "mips";
        if (!strncmp(arch, "sh", 2) && isdigit(arch[2]))
                return "sh";
 +      if (!strncmp(arch, "loongarch", 9))
 +              return "loongarch";
  
        return arch;
  }
index 554289fd6df9ad86846da27ccfb2987260a967f9,ca75285aa6560d9cc0c800fac7c2f38da648c6f6..b2ed9cc5226551e64a01bb59d7df4671f24388b7
@@@ -12,6 -12,7 +12,7 @@@
  #include "maps.h"
  #include "symbol.h"
  #include "symsrc.h"
+ #include "demangle-cxx.h"
  #include "demangle-ocaml.h"
  #include "demangle-java.h"
  #include "demangle-rust.h"
  #include <symbol/kallsyms.h>
  #include <internal/lib.h>
  
+ #ifdef HAVE_LIBBFD_SUPPORT
+ #define PACKAGE 'perf'
+ #include <bfd.h>
+ #endif
  #ifndef EM_AARCH64
  #define EM_AARCH64    183  /* ARM 64 bit */
  #endif
  
  typedef Elf64_Nhdr GElf_Nhdr;
  
- #ifndef DMGL_PARAMS
- #define DMGL_NO_OPTS     0              /* For readability... */
- #define DMGL_PARAMS      (1 << 0)       /* Include function args */
- #define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
- #endif
- #ifdef HAVE_LIBBFD_SUPPORT
- #define PACKAGE 'perf'
- #include <bfd.h>
- #else
- #ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
- extern char *cplus_demangle(const char *, int);
- static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
- {
-       return cplus_demangle(c, i);
- }
- #else
- #ifdef NO_DEMANGLE
- static inline char *bfd_demangle(void __maybe_unused *v,
-                                const char __maybe_unused *c,
-                                int __maybe_unused i)
- {
-       return NULL;
- }
- #endif
- #endif
- #endif
  
  #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
  static int elf_getphdrnum(Elf *elf, size_t *dst)
@@@ -213,7 -191,7 +191,7 @@@ Elf_Scn *elf_section_by_name(Elf *elf, 
        Elf_Scn *sec = NULL;
        size_t cnt = 1;
  
 -      /* Elf is corrupted/truncated, avoid calling elf_strptr. */
 +      /* ELF is corrupted/truncated, avoid calling elf_strptr. */
        if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL))
                return NULL;
  
@@@ -295,7 -273,6 +273,6 @@@ static bool want_demangle(bool is_kerne
  
  static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
  {
-       int demangle_flags = verbose > 0 ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
        char *demangled = NULL;
  
        /*
        if (!want_demangle(dso->kernel || kmodule))
            return demangled;
  
-       demangled = bfd_demangle(NULL, elf_name, demangle_flags);
+       demangled = cxx_demangle_sym(elf_name, verbose > 0, verbose > 0);
        if (demangled == NULL) {
                demangled = ocaml_demangle_sym(elf_name);
                if (demangled == NULL) {
@@@ -419,7 -396,7 +396,7 @@@ static bool get_ifunc_name(Elf *elf, st
  
  static void exit_rel(struct rel_info *ri)
  {
-       free(ri->sorted);
+       zfree(&ri->sorted);
  }
  
  static bool get_plt_sizes(struct dso *dso, GElf_Ehdr *ehdr, GElf_Shdr *shdr_plt,
@@@ -483,7 -460,7 +460,7 @@@ struct rela_dyn_info 
  
  static void exit_rela_dyn(struct rela_dyn_info *di)
  {
-       free(di->sorted);
+       zfree(&di->sorted);
  }
  
  static int cmp_offset(const void *a, const void *b)
@@@ -565,9 -542,12 +542,12 @@@ static u32 get_x86_64_plt_disp(const u
                n += 1;
        /* jmp with 4-byte displacement */
        if (p[n] == 0xff && p[n + 1] == 0x25) {
+               u32 disp;
                n += 2;
                /* Also add offset from start of entry to end of instruction */
-               return n + 4 + le32toh(*(const u32 *)(p + n));
+               memcpy(&disp, p + n, sizeof(disp));
+               return n + 4 + le32toh(disp);
        }
        return 0;
  }
@@@ -580,6 -560,7 +560,7 @@@ static bool get_plt_got_name(GElf_Shdr 
        const char *sym_name;
        char *demangled;
        GElf_Sym sym;
+       bool result;
        u32 disp;
  
        if (!di->sorted)
  
        snprintf(buf, buf_sz, "%s@plt", sym_name);
  
+       result = *sym_name;
        free(demangled);
  
-       return *sym_name;
+       return result;
  }
  
  static int dso__synthesize_plt_got_symbols(struct dso *dso, Elf *elf,
@@@ -903,7 -886,7 +886,7 @@@ static int elf_read_build_id(Elf *elf, 
                                size_t sz = min(size, descsz);
                                memcpy(bf, ptr, sz);
                                memset(bf + sz, 0, size - sz);
-                               err = descsz;
+                               err = sz;
                                break;
                        }
                }
@@@ -1371,17 -1354,21 +1354,21 @@@ static int dso__process_kernel_symbol(s
                 */
                if (*remap_kernel && dso->kernel && !kmodule) {
                        *remap_kernel = false;
-                       map->start = shdr->sh_addr + ref_reloc(kmap);
-                       map->end = map->start + shdr->sh_size;
-                       map->pgoff = shdr->sh_offset;
-                       map->map_ip = map__map_ip;
-                       map->unmap_ip = map__unmap_ip;
+                       map__set_start(map, shdr->sh_addr + ref_reloc(kmap));
+                       map__set_end(map, map__start(map) + shdr->sh_size);
+                       map__set_pgoff(map, shdr->sh_offset);
+                       map__set_map_ip(map, map__dso_map_ip);
+                       map__set_unmap_ip(map, map__dso_unmap_ip);
                        /* Ensure maps are correctly ordered */
                        if (kmaps) {
+                               int err;
                                map__get(map);
                                maps__remove(kmaps, map);
-                               maps__insert(kmaps, map);
+                               err = maps__insert(kmaps, map);
                                map__put(map);
+                               if (err)
+                                       return err;
                        }
                }
  
                 */
                if (*remap_kernel && kmodule) {
                        *remap_kernel = false;
-                       map->pgoff = shdr->sh_offset;
+                       map__set_pgoff(map, shdr->sh_offset);
                }
  
                *curr_mapp = map;
                u64 start = sym->st_value;
  
                if (kmodule)
-                       start += map->start + shdr->sh_offset;
+                       start += map__start(map) + shdr->sh_offset;
  
                curr_dso = dso__new(dso_name);
                if (curr_dso == NULL)
                        map__kmap(curr_map)->kmaps = kmaps;
  
                if (adjust_kernel_syms) {
-                       curr_map->start  = shdr->sh_addr + ref_reloc(kmap);
-                       curr_map->end    = curr_map->start + shdr->sh_size;
-                       curr_map->pgoff  = shdr->sh_offset;
+                       map__set_start(curr_map, shdr->sh_addr + ref_reloc(kmap));
+                       map__set_end(curr_map, map__start(curr_map) + shdr->sh_size);
+                       map__set_pgoff(curr_map, shdr->sh_offset);
                } else {
-                       curr_map->map_ip = curr_map->unmap_ip = identity__map_ip;
+                       map__set_map_ip(curr_map, identity__map_ip);
+                       map__set_unmap_ip(curr_map, identity__map_ip);
                }
                curr_dso->symtab_type = dso->symtab_type;
-               maps__insert(kmaps, curr_map);
+               if (maps__insert(kmaps, curr_map))
+                       return -1;
                /*
                 * Add it before we drop the reference to curr_map, i.e. while
                 * we still are sure to have a reference to this DSO via
                 * *curr_map->dso.
                 */
-               dsos__add(&kmaps->machine->dsos, curr_dso);
+               dsos__add(&maps__machine(kmaps)->dsos, curr_dso);
                /* kmaps already got it */
                map__put(curr_map);
                dso__set_loaded(curr_dso);
                *curr_mapp = curr_map;
                *curr_dsop = curr_dso;
        } else
-               *curr_dsop = curr_map->dso;
+               *curr_dsop = map__dso(curr_map);
  
        return 0;
  }
@@@ -1537,8 -1526,7 +1526,7 @@@ dso__load_sym_internal(struct dso *dso
                        if (strcmp(elf_name, kmap->ref_reloc_sym->name))
                                continue;
                        kmap->ref_reloc_sym->unrelocated_addr = sym.st_value;
-                       map->reloc = kmap->ref_reloc_sym->addr -
-                                    kmap->ref_reloc_sym->unrelocated_addr;
+                       map__set_reloc(map, kmap->ref_reloc_sym->addr - kmap->ref_reloc_sym->unrelocated_addr);
                        break;
                }
        }
         * attempted to prelink vdso to its virtual address.
         */
        if (dso__is_vdso(dso))
-               map->reloc = map->start - dso->text_offset;
+               map__set_reloc(map, map__start(map) - dso->text_offset);
  
        dso->adjust_symbols = runtime_ss->adjust_symbols || ref_reloc(kmap);
        /*
This page took 0.11454 seconds and 4 git commands to generate.