1. 22 11月, 2019 1 次提交
  2. 21 11月, 2019 1 次提交
  3. 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
  4. 07 11月, 2019 2 次提交
  5. 01 10月, 2019 1 次提交
  6. 26 9月, 2019 2 次提交
  7. 25 9月, 2019 6 次提交
  8. 23 9月, 2019 1 次提交
    • S
      perf record: Fix priv level with branch sampling for paranoid=2 · 4ec8d984
      Stephane Eranian 提交于
      Now that the default perf_events paranoid level is set to 2, a regular
      user cannot monitor kernel level activity anymore. As such, with the
      following cmdline:
      
        $ perf record -e cycles date
      
      The perf tool first tries cycles:uk but then falls back to cycles:u as
      can be seen in the perf report --header-only output:
      
        cmdline : /export/hda3/tmp/perf.tip record -e cycles ls
        event : name = cycles:u, , id = { 436186, ... }
      
      This is okay as long as there is way to learn the priv level was changed
      internally by the tool.
      
      But consider a similar example:
      
        $ perf record -b -e cycles date
        Error:
        You may not have permission to collect stats.
      
      Consider tweaking /proc/sys/kernel/perf_event_paranoid,
      which controls use of the performance events system by
      unprivileged users (without CAP_SYS_ADMIN).
      ...
      
      Why is that treated differently given that the branch sampling inherits the
      priv level of the first event in this case, i.e., cycles:u? It turns out
      that the branch sampling code is more picky and also checks exclude_hv.
      
      In the fallback path, perf record is setting exclude_kernel = 1, but it
      does not change exclude_hv. This does not seem to match the restriction
      imposed by paranoid = 2.
      
      This patch fixes the problem by forcing exclude_hv = 1 in the fallback
      for paranoid=2. With this in place:
      
        $ perf record -b -e cycles date
          cmdline : /export/hda3/tmp/perf.tip record -b -e cycles ls
          event : name = cycles:u, , id = { 436847, ... }
      
      And the command succeeds as expected.
      
      V2 fix a white space.
      
      Committer testing:
      
      After aplying the patch we get:
      
        [acme@quaco ~]$ perf record -b -e cycles date
        WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
        check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_paranoid.
      
        Samples in kernel functions may not be resolved if a suitable vmlinux
        file is not found in the buildid cache or in the vmlinux path.
      
        Samples in kernel modules won't be resolved at all.
      
        If some relocation was applied (e.g. kexec) symbols may be misresolved
        even with a suitable vmlinux or kallsyms file.
      
        Mon 23 Sep 2019 11:00:59 AM -03
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.005 MB perf.data (14 samples) ]
        [acme@quaco ~]$ perf evlist -v
        cycles:u: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD|BRANCH_STACK, read_format: ID, disabled: 1, inherit: 1, exclude_kernel: 1, exclude_hv: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, branch_sample_type: ANY
        [acme@quaco ~]$
      
      That warning about restricted kernel maps will be suppressed in a follow
      up patch, as perf_event_attr.exclude_kernel is set, i.e. no samples for
      the kernel will be taken and thus no need for those maps.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20190920230356.41420-1-eranian@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4ec8d984
  9. 20 9月, 2019 4 次提交
  10. 01 9月, 2019 1 次提交
  11. 30 8月, 2019 1 次提交
  12. 29 8月, 2019 3 次提交
    • 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
    • I
      perf evsel: Kernel profiling is disallowed only when perf_event_paranoid > 1 · aa97293f
      Igor Lubashev 提交于
      Perf was too restrictive about sysctl kernel.perf_event_paranoid. The
      kernel only disallows profiling when perf_event_paranoid > 1. Make perf
      do the same.
      
      Committer testing:
      
      For a non-root user:
      
        $ id
        uid=1000(acme) gid=1000(acme) groups=1000(acme),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
        $
      
      Before:
      
      We were restricting it to just userspace (:u suffix) even for a
      workload started by the user:
      
        $ perf record sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.001 MB perf.data (8 samples) ]
        $ perf evlist
        cycles:u
        $ perf evlist -v
        cycles:u: 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
        $ perf report --stdio
        # To display the perf.data header info, please use --header/--header-only options.
        #
        # Total Lost Samples: 0
        #
        # Samples: 8  of event 'cycles:u'
        # Event count (approx.): 1040396
        #
        # Overhead  Command  Shared Object     Symbol
        # ........  .......  ................  ......................
        #
            68.36%  sleep    libc-2.29.so      [.] _dl_addr
            27.33%  sleep    ld-2.29.so        [.] dl_main
             3.80%  sleep    ld-2.29.so        [.] _dl_setup_hash
        #
        # (Tip: Order by the overhead of source file name and line number: perf report -s srcline)
        #
        $
        $
      
      After:
      
      When the kernel allows profiling the kernel in that scenario:
      
        $ perf record sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.023 MB perf.data (11 samples) ]
        $ perf evlist
        cycles
        $ perf evlist -v
        cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 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
        $
        $ perf report --stdio
        # To display the perf.data header info, please use --header/--header-only options.
        #
        # Total Lost Samples: 0
        #
        # Samples: 11  of event 'cycles'
        # Event count (approx.): 1601964
        #
        # Overhead  Command  Shared Object     Symbol
        # ........  .......  ................  ..........................
        #
            28.14%  sleep    [kernel.vmlinux]  [k] __rb_erase_color
            27.21%  sleep    [kernel.vmlinux]  [k] unmap_page_range
            27.20%  sleep    ld-2.29.so        [.] __tunable_get_val
            15.24%  sleep    [kernel.vmlinux]  [k] thp_get_unmapped_area
             1.96%  perf     [kernel.vmlinux]  [k] perf_event_exec
             0.22%  perf     [kernel.vmlinux]  [k] native_sched_clock
             0.02%  perf     [kernel.vmlinux]  [k] intel_bts_enable_local
             0.00%  perf     [kernel.vmlinux]  [k] native_write_msr
        #
        # (Tip: Boolean options have negative forms, e.g.: perf report --no-children)
        #
        $
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIgor Lubashev <ilubashe@akamai.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1566869956-7154-4-git-send-email-ilubashe@akamai.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      aa97293f
    • I
      perf tools: Use CAP_SYS_ADMIN with perf_event_paranoid checks · dda1bf8e
      Igor Lubashev 提交于
      The kernel is using CAP_SYS_ADMIN instead of euid==0 to override
      perf_event_paranoid check. Make perf do the same.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> # coresight part
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/1566869956-7154-3-git-send-email-ilubashe@akamai.comSigned-off-by: NIgor Lubashev <ilubashe@akamai.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dda1bf8e
  13. 27 8月, 2019 3 次提交
  14. 26 8月, 2019 1 次提交
  15. 23 8月, 2019 3 次提交
  16. 14 8月, 2019 3 次提交
  17. 30 7月, 2019 6 次提交