1. 07 12月, 2021 1 次提交
  2. 07 11月, 2021 1 次提交
    • N
      perf evsel: Fix missing exclude_{host,guest} setting · 3500eeeb
      Namhyung Kim 提交于
      The current logic for the perf missing feature has a bug that it can
      wrongly clear some modifiers like G or H.  Actually some PMUs don't
      support any filtering or exclusion while others do.  But we check it as
      a global feature.
      
      For example, the cycles event can have 'G' modifier to enable it only in
      the guest mode on x86.  When you don't run any VMs it'll return 0.
      
        # perf stat -a -e cycles:G sleep 1
      
          Performance counter stats for 'system wide':
      
                          0      cycles:G
      
                1.000721670 seconds time elapsed
      
      But when it's used with other pmu events that don't support G modifier,
      it'll be reset and return non-zero values.
      
        # perf stat -a -e cycles:G,msr/tsc/ sleep 1
      
          Performance counter stats for 'system wide':
      
                538,029,960      cycles:G
             16,924,010,738      msr/tsc/
      
                1.001815327 seconds time elapsed
      
      This is because of the missing feature detection logic being global.
      Add a hashmap to set pmu-specific exclude_host/guest features.
      
      Committer notes:
      
      Fix 'perf test python' by adding a stub for evsel__find_pmu() in
      tools/perf/util/python.c, document that it is used so far only for the
      above reasons so that if anybody needs this in the python binding
      usecases, we can revisit this.
      Reported-by: NStephane Eranian <eranian@google.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Link: http://lore.kernel.org/lkml/20211105205847.120950-1-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3500eeeb
  3. 10 7月, 2021 1 次提交
  4. 29 4月, 2021 1 次提交
  5. 21 1月, 2021 1 次提交
    • S
      perf stat: Enable counting events for BPF programs · fa853c4b
      Song Liu 提交于
      Introduce 'perf stat -b' option, which counts events for BPF programs, like:
      
        [root@localhost ~]# ~/perf stat -e ref-cycles,cycles -b 254 -I 1000
           1.487903822            115,200      ref-cycles
           1.487903822             86,012      cycles
           2.489147029             80,560      ref-cycles
           2.489147029             73,784      cycles
           3.490341825             60,720      ref-cycles
           3.490341825             37,797      cycles
           4.491540887             37,120      ref-cycles
           4.491540887             31,963      cycles
      
      The example above counts 'cycles' and 'ref-cycles' of BPF program of id
      254.  This is similar to bpftool-prog-profile command, but more
      flexible.
      
      'perf stat -b' creates per-cpu perf_event and loads fentry/fexit BPF
      programs (monitor-progs) to the target BPF program (target-prog). The
      monitor-progs read perf_event before and after the target-prog, and
      aggregate the difference in a BPF map. Then the user space reads data
      from these maps.
      
      A new 'struct bpf_counter' is introduced to provide a common interface
      that uses BPF programs/maps to count perf events.
      
      Committer notes:
      
      Removed all but bpf_counter.h includes from evsel.h, not needed at all.
      
      Also BPF map lookups for PERCPU_ARRAYs need to have as its value receive
      buffer passed to the kernel libbpf_num_possible_cpus() entries, not
      evsel__nr_cpus(evsel), as the former uses
      /sys/devices/system/cpu/possible while the later uses
      /sys/devices/system/cpu/online, which may be less than the 'possible'
      number making the bpf map lookup overwrite memory and cause hard to
      debug memory corruption.
      
      We need to continue using evsel__nr_cpus(evsel) when accessing the
      perf_counts array tho, not to overwrite another are of memory :-)
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/lkml/20210120163031.GU12699@kernel.org/Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Link: http://lore.kernel.org/lkml/20201229214214.3413833-4-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fa853c4b
  6. 01 12月, 2020 1 次提交
  7. 30 11月, 2020 1 次提交
  8. 28 9月, 2020 1 次提交
  9. 10 9月, 2020 1 次提交
    • J
      perf tests: Call test_attr__open() directly · 8366f0d2
      Jiri Olsa 提交于
      There's no longer need to call test_attr__open() from
      sys_perf_event_open(), because both 'perf record' and 'perf stat' call
      evsel__open_cpu(), so we can call it directly from there and not polute
      the perf-sys.h header.
      
      Committer testing:
      
      Before and after:
      
        # perf test attr
        17: Setup struct perf_event_attr                                    : Ok
        49: Synthesize attr update                                          : Ok
        # perf test -v attr
        17: Setup struct perf_event_attr                                    :
        --- start ---
        test child forked, pid 2170868
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any_ret'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any_ret'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-C0'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-graph-fp'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-period'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-group-sampling'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-freq'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-detailed-3'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-k'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-k'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-group1'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-u'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-u'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-basic'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any_call'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any_call'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-default'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-graph-dwarf'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-no-buffering'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-raw'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-detailed-2'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-count'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-data'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-group'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-any'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-any'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-graph-default'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-no-samples'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-C0'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-no-inherit'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-ind_call'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-ind_call'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-basic'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-group1'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-pfm-period'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-pfm-period'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-detailed-1'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-no-inherit'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-hv'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-hv'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-group'
        test child finished with 0
        ---- end ----
        Setup struct perf_event_attr: Ok
        49: Synthesize attr update                                          :
        --- start ---
        test child forked, pid 2171004
        test child finished with 0
        ---- end ----
        Synthesize attr update: Ok
        #
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200827193201.GB127372@kravaSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8366f0d2
  10. 06 5月, 2020 2 次提交
  11. 12 11月, 2019 1 次提交
    • R
      perf tool: Provide an option to print perf_event_open args and return value · ccd26741
      Ravi Bangoria 提交于
      Perf record with verbose=2 already prints this information along with
      whole lot of other traces which requires lot of scrolling. Introduce
      an option to print only perf_event_open() arguments and return value.
      
      Sample o/p:
      
        $ perf --debug perf-event-open=1 record -- ls > /dev/null
        ------------------------------------------------------------
        perf_event_attr:
          size                             112
          { sample_period, sample_freq }   4000
          sample_type                      IP|TID|TIME|PERIOD
          read_format                      ID
          disabled                         1
          inherit                          1
          exclude_kernel                   1
          mmap                             1
          comm                             1
          freq                             1
          enable_on_exec                   1
          task                             1
          precise_ip                       3
          sample_id_all                    1
          exclude_guest                    1
          mmap2                            1
          comm_exec                        1
          ksymbol                          1
          bpf_event                        1
        ------------------------------------------------------------
        sys_perf_event_open: pid 4308  cpu 0  group_fd -1  flags 0x8 = 4
        sys_perf_event_open: pid 4308  cpu 1  group_fd -1  flags 0x8 = 5
        sys_perf_event_open: pid 4308  cpu 2  group_fd -1  flags 0x8 = 6
        sys_perf_event_open: pid 4308  cpu 3  group_fd -1  flags 0x8 = 8
        sys_perf_event_open: pid 4308  cpu 4  group_fd -1  flags 0x8 = 9
        sys_perf_event_open: pid 4308  cpu 5  group_fd -1  flags 0x8 = 10
        sys_perf_event_open: pid 4308  cpu 6  group_fd -1  flags 0x8 = 11
        sys_perf_event_open: pid 4308  cpu 7  group_fd -1  flags 0x8 = 12
        ------------------------------------------------------------
        perf_event_attr:
          type                             1
          size                             112
          config                           0x9
          watermark                        1
          sample_id_all                    1
          bpf_event                        1
          { wakeup_events, wakeup_watermark } 1
        ------------------------------------------------------------
        sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8
        sys_perf_event_open failed, error -13
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.002 MB perf.data (9 samples) ]
      
      Committer notes:
      
      Just like the 'verbose' variable this new 'debug_peo_args' needs to be
      added to util/python.c, since we don't link the debug.o file in the
      python binding, which ended up making 'perf test python' fail with:
      
        # perf test -v python
        18: 'import perf' in python                               :
        --- start ---
        test child forked, pid 19237
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        ImportError: /tmp/build/perf/python/perf.so: undefined symbol: debug_peo_args
        test child finished with -1
        ---- end ----
        'import perf' in python: FAILED!
        #
      
      After adding that new variable to util/python.c:
      
        # perf test -v python
        18: 'import perf' in python                               :
        --- start ---
        test child forked, pid 22364
        test child finished with 0
        ---- end ----
        'import perf' in python: Ok
        #
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lore.kernel.org/lkml/20191108094128.28769-1-ravi.bangoria@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ccd26741
  12. 10 10月, 2019 3 次提交
  13. 01 10月, 2019 1 次提交
  14. 25 9月, 2019 8 次提交
  15. 20 9月, 2019 2 次提交
  16. 01 9月, 2019 1 次提交
  17. 30 8月, 2019 2 次提交
  18. 29 8月, 2019 1 次提交
  19. 27 8月, 2019 5 次提交
  20. 30 7月, 2019 5 次提交