1. 10 10月, 2019 1 次提交
  2. 09 10月, 2019 3 次提交
  3. 07 10月, 2019 1 次提交
  4. 26 9月, 2019 2 次提交
    • A
      perf evlist: Fix access of freed id arrays · 7834fa94
      Andi Kleen 提交于
      I'm not fully sure if this is the correct fix, but without this I get
      crashes on more complex perf stat metric usages. The problem is that
      part of the state gets freed when a weak group fails, but then is later
      still used. Just don't free the ids, we're going to reuse them anyways
      on the weak group retry.
      
      For example:
      
        % perf stat -M IpB,IpCall,IpTB,IPC,Retiring_SMT,Frontend_Bound_SMT,Kernel_Utilization,CPU_Utilization --metric-only -a -I 1000 sleep 2
      
        crashes and gives in valgrind:
      
        =21527== Invalid write of size 8
        ==21527==    at 0x4EE582: hlist_add_head (list.h:644)
        ==21527==    by 0x4EFD3C: perf_evlist__id_hash (evlist.c:477)
        ==21527==    by 0x4EFD99: perf_evlist__id_add (evlist.c:483)
        ==21527==    by 0x4EFF15: perf_evlist__id_add_fd (evlist.c:524)
        ==21527==    by 0x4FC693: store_evsel_ids (evsel.c:2969)
        ==21527==    by 0x4FC76C: perf_evsel__store_ids (evsel.c:2986)
        ==21527==    by 0x450DA7: __run_perf_stat (builtin-stat.c:519)
        ==21527==    by 0x451285: run_perf_stat (builtin-stat.c:636)
        ==21527==    by 0x454619: cmd_stat (builtin-stat.c:1966)
        ==21527==    by 0x4D557D: run_builtin (perf.c:310)
        ==21527==    by 0x4D57EA: handle_internal_command (perf.c:362)
        ==21527==    by 0x4D5931: run_argv (perf.c:406)
        ==21527==  Address 0x12e3f008 is 104 bytes inside a block of size 2,056 free'd
        ==21527==    at 0x4839A0C: free (vg_replace_malloc.c:540)
        ==21527==    by 0x627139: xyarray__delete (xyarray.c:32)
        ==21527==    by 0x4F6BE4: perf_evsel__free_id (evsel.c:1253)
        ==21527==    by 0x4FA11F: evsel__close (evsel.c:1994)
        ==21527==    by 0x4F30A3: perf_evlist__reset_weak_group (evlist.c:1783)
        ==21527==    by 0x450B47: __run_perf_stat (builtin-stat.c:466)
        ==21527==    by 0x451285: run_perf_stat (builtin-stat.c:636)
        ==21527==    by 0x454619: cmd_stat (builtin-stat.c:1966)
        ==21527==    by 0x4D557D: run_builtin (perf.c:310)
        ==21527==    by 0x4D57EA: handle_internal_command (perf.c:362)
        ==21527==    by 0x4D5931: run_argv (perf.c:406)
        ==21527==    by 0x4D5CAE: main (perf.c:531)
        ==21527==  Block was alloc'd at
        ==21527==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
        ==21527==    by 0x627024: zalloc (zalloc.c:8)
        ==21527==    by 0x627088: xyarray__new (xyarray.c:10)
        ==21527==    by 0x4F6B20: perf_evsel__alloc_id (evsel.c:1237)
        ==21527==    by 0x4FC74E: perf_evsel__store_ids (evsel.c:2983)
        ==21527==    by 0x450DA7: __run_perf_stat (builtin-stat.c:519)
        ==21527==    by 0x451285: run_perf_stat (builtin-stat.c:636)
        ==21527==    by 0x454619: cmd_stat (builtin-stat.c:1966)
        ==21527==    by 0x4D557D: run_builtin (perf.c:310)
        ==21527==    by 0x4D57EA: handle_internal_command (perf.c:362)
        ==21527==    by 0x4D5931: run_argv (perf.c:406)
        ==21527==    by 0x4D5CAE: main (perf.c:531)
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Link: http://lore.kernel.org/lkml/20190923233339.25326-1-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7834fa94
    • A
      perf evlist: Remove unused perf_evlist__fprintf() method · bd704620
      Arnaldo Carvalho de Melo 提交于
      Ditch it, noone is using it, one more stdio.h include in a hot header.
      
      Fix the fallout in parse-events.y, where we end up using a FILE pointer,
      I think due to YYDEBUG being set and in some places, like Amazon Linux 1
      we don't get stdio.h included by luck, like in most other places, add a
      explicit stdio.h include directive.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-37k5q0lhdbo2hvvfbnnzn7og@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bd704620
  5. 25 9月, 2019 27 次提交
  6. 20 9月, 2019 1 次提交
  7. 01 9月, 2019 2 次提交
  8. 30 8月, 2019 1 次提交
  9. 29 8月, 2019 2 次提交
    • A
      perf evlist: Use unshare(CLONE_FS) in sb threads to let setns(CLONE_NEWNS) work · b397f846
      Arnaldo Carvalho de Melo 提交于
      When we started using a thread to catch the PERF_RECORD_BPF_EVENT meta
      data events to then ask the kernel for further info (BTF, etc) for BPF
      programs shortly after they get loaded, we forgot to use
      unshare(CLONE_FS) as was done in:
      
        868a8329 ("perf top: Support lookup of symbols in other mount namespaces.")
      
      Do it so that we can enter the namespaces to read the build-ids at the
      end of a 'perf record' session for the DSOs that had hits.
      
      Before:
      
      Starting a 'stress-ng --cpus 8' inside a container and then, outside the
      container running:
      
        # perf record -a --namespaces sleep 5
        # perf buildid-list | grep stress-ng
        #
      
      We would end up with a 'perf.data' file that had no entry in its
      build-id table for the /usr/bin/stress-ng binary inside the container
      that got tons of PERF_RECORD_SAMPLEs.
      
      After:
      
        # perf buildid-list | grep stress-ng
        f2ed02c68341183a124b9b0f6e2e6c493c465b29 /usr/bin/stress-ng
        #
      
      Then its just a matter of making sure that that binary debuginfo package
      gets available in a place that 'perf report' will look at build-id keyed
      ELF files, which, in my case, on a f30 notebook, was a matter of
      installing the debuginfo file for the distro used in the container,
      fedora 31:
      
        # rpm -ivh http://fedora.c3sl.ufpr.br/linux/development/31/Everything/x86_64/debug/tree/Packages/s/stress-ng-debuginfo-0.07.29-10.fc31.x86_64.rpm
      
      Then, because perf currently looks for those debuginfo files (richer ELF
      symtab) inside that namespace (look at the setns calls):
      
        openat(AT_FDCWD, "/proc/self/ns/mnt", O_RDONLY) = 137
        openat(AT_FDCWD, "/proc/13169/ns/mnt", O_RDONLY) = 139
        setns(139, CLONE_NEWNS)                 = 0
        stat("/usr/bin/stress-ng", {st_mode=S_IFREG|0755, st_size=3065416, ...}) = 0
        openat(AT_FDCWD, "/usr/bin/stress-ng", O_RDONLY) = 140
        fcntl(140, F_GETFD)                     = 0
        fstat(140, {st_mode=S_IFREG|0755, st_size=3065416, ...}) = 0
        mmap(NULL, 3065416, PROT_READ, MAP_PRIVATE, 140, 0) = 0x7ff2fdc5b000
        munmap(0x7ff2fdc5b000, 3065416)         = 0
        close(140)                              = 0
        stat("stress-ng-0.07.29-10.fc31.x86_64.debug", 0x7fff45d71260) = -1 ENOENT (No such file or directory)
        stat("/usr/bin/stress-ng-0.07.29-10.fc31.x86_64.debug", 0x7fff45d71260) = -1 ENOENT (No such file or directory)
        stat("/usr/bin/.debug/stress-ng-0.07.29-10.fc31.x86_64.debug", 0x7fff45d71260) = -1 ENOENT (No such file or directory)
        stat("/usr/lib/debug/usr/bin/stress-ng-0.07.29-10.fc31.x86_64.debug", 0x7fff45d71260) = -1 ENOENT (No such file or directory)
        stat("/root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29", 0x7fff45d711e0) = -1 ENOENT (No such file or directory)
      
      To only then go back to the "host" namespace to look just in the users's
      ~/.debug cache:
      
        setns(137, CLONE_NEWNS)                 = 0
        chdir("/root")                          = 0
        close(137)                              = 0
        close(139)                              = 0
        stat("/root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf", 0x7fff45d732e0) = -1 ENOENT (No such file or directory)
      
      It continues to fail to resolve symbols:
      
        # perf report | grep stress-ng | head -5
           9.50%  stress-ng-cpu    stress-ng    [.] 0x0000000000021ac1
           8.58%  stress-ng-cpu    stress-ng    [.] 0x0000000000021ab4
           8.51%  stress-ng-cpu    stress-ng    [.] 0x0000000000021489
           7.17%  stress-ng-cpu    stress-ng    [.] 0x00000000000219b6
           3.93%  stress-ng-cpu    stress-ng    [.] 0x0000000000021478
        #
      
      To overcome that we use:
      
        # perf buildid-cache -v --add /usr/lib/debug/usr/bin/stress-ng-0.07.29-10.fc31.x86_64.debug
        Adding f2ed02c68341183a124b9b0f6e2e6c493c465b29 /usr/lib/debug/usr/bin/stress-ng-0.07.29-10.fc31.x86_64.debug: Ok
        #
        # ls -la /root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf
        -rw-r--r--. 3 root root 2401184 Jul 27 07:03 /root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf
        # file /root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf
        /root/.debug/.build-id/f2/ed02c68341183a124b9b0f6e2e6c493c465b29/elf: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter \004, BuildID[sha1]=f2ed02c68341183a124b9b0f6e2e6c493c465b29, for GNU/Linux 3.2.0, with debug_info, not stripped, too many notes (256)
        #
      
      Now it finally works:
      
        # perf report | grep stress-ng | head -5
          23.59%  stress-ng-cpu    stress-ng    [.] ackermann
          23.33%  stress-ng-cpu    stress-ng    [.] is_prime
          17.36%  stress-ng-cpu    stress-ng    [.] stress_cpu_sieve
           6.08%  stress-ng-cpu    stress-ng    [.] stress_cpu_correlate
           3.55%  stress-ng-cpu    stress-ng    [.] queens_try
        #
      
      I'll make sure that it looks for the build-id keyed files in both the
      "host" namespace (the namespace the user running 'perf record' was a the
      time of the recording) and in the container namespace, as it shouldn't
      matter where a content based key lookup finds the ELF file to use in
      resolving symbols, etc.
      Reported-by: NKarl Rister <krister@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stanislav Fomichev <sdf@google.com>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Fixes: 657ee553 ("perf evlist: Introduce side band thread")
      Link: https://lkml.kernel.org/n/tip-g79k0jz41adiaeuqud742t2l@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b397f846
    • A
      perf evlist: Remove needless util.h from evlist.h · 2da39f1c
      Arnaldo Carvalho de Melo 提交于
      There is no need for that util/util.h include there and, remove it,
      pruning the include tree, fix the fallout by adding necessary headers to
      places that were getting needed includes indirectly from evlist.h ->
      util.h.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-s9f7uve8wvykr5itcm7m7d8q@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2da39f1c