1. 02 4月, 2022 1 次提交
    • I
      perf evlist: Rename cpus to user_requested_cpus · 0df6ade7
      Ian Rogers 提交于
      evlist contains cpus and all_cpus. all_cpus is the union of the cpu maps
      of all evsels.
      
      For non-task targets, cpus is set to be cpus requested from the command
      line, defaulting to all online cpus if no cpus are specified.
      
      For an uncore event, all_cpus may be just CPU 0 or every online CPU.
      
      This causes all_cpus to have fewer values than the cpus variable which
      is confusing given the 'all' in the name.
      
      To try to make the behavior clearer, rename cpus to user_requested_cpus
      and add comments on the two struct variables.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20220328232648.2127340-3-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0df6ade7
  2. 16 2月, 2022 2 次提交
  3. 11 2月, 2022 1 次提交
  4. 07 11月, 2021 1 次提交
  5. 17 9月, 2021 1 次提交
  6. 02 8月, 2021 1 次提交
  7. 10 7月, 2021 2 次提交
  8. 25 6月, 2021 1 次提交
    • J
      perf top: Add cgroup support for perf top (-G) · 51f38242
      Joshua Martinez 提交于
      Added callback option (-G) to support cgroups for 'perf top'.
      
      Added condition to make sure -cgroup and --all-cgroups aren't both enabled.
      
      Example:
      
        $perf top -e cycles -G system.slice/docker-6b95a5eb649c0d671eba3835f0d93973d05a088f3ae8602246bde37affb1ba3e.scope -a --stdio
      
         PerfTop:    3330 irqs/sec  kernel:68.2%  exact:  0.0% lost: 0/0 drop: 0/11075 [4000Hz cpu-clock],  (all, 4 CPUs)
         -------------------------------------------------------------------------------------------------------------------------------------------------------
      
          27.32%  [unknown]         [.] 0x00007f8ab7b69352
          11.44%  [kernel]          [k] 0xffffffff968cd657
           3.12%  [kernel]          [k] 0xffffffff96160e96
           2.63%  [kernel]          [k] 0xffffffff96160eb0
           1.96%  [kernel]          [k] 0xffffffff9615fcf6
           1.42%  [kernel]          [k] 0xffffffff964ddfc7
           1.09%  [kernel]          [k] 0xffffffff96160e90
           0.81%  [kernel]          [k] 0xffffffff96160eb3
           0.67%  [kernel]          [k] 0xffffffff9615fec1
           0.57%  [kernel]          [k] 0xffffffff961ee1d0
           0.53%  [unknown]         [.] 0x00007f8ab7b6666c
           0.53%  [kernel]          [k] 0xffffffff96160e64
           0.52%  [kernel]          [k] 0xffffffff9616c303
           0.51%  [kernel]          [k] 0xffffffffc08e7d50
           ...
      Signed-off-by: NJoshua Martinez <joshuamart@google.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: joshua martinez <joshuamart@google.com>
      Link: http://lore.kernel.org/lkml/20210616231829.3735671-1-joshuamart@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      51f38242
  9. 29 4月, 2021 1 次提交
  10. 24 3月, 2021 1 次提交
  11. 01 12月, 2020 5 次提交
  12. 30 11月, 2020 3 次提交
  13. 21 8月, 2020 1 次提交
    • T
      perf top: Skip side-band event setup if HAVE_LIBBPF_SUPPORT is not set · 0c5f1acc
      Tiezhu Yang 提交于
      When I execute 'perf top' without HAVE_LIBBPF_SUPPORT, there exists the
      following segmentation fault, skip the side-band event setup to fix it,
      this is similar with commit 1101c872 ("perf record: Skip side-band
      event setup if HAVE_LIBBPF_SUPPORT is not set").
      
        [yangtiezhu@linux perf]$ ./perf top
        <SNIP>
        perf: Segmentation fault
        Obtained 6 stack frames.
        ./perf(sighandler_dump_stack+0x5c) [0x12011b604]
        [0xffffffc010]
        ./perf(perf_mmap__read_init+0x3e) [0x1201feeae]
        ./perf() [0x1200d715c]
        /lib64/libpthread.so.0(+0xab9c) [0xffee10ab9c]
        /lib64/libc.so.6(+0x128f4c) [0xffedc08f4c]
        Segmentation fault
        [yangtiezhu@linux perf]$
      
      I use git bisect to find commit b38d85ef ("perf bpf: Decouple
      creating the evlist from adding the SB event") is the first bad commit,
      so also add the Fixes tag.
      
      Committer testing:
      
      First build perf explicitely disabling libbpf:
      
        $ make NO_LIBBPF=1 O=/tmp/build/perf -C tools/perf install-bin && perf test python
      
      Now make sure it isn't linked:
      
        $ perf -vv | grep -w bpf
                         bpf: [ OFF ]  # HAVE_LIBBPF_SUPPORT
        $
        $ nm ~/bin/perf | grep libbpf
        $
      
      And now try to run 'perf top':
      
        # perf top
        perf: Segmentation fault
        -------- backtrace --------
        perf[0x5bcd6d]
        /lib64/libc.so.6(+0x3ca6f)[0x7fd0f5a66a6f]
        perf(perf_mmap__read_init+0x1e)[0x5e1afe]
        perf[0x4cc468]
        /lib64/libpthread.so.0(+0x9431)[0x7fd0f645a431]
        /lib64/libc.so.6(clone+0x42)[0x7fd0f5b2b912]
        #
      
      Applying this patch fixes the issue.
      
      Fixes: b38d85ef ("perf bpf: Decouple creating the evlist from adding the SB event")
      Signed-off-by: NTiezhu Yang <yangtiezhu@loongson.cn>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Xuefeng Li <lixuefeng@loongson.cn>
      Link: http://lore.kernel.org/lkml/1597753837-16222-1-git-send-email-yangtiezhu@loongson.cnSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0c5f1acc
  14. 23 6月, 2020 1 次提交
  15. 30 5月, 2020 1 次提交
    • S
      perf tools: Add optional support for libpfm4 · 70943490
      Stephane Eranian 提交于
      This patch links perf with the libpfm4 library if it is available and
      LIBPFM4 is passed to the build. The libpfm4 library contains hardware
      event tables for all processors supported by perf_events. It is a helper
      library that helps convert from a symbolic event name to the event
      encoding required by the underlying kernel interface. This library is
      open-source and available from: http://perfmon2.sf.net.
      
      With this patch, it is possible to specify full hardware events by name.
      Hardware filters are also supported. Events must be specified via the
      --pfm-events and not -e option. Both options are active at the same time
      and it is possible to mix and match:
      
        $ perf stat --pfm-events inst_retired:any_p:c=1:i -e cycles ....
      
      One needs to explicitely ask for its inclusion by using the LIBPFM4 make
      command line option, ie its opt-in rather than opt-out of feature
      detection and build support.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jiwei Sun <jiwei.sun@windriver.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: yuzhoujian <yuzhoujian@didichuxing.com>
      Link: http://lore.kernel.org/lkml/20200505182943.218248-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      70943490
  16. 28 5月, 2020 2 次提交
  17. 06 5月, 2020 6 次提交
  18. 18 4月, 2020 1 次提交
  19. 03 4月, 2020 3 次提交
  20. 06 3月, 2020 1 次提交
  21. 27 2月, 2020 2 次提交
    • R
      perf annotate: Remove privsize from symbol__annotate() args · e0ad4d68
      Ravi Bangoria 提交于
      privsize is passed as 0 from all the symbol__annotate() callers.
      Remove it from argument list.
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Link: http://lore.kernel.org/lkml/20200204045233.474937-2-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e0ad4d68
    • R
      perf annotate: Make perf config effective · 7384083b
      Ravi Bangoria 提交于
      perf default config set by user in [annotate] section is totally ignored
      by annotate code. Fix it.
      
      Before:
      
        $ ./perf config
        annotate.hide_src_code=true
        annotate.show_nr_jumps=true
        annotate.show_nr_samples=true
      
        $ ./perf annotate shash
               │    unsigned h = 0;
               │      movl   $0x0,-0xc(%rbp)
               │    while (*s)
               │    ↓ jmp    44
               │    h = 65599 * h + *s++;
         11.33 │24:   mov    -0xc(%rbp),%eax
         43.50 │      imul   $0x1003f,%eax,%ecx
               │      mov    -0x18(%rbp),%rax
      
      After:
      
               │        movl   $0x0,-0xc(%rbp)
               │      ↓ jmp    44
             1 │1 24:   mov    -0xc(%rbp),%eax
             4 │        imul   $0x1003f,%eax,%ecx
               │        mov    -0x18(%rbp),%rax
      
      Note that we have removed show_nr_samples and show_total_period from
      annotation_options because they are not used. Instead of them we use
      symbol_conf.show_nr_samples and symbol_conf.show_total_period.
      
      Committer testing:
      
      Using 'perf annotate --stdio2' to use the TUI rendering but emitting the output to stdio:
      
        # perf config
        #
        # perf config annotate.hide_src_code=true
        # perf config
        annotate.hide_src_code=true
        #
        # perf config annotate.show_nr_jumps=true
        # perf config annotate.show_nr_samples=true
        # perf config
        annotate.hide_src_code=true
        annotate.show_nr_jumps=true
        annotate.show_nr_samples=true
        #
        #
      
      Before:
      
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Percent
                    00000000000609f0 <ObjectInstance::weak_pointer_was_finalized()@@base>:
                      endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
        100.00  10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
                1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
                20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
      
      After:
      
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Samples       endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
           1  1 10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
              1 1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
              1 20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
        # perf config annotate.show_nr_jumps
        annotate.show_nr_jumps=true
        # perf config annotate.show_nr_jumps=false
        # perf config annotate.show_nr_jumps
        annotate.show_nr_jumps=false
        #
        # perf annotate --stdio2 ObjectInstance::weak_pointer_was_finalized 2> /dev/null
        Samples: 1  of event 'cycles', 4000 Hz, Event count (approx.): 830873, [percent: local period]
        ObjectInstance::weak_pointer_was_finalized() /usr/lib64/libgjs.so.0.0.0
        Samples       endbr64
                      cmpq    $0x0,0x20(%rdi)
                    ↓ je      10
                      xor     %eax,%eax
                    ← retq
                      xchg    %ax,%ax
             1  10:   push    %rbp
                      cmpq    $0x0,0x18(%rdi)
                      mov     %rdi,%rbp
                    ↓ jne     20
                1b:   xor     %eax,%eax
                      pop     %rbp
                    ← retq
                      nop
                20:   lea     0x18(%rdi),%rdi
                    → callq   JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*
                      cmpq    $0x0,0x18(%rbp)
                    ↑ jne     1b
                      mov     %rbp,%rdi
                    → callq   ObjectBase::jsobj_addr() const@plt
                      mov     $0x1,%eax
                      pop     %rbp
                    ← retq
        #
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Link: http://lore.kernel.org/lkml/20200213064306.160480-6-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7384083b
  22. 14 1月, 2020 1 次提交
    • A
      perf tools: Support --prefix/--prefix-strip · 3b0b16bf
      Andi Kleen 提交于
      The objdump utility has useful --prefix / --prefix-strip options to
      allow changing source code file names hardcoded into executables' debug
      info. Add options to 'perf report', 'perf top' and 'perf annotate',
      which are then passed to objdump.
      
        $ mkdir foo
        $ echo 'main() { for (;;); }' > foo/foo.c
        $ gcc -g foo/foo.c
        foo/foo.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
            1 | main() { for (;;); }
              | ^~~~
        $ perf record ./a.out
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.230 MB perf.data (5721 samples) ]
        $ mv foo bar
        $ perf annotate
        <does not show source code>
        $ perf annotate --prefix=/home/ak/lsrc/git/bar --prefix-strip=5
        <does show source code>
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Tested-by: NJiri Olsa <jolsa@redhat.com>
      LPU-Reference: 20200107210444.214071-1-andi@firstfloor.org
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3b0b16bf
  23. 11 12月, 2019 1 次提交
    • A
      perf top: Do not bail out when perf_env__read_cpuid() returns ENOSYS · 61208e6e
      Arnaldo Carvalho de Melo 提交于
      'perf top' stopped working on hw architectures that do not provide a
      get_cpuid() implementation and thus fallback to the weak get_cpuid()
      default function.
      
      This is done because at annotation time we may need it in the arch
      specific annotation init routine, but that is only being used by arches
      that do provide a get_cpuid() implementation:
      
        $ find tools/  -name "*.[ch]" | xargs grep 'evlist->env'
        tools/perf/builtin-top.c:	top.evlist->env = &perf_env;
        tools/perf/util/evsel.c:		return evsel->evlist->env;
        tools/perf/util/s390-cpumsf.c:	sf->machine_type = s390_cpumsf_get_type(session->evlist->env->cpuid);
        tools/perf/util/header.c:	session->evlist->env = &header->env;
        tools/perf/util/sample-raw.c:	const char *arch_pf = perf_env__arch(evlist->env);
        $
      
        $ find tools/perf/arch  -name "*.[ch]" | xargs grep -w get_cpuid
        tools/perf/arch/x86/util/auxtrace.c:	ret = get_cpuid(buffer, sizeof(buffer));
        tools/perf/arch/x86/util/header.c:get_cpuid(char *buffer, size_t sz)
        tools/perf/arch/powerpc/util/header.c:get_cpuid(char *buffer, size_t sz)
        tools/perf/arch/s390/util/header.c: * Implementation of get_cpuid().
        tools/perf/arch/s390/util/header.c:int get_cpuid(char *buffer, size_t sz)
        tools/perf/arch/s390/util/header.c:	if (buf && get_cpuid(buf, 128))
        $
      
      For 'report' or 'script', i.e. tools working on perf.data files, that is
      setup while reading the header, its just top that needs to explicitely
      read it at tool start.
      
      Fixes: 608127f7 ("perf top: Initialize perf_env->cpuid, needed by the per arch annotation init routine")
      Reported-by: NJohn Garry <john.garry@huawei.com>
      Analysed-by: NJiri Olsa <jolsa@kernel.org>
      Reviewed-by: NMark Rutland <mark.rutland@arm.com>
      Tested-by: NMark Rutland <mark.rutland@arm.com>
      Tested-by: John Garry <john.garry@huawei.com> # arm64
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lkml.kernel.org/n/tip-lxwjr0cd2eggzx04a780ffrv@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      61208e6e