1. 20 10月, 2019 8 次提交
    • J
      libperf: Move mask setup to perf_evlist__mmap_ops() · b6cd35e4
      Jiri Olsa 提交于
      Move the mask setup to perf_evlist__mmap_ops(), because it's the same on
      both perf and libperf path.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20191017105918.20873-4-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b6cd35e4
    • J
      libperf: Move mmap allocation to perf_evlist__mmap_ops::get · 3805e4f3
      Jiri Olsa 提交于
      Move allocation of the mmap array into perf_evlist__mmap_ops::get, to
      centralize the mmap allocation.
      
      Also move nr_mmap setup to perf_evlist__mmap_ops so it's centralized and
      shared by both perf and libperf mmap code.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20191017105918.20873-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3805e4f3
    • J
      libperf: Introduce perf_evlist__for_each_mmap() · 6eb65f7a
      Jiri Olsa 提交于
      Add the perf_evlist__for_each_mmap() function and export it in the
      perf/evlist.h header, so that the user can iterate through 'struct
      perf_mmap' objects.
      
      Add a internal perf_mmap__link() function to do the actual linking.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20191017105918.20873-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6eb65f7a
    • L
      perf tests: Disable bp_signal testing for arm64 · 6a5f3d94
      Leo Yan 提交于
      As there are several discussions for enabling perf breakpoint signal
      testing on arm64 platform: arm64 needs to rely on single-step to execute
      the breakpointed instruction and then reinstall the breakpoint exception
      handler.  But if we hook the breakpoint with a signal, the signal
      handler will do the stepping rather than the breakpointed instruction,
      this causes infinite loops as below:
      
               Kernel space              |            Userspace
        ---------------------------------|--------------------------------
                                         |  __test_function() -> hit
      				   |                       breakpoint
        breakpoint_handler()             |
          `-> user_enable_single_step()  |
        do_signal()                      |
                                         |  sig_handler() -> Step one
      				   |                instruction and
      				   |                trap to kernel
        single_step_handler()            |
          `-> reinstall_suspended_bps()  |
                                         |  __test_function() -> hit
      				   |     breakpoint again and
      				   |     repeat up flow infinitely
      
      As Will Deacon mentioned [1]: "that we require the overflow handler to
      do the stepping on arm/arm64, which is relied upon by GDB/ptrace. The
      hw_breakpoint code is a complete disaster so my preference would be to
      rip out the perf part and just implement something directly in ptrace,
      but it's a pretty horrible job".  Though Will commented this on arm
      architecture, but the comment also can apply on arm64 architecture.
      
      For complete information, I searched online and found a few years back,
      Wang Nan sent one patch 'arm64: Store breakpoint single step state into
      pstate' [2]; the patch tried to resolve this issue by avoiding single
      stepping in signal handler and defer to enable the signal stepping when
      return to __test_function().  The fixing was not merged due to the
      concern for missing to handle different usage cases.
      
      Based on the info, the most feasible way is to skip Perf breakpoint
      signal testing for arm64 and this could avoid the duplicate
      investigation efforts when people see the failure.  This patch skips
      this case on arm64 platform, which is same with arm architecture.
      
      [1] https://lkml.org/lkml/2018/11/15/205
      [2] https://lkml.org/lkml/2015/12/23/477Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Brajeswar Ghosh <brajeswar.linux@gmail.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Souptick Joarder <jrdr.linux@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20191018085531.6348-3-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6a5f3d94
    • L
      perf tests bp_account: Add dedicated checking helper is_supported() · e533eadf
      Leo Yan 提交于
      The arm architecture supports breakpoint accounting but it doesn't
      support breakpoint overflow signal handling.  The current code uses the
      same checking helper, thus it disables both testings (bp_account and
      bp_signal) for arm platform.
      
      For handling two testings separately, this patch adds a dedicated
      checking helper is_supported() for breakpoint accounting testing, thus
      it allows supporting breakpoint accounting testing on arm platform; the
      old helper test__bp_signal_is_supported() is only used to checking for
      breakpoint overflow signal testing.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Brajeswar Ghosh <brajeswar.linux@gmail.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Souptick Joarder <jrdr.linux@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20191018085531.6348-2-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e533eadf
    • L
      perf tests: Remove needless headers for bp_account · 12d79563
      Leo Yan 提交于
      A few headers are not needed and were introduced by copying from other
      test file.  This patch removes the needless headers for the breakpoint
      accounting testing.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Brajeswar Ghosh <brajeswar.linux@gmail.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Souptick Joarder <jrdr.linux@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20191018085531.6348-1-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      12d79563
    • J
      perf list: Hide deprecated events by default · a7f6c8c8
      Jin Yao 提交于
      There are some deprecated events listed by perf list. But we can't
      remove them from perf list with ease because some old scripts may use
      them.
      
      Deprecated events are old names of renamed events.  When an event gets
      renamed the old name is kept around for some time and marked with
      Deprecated. The newer Intel event lists in the tree already have these
      headers.
      
      So we need to keep them in the event list, but provide a new option to
      show them. The new option is "--deprecated".
      
      With this patch, the deprecated events are hidden by default but they
      can be displayed when option "--deprecated" is enabled.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20191015025357.8708-1-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a7f6c8c8
    • A
      perf trace: Pass a syscall_arg to syscall_arg_fmt->strtoul() · 9afec87e
      Arnaldo Carvalho de Melo 提交于
      With just what we need for the STUL_STRARRAY, i.e. the 'struct strarray'
      pointer to be used, just like with syscall_arg_fmt->scnprintf() for the
      other direction (number -> string).
      
      With this all the strarrays that are associated with syscalls can be
      used with '-e syscalls:sys_enter_SYSCALLNAME --filter', and soon will be
      possible as well to use with the strace-like shorter form, with just the
      syscall names, i.e. something like:
      
         -e lseek/whence==END/
      
      For now we have to use the longer form:
      
          # perf trace -e syscalls:sys_enter_lseek
             0.000 pool/2242 syscalls:sys_enter_lseek(fd: 14<anon_inode:[timerfd]>, offset: 0, whence: CUR)
             0.031 pool/2242 syscalls:sys_enter_lseek(fd: 15<anon_inode:[timerfd]>, offset: 0, whence: CUR)
             0.046 pool/2242 syscalls:sys_enter_lseek(fd: 16<anon_inode:[timerfd]>, offset: 0, whence: CUR)
          5003.528 pool/2242 syscalls:sys_enter_lseek(fd: 14<anon_inode:[timerfd]>, offset: 0, whence: CUR)
          5003.575 pool/2242 syscalls:sys_enter_lseek(fd: 15<anon_inode:[timerfd]>, offset: 0, whence: CUR)
          5003.593 pool/2242 syscalls:sys_enter_lseek(fd: 16<anon_inode:[timerfd]>, offset: 0, whence: CUR)
         10002.017 pool/2242 syscalls:sys_enter_lseek(fd: 14<anon_inode:[timerfd]>, offset: 0, whence: CUR)
         10002.051 pool/2242 syscalls:sys_enter_lseek(fd: 15<anon_inode:[timerfd]>, offset: 0, whence: CUR)
         10002.068 pool/2242 syscalls:sys_enter_lseek(fd: 16<anon_inode:[timerfd]>, offset: 0, whence: CUR)
        ^C# perf trace -e syscalls:sys_enter_lseek --filter="whence!=CUR"
             0.000 sshd/24476 syscalls:sys_enter_lseek(fd: 3, offset: 9032, whence: SET)
             0.060 sshd/24476 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libcrypt.so.2.0.0>, offset: 9032, whence: SET)
             0.187 sshd/24476 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libcrypt.so.2.0.0>, offset: 118632, whence: SET)
             0.203 sshd/24476 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libcrypt.so.2.0.0>, offset: 118632, whence: SET)
             0.349 sshd/24476 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libcrypt.so.2.0.0>, offset: 61936, whence: SET)
        ^C#
      
      And for those curious about what are those lseek(DSO, offset, SET), well, its the loader:
      
        # perf trace -e syscalls:sys_enter_lseek/max-stack=16/ --filter="whence!=CUR"
           0.000 sshd/24495 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libgcrypt.so.20.2.5>, offset: 9032, whence: SET)
                                             __libc_lseek64 (/usr/lib64/ld-2.29.so)
                                             _dl_map_object (/usr/lib64/ld-2.29.so)
           0.067 sshd/24495 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libgcrypt.so.20.2.5>, offset: 9032, whence: SET)
                                             __libc_lseek64 (/usr/lib64/ld-2.29.so)
                                             _dl_map_object_from_fd (/usr/lib64/ld-2.29.so)
                                             _dl_map_object (/usr/lib64/ld-2.29.so)
           0.198 sshd/24495 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libgcrypt.so.20.2.5>, offset: 118632, whence: SET)
                                             __libc_lseek64 (/usr/lib64/ld-2.29.so)
                                             _dl_map_object (/usr/lib64/ld-2.29.so)
           0.219 sshd/24495 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libgcrypt.so.20.2.5>, offset: 118632, whence: SET)
                                             __libc_lseek64 (/usr/lib64/ld-2.29.so)
                                             _dl_map_object_from_fd (/usr/lib64/ld-2.29.so)
                                             _dl_map_object (/usr/lib64/ld-2.29.so)
        ^C#
      
      :-)
      
      With this we can use strings in strarrays in filters, which allows us to
      reuse all these that are in place for syscalls:
      
        $ find tools/perf/trace/beauty/ -name "*.c" | xargs grep -w DEFINE_STRARRAY
        tools/perf/trace/beauty/fcntl.c:	static DEFINE_STRARRAY(fcntl_setlease, "F_");
        tools/perf/trace/beauty/mmap.c:       static DEFINE_STRARRAY(mmap_flags, "MAP_");
        tools/perf/trace/beauty/mmap.c:       static DEFINE_STRARRAY(madvise_advices, "MADV_");
        tools/perf/trace/beauty/sync_file_range.c:       static DEFINE_STRARRAY(sync_file_range_flags, "SYNC_FILE_RANGE_");
        tools/perf/trace/beauty/socket.c:	static DEFINE_STRARRAY(socket_ipproto, "IPPROTO_");
        tools/perf/trace/beauty/mount_flags.c:	static DEFINE_STRARRAY(mount_flags, "MS_");
        tools/perf/trace/beauty/pkey_alloc.c:	static DEFINE_STRARRAY(pkey_alloc_access_rights, "PKEY_");
        tools/perf/trace/beauty/sockaddr.c:DEFINE_STRARRAY(socket_families, "PF_");
        tools/perf/trace/beauty/tracepoints/x86_irq_vectors.c:static DEFINE_STRARRAY(x86_irq_vectors, "_VECTOR");
        tools/perf/trace/beauty/tracepoints/x86_msr.c:static DEFINE_STRARRAY(x86_MSRs, "MSR_");
        tools/perf/trace/beauty/prctl.c:	static DEFINE_STRARRAY(prctl_options, "PR_");
        tools/perf/trace/beauty/prctl.c:	static DEFINE_STRARRAY(prctl_set_mm_options, "PR_SET_MM_");
        tools/perf/trace/beauty/fspick.c:       static DEFINE_STRARRAY(fspick_flags, "FSPICK_");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(ioctl_tty_cmd, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(drm_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(sndrv_pcm_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(sndrv_ctl_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(kvm_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(vhost_virtio_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(vhost_virtio_ioctl_read_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(perf_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(usbdevfs_ioctl_cmds, "");
        tools/perf/trace/beauty/fsmount.c:       static DEFINE_STRARRAY(fsmount_attr_flags, "MOUNT_ATTR_");
        tools/perf/trace/beauty/renameat.c:       static DEFINE_STRARRAY(rename_flags, "RENAME_");
        tools/perf/trace/beauty/kcmp.c:	static DEFINE_STRARRAY(kcmp_types, "KCMP_");
        tools/perf/trace/beauty/move_mount.c:       static DEFINE_STRARRAY(move_mount_flags, "MOVE_MOUNT_");
        $
      
      Well, some, as the mmap flags are like:
      
        $ tools/perf/trace/beauty/mmap_flags.sh
        static const char *mmap_flags[] = {
        	[ilog2(0x40) + 1] = "32BIT",
        	[ilog2(0x01) + 1] = "SHARED",
        	[ilog2(0x02) + 1] = "PRIVATE",
        	[ilog2(0x10) + 1] = "FIXED",
        	[ilog2(0x20) + 1] = "ANONYMOUS",
        	[ilog2(0x008000) + 1] = "POPULATE",
        	[ilog2(0x010000) + 1] = "NONBLOCK",
        	[ilog2(0x020000) + 1] = "STACK",
        	[ilog2(0x040000) + 1] = "HUGETLB",
        	[ilog2(0x080000) + 1] = "SYNC",
        	[ilog2(0x100000) + 1] = "FIXED_NOREPLACE",
        	[ilog2(0x0100) + 1] = "GROWSDOWN",
        	[ilog2(0x0800) + 1] = "DENYWRITE",
        	[ilog2(0x1000) + 1] = "EXECUTABLE",
        	[ilog2(0x2000) + 1] = "LOCKED",
        	[ilog2(0x4000) + 1] = "NORESERVE",
        };
        $
      
      So we'll need a strarray__strtoul_flags() that will break donw the flags
      into tokens separated by '|' before doing the lookup and then go on
      reconstructing the value from, say:
      
            # perf trace -e syscalls:sys_enter_mmap --filter="flags==PRIVATE|FIXED|DENYWRITE"
      
      into:
      
            # perf trace -e syscalls:sys_enter_mmap --filter="flags==0x2|0x10|0x0800"
      
      and finally into:
      
            # perf trace -e syscalls:sys_enter_mmap --filter="flags==0x812"
      
      That is what we see if we don't use the augmented view obtained from:
      
        # perf trace -e mmap
        <SNIP>
        211792.885 procmail/15393 mmap(addr: 0x7fcd11645000, len: 8192, prot: READ, flags: PRIVATE|FIXED|DENYWRITE, fd: 8, off: 0xa000) = 0x7fcd11645000
        <SNIP>
      
      But plain use tracefs:
      
              procmail-15559 [000] .... 54557.178262: sys_mmap(addr: 7f5c9bf7a000, len: 9b000, prot: 1, flags: 812, fd: 3, off: a9000)
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-c6mgkjt8ujnc263eld5tb7q3@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9afec87e
  2. 18 10月, 2019 9 次提交
  3. 16 10月, 2019 14 次提交
    • A
      perf trace: Hook the 'vec' tracepoint argument with the x86 IRQ vectors scnprintf/strtoul · df604bfd
      Arnaldo Carvalho de Melo 提交于
      Ended up only being useful when filtering multiple irq_vectors
      tracepoints, as we end up having a tracepoint for each of the entries,
      i.e.:
      
      This will always come with the "RESCHEDULE_VECTOR" in the 'vector' arg:
      
        # perf trace --max-events 8 -e irq_vectors:reschedule*
           0.000 cc1/29067 irq_vectors:reschedule_entry(vector: RESCHEDULE)
           0.004 cc1/29067 irq_vectors:reschedule_exit(vector: RESCHEDULE)
           0.553 cc1/29067 irq_vectors:reschedule_entry(vector: RESCHEDULE)
           0.556 cc1/29067 irq_vectors:reschedule_exit(vector: RESCHEDULE)
           1.182 cc1/29067 irq_vectors:reschedule_entry(vector: RESCHEDULE)
           1.185 cc1/29067 irq_vectors:reschedule_exit(vector: RESCHEDULE)
           1.203 :29052/29052 irq_vectors:reschedule_entry(vector: RESCHEDULE)
           1.206 :29052/29052 irq_vectors:reschedule_exit(vector: RESCHEDULE)
        #
      
      While filtering that value will produce nothing:
      
        # perf trace --max-events 8 -e irq_vectors:reschedule* --filter="vector != RESCHEDULE"
        ^C#
      
      Maybe it'll be useful for those other tracepoints:
      
        # perf list irq_vectors:vector_*
      
        List of pre-defined events (to be used in -e):
      
          irq_vectors:vector_activate                        [Tracepoint event]
          irq_vectors:vector_alloc                           [Tracepoint event]
          irq_vectors:vector_alloc_managed                   [Tracepoint event]
          irq_vectors:vector_clear                           [Tracepoint event]
          irq_vectors:vector_config                          [Tracepoint event]
          irq_vectors:vector_deactivate                      [Tracepoint event]
          irq_vectors:vector_free_moved                      [Tracepoint event]
          irq_vectors:vector_reserve                         [Tracepoint event]
          irq_vectors:vector_reserve_managed                 [Tracepoint event]
          irq_vectors:vector_setup                           [Tracepoint event]
          irq_vectors:vector_teardown                        [Tracepoint event]
          irq_vectors:vector_update                          [Tracepoint event]
        #
      
      But since we have it done, keep it.
      
      This at least served to teach me that all those irq vectors have a entry
      and an exit tracepoint that I can then use just like with
      raw_syscalls:sys_{enter,exit}, i.e. pair them, use just a
      trace__irq_vectors_entry() + trace__irq_vectors_exit() and use the
      'vector' arg as I use the 'syscall id' one for syscalls.
      
      Then the default for 'perf trace' will include irq_vectors in addition
      to syscalls.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-wer4cwbbqub3o7sa8h1j3uzb@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      df604bfd
    • A
      perf trace beauty: Add the glue for the autogenerated x86 IRQ vector array · 573ed898
      Arnaldo Carvalho de Melo 提交于
      We need to wrap this autogenerated string array with the
      strarray__scnprintf() formatter and the strarray__strotul() lookup
      method, do it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-bx2cjcyv6aerhyy3gvu3uwcy@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      573ed898
    • A
      libbeauty: Add a strarray__scnprintf_suffix() method · 97c2a780
      Arnaldo Carvalho de Melo 提交于
      In some cases, like with x86 IRQ vectors, the common part in names is at
      the end, so a suffix, add a scnprintf function for that.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-agxbj6es2ke3rehwt4gkdw23@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      97c2a780
    • A
      libbeauty: Hook up the x86 irq_vectors table generator · f19a85c6
      Arnaldo Carvalho de Melo 提交于
      I.e. after running:
      
        $ make -C tools/perf O=/tmp/build/perf
      
      We end up with:
      
        $ cat /tmp/build/perf/trace/beauty/generated/x86_arch_irq_vectors_array.c
        static const char *x86_irq_vectors[] = {
        	[0x02] = "NMI",
        	[0x12] = "MCE",
        	[0x20] = "IRQ_MOVE_CLEANUP",
        	[0x80] = "IA32_SYSCALL",
        	[0xec] = "LOCAL_TIMER",
        	[0xed] = "HYPERV_STIMER0",
        	[0xee] = "HYPERV_REENLIGHTENMENT",
        	[0xef] = "MANAGED_IRQ_SHUTDOWN",
        	[0xf0] = "POSTED_INTR_NESTED",
        	[0xf1] = "POSTED_INTR_WAKEUP",
        	[0xf2] = "POSTED_INTR",
        	[0xf3] = "HYPERVISOR_CALLBACK",
        	[0xf4] = "DEFERRED_ERROR",
        	[0xf6] = "IRQ_WORK",
        	[0xf7] = "X86_PLATFORM_IPI",
        	[0xf8] = "REBOOT",
        	[0xf9] = "THRESHOLD_APIC",
        	[0xfa] = "THERMAL_APIC",
        	[0xfb] = "CALL_FUNCTION_SINGLE",
        	[0xfc] = "CALL_FUNCTION",
        	[0xfd] = "RESCHEDULE",
        	[0xfe] = "ERROR_APIC",
        	[0xff] = "SPURIOUS_APIC",
        };
        $
      
      Now its just a matter of using it, associating it to tracepoint arguments named
      'vector', all of which can be correctly used with this table, for int args.
      
      At some point we should move tools/perf/trace/beauty to tools/beauty/,
      so that it can be used more generally and even made available externally
      like libbpf, libperf, libtraceevent, etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-0p2df4kq1afrxbck4e4ct34r@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f19a85c6
    • A
      libbeauty: Add a generator for x86's IRQ vectors -> strings · 5fa022ae
      Arnaldo Carvalho de Melo 提交于
      We'll wire this up with the 'vector' arg in irq_vectors:*, etc:
      
      Just run it straight away and check what it produces:
      
        $ tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh
        static const char *x86_irq_vectors[] = {
        	[0x02] = "NMI",
        	[0x12] = "MCE",
        	[0x20] = "IRQ_MOVE_CLEANUP",
        	[0x80] = "IA32_SYSCALL",
        	[0xec] = "LOCAL_TIMER",
        	[0xed] = "HYPERV_STIMER0",
        	[0xee] = "HYPERV_REENLIGHTENMENT",
        	[0xef] = "MANAGED_IRQ_SHUTDOWN",
        	[0xf0] = "POSTED_INTR_NESTED",
        	[0xf1] = "POSTED_INTR_WAKEUP",
        	[0xf2] = "POSTED_INTR",
        	[0xf3] = "HYPERVISOR_CALLBACK",
        	[0xf4] = "DEFERRED_ERROR",
        	[0xf6] = "IRQ_WORK",
        	[0xf7] = "X86_PLATFORM_IPI",
        	[0xf8] = "REBOOT",
        	[0xf9] = "THRESHOLD_APIC",
        	[0xfa] = "THERMAL_APIC",
        	[0xfb] = "CALL_FUNCTION_SINGLE",
        	[0xfc] = "CALL_FUNCTION",
        	[0xfd] = "RESCHEDULE",
        	[0xfe] = "ERROR_APIC",
        	[0xff] = "SPURIOUS_APIC",
        };
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-cpl1pa7kkwn0llufi5qw4li8@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5fa022ae
    • A
      tools arch x86: Grab a copy of the file containing the IRQ vector defines · d2b72b72
      Arnaldo Carvalho de Melo 提交于
      We'll use it to generate a table and then convert the irq_vectors:*
      tracepoint 'vector' arg in things like perf trace, script, etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-z7gi058lzhnrm32slevg3xod@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d2b72b72
    • J
      perf vendor events arm64: Add some missing events for Hisi hip08 HHA PMU · 2b784715
      John Garry 提交于
      Add some more missing events.
      
      A trivial typo is also fixed.
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Reviewed-by: NShaokun Zhang <zhangshaokun@hisilicon.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: Will Deacon <will@kernel.org>
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1567612484-195727-5-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2b784715
    • J
      perf vendor events arm64: Add some missing events for Hisi hip08 L3C PMU · e3ae5695
      John Garry 提交于
      Add some more missing events.
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Reviewed-by: NShaokun Zhang <zhangshaokun@hisilicon.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: Will Deacon <will@kernel.org>
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1567612484-195727-4-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e3ae5695
    • J
      perf vendor events arm64: Add some missing events for Hisi hip08 DDRC PMU · 1410732a
      John Garry 提交于
      Add some more missing events.
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Reviewed-by: NShaokun Zhang <zhangshaokun@hisilicon.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: Will Deacon <will@kernel.org>
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1567612484-195727-3-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1410732a
    • J
      perf vendor events arm64: Fix Hisi hip08 DDRC PMU eventname · 84b0975f
      John Garry 提交于
      The "EventName" for the DDRC precharge command event is incorrect, so
      fix it.
      
      Fixes: 57cc7324 ("perf jevents: Add support for Hisi hip08 DDRC PMU aliasing")
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Reviewed-by: NShaokun Zhang <zhangshaokun@hisilicon.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: Will Deacon <will@kernel.org>
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1567612484-195727-2-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      84b0975f
    • A
      perf trace: Support tracepoint dynamic char arrays · c5e006cd
      Arnaldo Carvalho de Melo 提交于
      Things like:
      
        # grep __data_loc /sys/kernel/debug/tracing/events/sched/sched_process_exec/format
      	field:__data_loc char[] filename;	offset:8;	size:4;	signed:1;
        #
      
      That, at that offset (8) and with that size(8) have an integer that
      contains the real length and offset for the contents of that array.
      
      Now this works:
      
        # perf trace --max-events 1 -e sched:*exec -a
           0.000 sed/19441 sched:sched_process_exec(filename: "/usr/bin/sync", pid: 19441 (sync), old_pid: 19441 (sync))
        #
      
      As when using the libtraceevent based beautifier:
      
        # perf trace --libtraceevent --max-events 1 -e sched:*exec -a
           0.000 sync/19463 sched:sched_process_exec(filename=/usr/bin/sync pid=19463 old_pid=19463)
        #
      
      I.e. that 'filename' is implemented as a dynamic char array.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-950p0m842fe6n7sxsdwqj5i2@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c5e006cd
    • A
      perf trace: Filter own pid to avoid a feedback look in 'perf trace record -a' · 7fbfe22c
      Arnaldo Carvalho de Melo 提交于
      When doing a system wide 'perf trace record' we need, just like in 'perf
      trace' live mode, to filter out perf trace's own pid, so set up a
      tracepoint filter for the raw_syscalls tracepoints right after adding
      them to the argv array that is set up to then call cmd_record().
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-uysx5w8f2y5ndoln5cq370tv@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7fbfe22c
    • A
      perf string: Export asprintf__tp_filter_pids() · da949f50
      Arnaldo Carvalho de Melo 提交于
      Will be used directly in 'perf trace' for setting up the command line
      argv array to pass to cmd_record, as this was how 'perf trace record'
      was implemented, following the model used in 'perf kvm record', 'perf
      sched record', etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-w3cuwjs63lxf5zpryy3145uv@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      da949f50
    • A
      perf trace: Introduce --errno-summary · b88b14db
      Arnaldo Carvalho de Melo 提交于
      To be used with -S or -s, using just this new option implies -s,
      examples:
      
        # perf trace --errno-summary sleep 1
      
         Summary of events:
      
         sleep (10793), 80 events, 93.0%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           nanosleep              1      0  1000.427  1000.427  1000.427  1000.427      0.00%
           mmap                   8      0     0.026     0.002     0.003     0.005      9.18%
           close                  5      0     0.018     0.001     0.004     0.009     48.97%
           mprotect               4      0     0.017     0.003     0.004     0.006     16.49%
           openat                 3      0     0.012     0.003     0.004     0.005      9.41%
           munmap                 1      0     0.010     0.010     0.010     0.010      0.00%
           brk                    4      0     0.005     0.001     0.001     0.002     22.77%
           read                   4      0     0.005     0.001     0.001     0.002     22.33%
           access                 1      1     0.004     0.004     0.004     0.004      0.00%
        				ENOENT: 1
           fstat                  3      0     0.004     0.001     0.001     0.002     17.18%
           lseek                  3      0     0.003     0.001     0.001     0.001     11.62%
           arch_prctl             2      1     0.002     0.001     0.001     0.001      3.32%
        				EINVAL: 1
           execve                 1      0     0.000     0.000     0.000     0.000      0.00%
      
        #
      
      Works as well together with --failure and -S, i.e. collect the stats and
      show just the syscalls that failed:
      
        # perf trace --failure -S --errno-summary sleep 1
             0.032 arch_prctl(option: 0x3001, arg2: 0x7fffdb11b580) = -1 EINVAL (Invalid argument)
             0.045 access(filename: "/etc/ld.so.preload", mode: R) = -1 ENOENT (No such file or directory)
      
         Summary of events:
      
         sleep (10806), 80 events, 93.0%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           nanosleep              1      0  1000.094  1000.094  1000.094  1000.094      0.00%
           mmap                   8      0     0.026     0.002     0.003     0.005      9.06%
           close                  5      0     0.018     0.001     0.004     0.010     49.58%
           mprotect               4      0     0.017     0.003     0.004     0.006     17.56%
           openat                 3      0     0.014     0.004     0.005     0.006     12.29%
           munmap                 1      0     0.010     0.010     0.010     0.010      0.00%
           brk                    4      0     0.005     0.001     0.001     0.002     22.75%
           read                   4      0     0.005     0.001     0.001     0.002     17.19%
           access                 1      1     0.005     0.005     0.005     0.005      0.00%
        				ENOENT: 1
           fstat                  3      0     0.004     0.001     0.001     0.002     21.66%
           lseek                  3      0     0.003     0.001     0.001     0.001     11.71%
           arch_prctl             2      1     0.002     0.001     0.001     0.001      2.66%
        				EINVAL: 1
           execve                 1      0     0.000     0.000     0.000     0.000      0.00%
      
        #
      Suggested-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-l0mjwczkpouov7lss5zn8d9h@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b88b14db
  4. 15 10月, 2019 9 次提交
    • A
      perf trace: Add syscall failure stats to -s/--summary and -S/--with-summary · 8eded45f
      Arnaldo Carvalho de Melo 提交于
      Just like strace has:
      
        # trace -s sleep 1
      
        Summary of events:
      
        sleep (32370), 80 events, 93.0%
      
          syscall            calls  errors  total       min       avg       max       stddev
                                            (msec)    (msec)    (msec)    (msec)        (%)
          --------------- --------  ------ -------- --------- --------- ---------     ------
          nanosleep              1      0  1000.402  1000.402  1000.402  1000.402      0.00%
          mmap                   8      0     0.023     0.002     0.003     0.004      8.49%
          close                  5      0     0.015     0.001     0.003     0.009     51.39%
          mprotect               4      0     0.014     0.002     0.003     0.005     16.95%
          openat                 3      0     0.013     0.003     0.004     0.005     14.29%
          munmap                 1      0     0.010     0.010     0.010     0.010      0.00%
          read                   4      0     0.005     0.001     0.001     0.002     16.83%
          brk                    4      0     0.004     0.001     0.001     0.002     20.82%
          access                 1      1     0.004     0.004     0.004     0.004      0.00%
          fstat                  3      0     0.003     0.001     0.001     0.001     12.17%
          lseek                  3      0     0.003     0.001     0.001     0.001     11.45%
          arch_prctl             2      1     0.002     0.001     0.001     0.001      2.30%
          execve                 1      0     0.000     0.000     0.000     0.000      0.00%
      
        #
      
        # perf trace -S sleep 1
               ?  ... [continued]: execve())             = 0
           0.028 brk(brk: NULL)                          = 0x559f5bd96000
           0.033 arch_prctl(option: 0x3001, arg2: 0x7ffda8b715a0) = -1 EINVAL (Invalid argument)
           0.046 access(filename: "/etc/ld.so.preload", mode: R) = -1 ENOENT (No such file or directory)
           0.055 openat(dfd: CWD, filename: "/etc/ld.so.cache", flags: RDONLY|CLOEXEC) = 3
           0.060 fstat(fd: 3, statbuf: 0x7ffda8b707a0)   = 0
           0.062 mmap(addr: NULL, len: 134346, prot: READ, flags: PRIVATE, fd: 3, off: 0) = 0x7f3aedfc4000
           0.066 close(fd: 3)                            = 0
           0.079 openat(dfd: CWD, filename: "/lib64/libc.so.6", flags: RDONLY|CLOEXEC) = 3
           0.085 read(fd: 3, buf: 0x7ffda8b70948, count: 832) = 832
           0.088 lseek(fd: 3, offset: 792, whence: SET)  = 792
           0.090 read(fd: 3, buf: 0x7ffda8b70810, count: 68) = 68
           0.093 fstat(fd: 3, statbuf: 0x7ffda8b707f0)   = 0
           0.095 mmap(addr: NULL, len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS) = 0x7f3aedfc2000
           0.101 lseek(fd: 3, offset: 792, whence: SET)  = 792
           0.103 read(fd: 3, buf: 0x7ffda8b70450, count: 68) = 68
           0.105 lseek(fd: 3, offset: 864, whence: SET)  = 864
           0.107 read(fd: 3, buf: 0x7ffda8b70470, count: 32) = 32
           0.110 mmap(addr: NULL, len: 1857472, prot: READ, flags: PRIVATE|DENYWRITE, fd: 3, off: 0) = 0x7f3aeddfc000
           0.114 mprotect(start: 0x7f3aede1e000, len: 1679360, prot: NONE) = 0
           0.121 mmap(addr: 0x7f3aede1e000, len: 1363968, prot: READ|EXEC, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x22000) = 0x7f3aede1e000
           0.127 mmap(addr: 0x7f3aedf6b000, len: 311296, prot: READ, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x16f000) = 0x7f3aedf6b000
           0.131 mmap(addr: 0x7f3aedfb8000, len: 24576, prot: READ|WRITE, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x1bb000) = 0x7f3aedfb8000
           0.138 mmap(addr: 0x7f3aedfbe000, len: 14272, prot: READ|WRITE, flags: PRIVATE|FIXED|ANONYMOUS) = 0x7f3aedfbe000
           0.147 close(fd: 3)                            = 0
           0.158 arch_prctl(option: SET_FS, arg2: 0x7f3aedfc3580) = 0
           0.210 mprotect(start: 0x7f3aedfb8000, len: 16384, prot: READ) = 0
           0.230 mprotect(start: 0x559f5b27d000, len: 4096, prot: READ) = 0
           0.236 mprotect(start: 0x7f3aee00f000, len: 4096, prot: READ) = 0
           0.240 munmap(addr: 0x7f3aedfc4000, len: 134346) = 0
           0.300 brk(brk: NULL)                          = 0x559f5bd96000
           0.302 brk(brk: 0x559f5bdb7000)                = 0x559f5bdb7000
           0.305 brk(brk: NULL)                          = 0x559f5bdb7000
           0.310 openat(dfd: CWD, filename: "/usr/lib/locale/locale-archive", flags: RDONLY|CLOEXEC) = 3
           0.315 fstat(fd: 3, statbuf: 0x7f3aedfbdac0)   = 0
           0.318 mmap(addr: NULL, len: 217750512, prot: READ, flags: PRIVATE, fd: 3, off: 0) = 0x7f3ae0e52000
           0.325 close(fd: 3)                            = 0
           0.358 nanosleep(rqtp: 0x7ffda8b714b0, rmtp: NULL) = 0
        1000.622 close(fd: 1)                            = 0
        1000.641 close(fd: 2)                            = 0
        1000.664 exit_group(error_code: 0)               = ?
      
         Summary of events:
      
         sleep (722), 80 events, 93.0%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           nanosleep              1      0  1000.194  1000.194  1000.194  1000.194      0.00%
           mmap                   8      0     0.025     0.002     0.003     0.005     10.17%
           close                  5      0     0.018     0.001     0.004     0.010     50.18%
           mprotect               4      0     0.016     0.003     0.004     0.006     16.81%
           openat                 3      0     0.011     0.003     0.004     0.004      6.57%
           munmap                 1      0     0.010     0.010     0.010     0.010      0.00%
           brk                    4      0     0.005     0.001     0.001     0.002     20.72%
           read                   4      0     0.005     0.001     0.001     0.002     16.71%
           access                 1      1     0.005     0.005     0.005     0.005      0.00%
           fstat                  3      0     0.004     0.001     0.001     0.002     14.82%
           lseek                  3      0     0.003     0.001     0.001     0.001     11.66%
           arch_prctl             2      1     0.002     0.001     0.001     0.001      3.59%
           execve                 1      0     0.000     0.000     0.000     0.000      0.00%
      
        #
      
      Works for system wide, e.g. for 1ms:
      
        # perf trace -s -a sleep 0.001
      
         Summary of events:
      
         sleep (768), 94 events, 37.9%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           nanosleep              1      0     1.133     1.133     1.133     1.133      0.00%
           execve                 7      6     0.351     0.003     0.050     0.316     88.53%
           mmap                   8      0     0.024     0.002     0.003     0.004      8.86%
           mprotect               4      0     0.017     0.003     0.004     0.006     16.02%
           openat                 3      0     0.013     0.004     0.004     0.005      8.34%
           munmap                 1      0     0.010     0.010     0.010     0.010      0.00%
           brk                    4      0     0.007     0.001     0.002     0.002     10.99%
           close                  5      0     0.005     0.001     0.001     0.002     11.69%
           read                   5      0     0.005     0.000     0.001     0.002     30.53%
           access                 1      1     0.004     0.004     0.004     0.004      0.00%
           fstat                  3      0     0.004     0.001     0.001     0.002     10.74%
           lseek                  3      0     0.003     0.001     0.001     0.001     10.20%
           arch_prctl             2      1     0.002     0.001     0.001     0.001      3.34%
      
         Web Content (21258), 46 events, 18.5%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           recvmsg               12     12     0.015     0.001     0.001     0.002      8.50%
           futex                  2      0     0.008     0.003     0.004     0.005     27.08%
           poll                   6      0     0.006     0.000     0.001     0.002     22.14%
           read                   2      0     0.006     0.002     0.003     0.003     26.08%
           write                  1      0     0.002     0.002     0.002     0.002      0.00%
      
         Web Content (4365), 36 events, 14.5%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           recvmsg               10     10     0.015     0.001     0.002     0.003     11.83%
           poll                   5      0     0.006     0.000     0.001     0.002     28.44%
           futex                  2      0     0.005     0.001     0.003     0.004     48.29%
           read                   1      0     0.003     0.003     0.003     0.003      0.00%
      
         Timer (21275), 14 events, 5.6%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           futex                  6      1     0.240     0.000     0.040     0.149     64.58%
           write                  1      0     0.008     0.008     0.008     0.008      0.00%
      
         Timer (4383), 14 events, 5.6%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           futex                  6      2     0.186     0.000     0.031     0.181     96.45%
           write                  1      0     0.010     0.010     0.010     0.010      0.00%
      
         Web Content (20354), 28 events, 11.3%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           recvmsg                8      8     0.010     0.001     0.001     0.002     15.24%
           poll                   4      0     0.004     0.000     0.001     0.002     35.68%
           futex                  1      0     0.003     0.003     0.003     0.003      0.00%
           read                   1      0     0.003     0.003     0.003     0.003      0.00%
      
         Timer (20371), 10 events, 4.0%
      
           syscall            calls  errors  total       min       avg       max       stddev
                                             (msec)    (msec)    (msec)    (msec)        (%)
           --------------- --------  ------ -------- --------- --------- ---------     ------
           futex                  4      1     0.077     0.000     0.019     0.075     95.46%
           write                  1      0     0.005     0.005     0.005     0.005      0.00%
      
        [root@quaco ~]#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-k7kh2muo5oeg56yx446hnw9v@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8eded45f
    • J
      perf stat: Support --all-kernel/--all-user · dd071024
      Jin Yao 提交于
      'perf record' has supported --all-kernel / --all-user to configure all
      used events to run in kernel space or run in user space. But 'perf stat'
      doesn't support these options.
      
      It would be useful to support these options in 'perf stat' too to keep
      the same semantics available in both tools.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20191011050545.3899-1-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dd071024
    • T
      perf jvmti: Link against tools/lib/ctype.h to have weak strlcpy() · 5fb470bc
      Thomas Richter 提交于
      The build of file libperf-jvmti.so succeeds but the resulting
      object fails to load:
      
       # ~/linux/tools/perf/perf record -k mono -- java  \
            -XX:+PreserveFramePointer \
            -agentpath:/root/linux/tools/perf/libperf-jvmti.so \
             hog 100000 123450
        Error occurred during initialization of VM
        Could not find agent library /root/linux/tools/perf/libperf-jvmti.so
            in absolute path, with error:
            /root/linux/tools/perf/libperf-jvmti.so: undefined symbol: _ctype
      
      Add the missing _ctype symbol into the build script.
      
      Fixes: 79743bc9 ("perf jvmti: Link against tools/lib/string.o to have weak strlcpy()")
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20191008093841.59387-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5fb470bc
    • I
      perf annotate: Fix objdump --no-show-raw-insn flag · c5baf908
      Ian Rogers 提交于
      Remove redirection of objdump's stderr to /dev/null to help diagnose
      failures.
      
      Fix the '--no-show-raw' flag to be '--no-show-raw-insn' which binutils
      is permissive and allows, but fails with LLVM objdump.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: clang-built-linux@googlegroups.com
      Link: http://lore.kernel.org/lkml/20191010183649.23768-6-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c5baf908
    • I
      perf annotate: Don't pipe objdump output through 'expand' command · b34b45ee
      Ian Rogers 提交于
      Avoiding a pipe allows objdump command failures to surface.  Move to the
      caller of symbol__parse_objdump_line the call to strim that removes
      leading and trailing tabs.  Add a new expand_tabs function that if a tab
      is present allocate a new line in which tabs are expanded.  In
      symbol__parse_objdump_line the line had no leading spaces, so simplify
      the line_ip processing.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: clang-built-linux@googlegroups.com
      Link: http://lore.kernel.org/lkml/20191010183649.23768-5-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b34b45ee
    • I
      perf annotate: Don't pipe objdump output through 'grep' command · 7a675de4
      Ian Rogers 提交于
      Simplify the objdump command by not piping the output of objdump through
      grep. Instead, drop lines that match the grep pattern during the reading
      loop.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: clang-built-linux@googlegroups.com
      Link: http://lore.kernel.org/lkml/20191010183649.23768-4-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7a675de4
    • I
      perf annotate: Use libsubcmd's run-command.h to fork objdump · 42359499
      Ian Rogers 提交于
      Reduce duplicated logic by using the subcmd library. Ensure when errors
      occur they are reported to the caller. Before this patch, if no lines
      are read the error status is 0.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: clang-built-linux@googlegroups.com
      Link: http://lore.kernel.org/lkml/20191010183649.23768-3-irogers@google.com
      Link: http://lore.kernel.org/lkml/20191015003418.62563-1-irogers@google.com
      [ merged follow up fix for NULL termination as in the 2nd link above ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      42359499
    • I
      perf annotate: Avoid reallocation in objdump parsing · 353dcaa2
      Ian Rogers 提交于
      Objdump output is parsed using getline which allocates memory for the
      read. Getline will realloc if the memory is too small, but currently the
      line is always freed after the call.
      
      Simplify parse_objdump_line by performing the reading in symbol__disassemble.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jin Yao <yao.jin@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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: clang-built-linux@googlegroups.com
      Link: http://lore.kernel.org/lkml/20191010183649.23768-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      353dcaa2
    • J
      perf report: Add warning when libunwind not compiled in · 800d3f56
      Jin Yao 提交于
      We received a user report that call-graph DWARF mode was enabled in
      'perf record' but 'perf report' didn't unwind the callstack correctly.
      The reason was, libunwind was not compiled in.
      
      We can use 'perf -vv' to check the compiled libraries but it would be
      valuable to report a warning to user directly (especially valuable for
      a perf newbie).
      
      The warning is:
      
      Warning:
      Please install libunwind development packages during the perf build.
      
      Both TUI and stdio are supported.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20191011022122.26369-1-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      800d3f56