Skip to content
  1. Jul 19, 2017
    • Krister Johansen's avatar
      perf probe: Allow placing uprobes in alternate namespaces. · 544abd44
      Krister Johansen authored
      
      
      Teaches perf how to place a uprobe on a file that's in a different mount
      namespace.  The user must add the probe using the --target-ns argument
      to perf probe.  Once it has been placed, it may be recorded against
      without further namespace-specific commands.
      
      Signed-off-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      [ PPC build fixed by Ravi: ]
      Link: http://lkml.kernel.org/r/1500287542-6219-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      [ Fix !HAVE_DWARF_SUPPORT build ]
      Link: http://lkml.kernel.org/r/1499305693-1599-4-git-send-email-kjlx@templeofstupid.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      544abd44
    • Krister Johansen's avatar
      perf maps: Lookup maps in both intitial mountns and inner mountns. · bf2e710b
      Krister Johansen authored
      
      
      If a process is in a mountns and has symbols in /tmp/perf-<pid>.map,
      look first in the namespace using the tgid for the pidns that the
      process might be in.  If the map isn't found there, try looking in the
      mountns where perf is running, and use the tgid that's appropriate for
      perf's pid namespace.  If all else fails, use the original pid.
      
      This allows us to locate a symbol map file in the mount namespace, if it
      was generated there.  However, we also try the tool's /tmp in case it's
      there instead.
      
      Signed-off-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Tested-by: default avatarBrendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1499305693-1599-3-git-send-email-kjlx@templeofstupid.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bf2e710b
    • Krister Johansen's avatar
      perf symbols: Find symbols in different mount namespace · 843ff37b
      Krister Johansen authored
      
      
      Teach perf how to resolve symbols from binaries that are in a different
      mount namespace from the tool.  This allows perf to generate meaningful
      stack traces even if the binary resides in a different mount namespace
      from the tool.
      
      Signed-off-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Tested-by: default avatarBrendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1499305693-1599-2-git-send-email-kjlx@templeofstupid.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      843ff37b
    • Arnaldo Carvalho de Melo's avatar
      tools build: Add test for setns() · 86bcdb5a
      Arnaldo Carvalho de Melo authored
      
      
      And provide an alternative implementation to keep perf building on older
      distros as we're about to add initial support for namespaces.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-bqdwijunhjlvps1ardykhw1i@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      86bcdb5a
    • Arnaldo Carvalho de Melo's avatar
      tools include uapi x86: Add __NR_setns, if missing · 59291f19
      Arnaldo Carvalho de Melo authored
      
      
      To help us provide a simple setns() in older distros.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-o10a85kf6j7ig87ep6crab2k@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      59291f19
    • Arnaldo Carvalho de Melo's avatar
      tools include uapi x86: Grab a copy of unistd.h · 047726d1
      Arnaldo Carvalho de Melo authored
      
      
      In older distros we were not including our copies of unistd_{32,64}.h,
      as we were relying on the system's asm/unistd.h, and a log time ago
      the files to be included were asm-{x86_64,i386}/unistd.h.
      
      Fix it by also carrying a copy of asm/unistd.h, that will be the same
      as in modern distros and will allow us to provide missing __NR_setns,
      for instance, in older distros.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-iwmgm0c4m1ynstktzmkjh8di@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      047726d1
    • Sukadev Bhattiprolu's avatar
      perf vendor events: Add POWER9 PVRs to mapfile · 80e63ffb
      Sukadev Bhattiprolu authored
      
      
      Add currently supported POWER9 PVRs to the mapfile
      
      Signed-off-by: default avatarSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Shriya <shriyak@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/n/tip-k1pe02sn5gh6nrzp8ditye94@git.kernel.org
      [ Fix conflict with a87006fd5629 ("perf pmu-events: Support additional POWER8+ PVR in mapfile") ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      80e63ffb
    • Sukadev Bhattiprolu's avatar
      perf vendor events: Add POWER9 PMU events · 826db0f1
      Sukadev Bhattiprolu authored
      
      
      Add POWER9 PMU events.
      
      Signed-off-by: default avatarSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Link: http://lkml.kernel.org/n/tip-i08irl1x1i914xsikiomvqip@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      826db0f1
    • Shriya's avatar
      perf pmu-events: Support additional POWER8+ PVR in mapfile · 8b3cf3d8
      Shriya authored
      
      
      Add support for POWER8+ PVR 004c0100 for Garrison
      
      Signed-off-by: default avatarShriya <shriyak@linux.vnet.ibm.com>
      Reviewed-by: default avatarMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/1497853842-11023-1-git-send-email-shriyak@linux.vnet.ibm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8b3cf3d8
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty fcntl: Beautify F_GETOWN and F_SETOWN · 1a4ad263
      Arnaldo Carvalho de Melo authored
      
      
      By attaching the pid beautifier to the args in the F_SETOWN case and to
      the syscall return on the F_GETOWN one.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-ea1prtqvao87cdrishce7954@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1a4ad263
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Export the pid beautifier for use in more places · ff2f1b2d
      Arnaldo Carvalho de Melo authored
      
      
      Now that the beautifiers are being split into multiple source and object
      files, we will need more of them exported, do it for the 'pid' one, will
      be used to augment the return of some syscalls that may return a 'pid',
      such as fcntl(fd, F_GETOWN).
      
      Will also be used for fcntl(fd, F_SETOWN, pid).
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-7gr5nt9p5skp4i1w0ja1w272@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ff2f1b2d
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty fcntl: Augment the return of F_DUPFD(_CLOEXEC) · 07a05724
      Arnaldo Carvalho de Melo authored
      
      
      Using the existing 'fd' beautifier, now we can see the path for the just
      dup'ed fd:
      
       18031.338 ( 0.009 ms): gnome-terminal/2472 fcntl(fd: 55, cmd: DUPFD_CLOEXEC) = 56</memfd:gdk-wayland (deleted)>
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-z0ggo126p2eobfwnjw9z16tw@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      07a05724
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Export the fd beautifier for use in more places · fc65eb82
      Arnaldo Carvalho de Melo authored
      
      
      Now that the beautifiers are being split into multiple source and object
      files, we will need more of them exported, do it for the 'fd' one, will
      be used to augment the return of some syscalls that may return an 'fd',
      such as fcntl(fd, F_DUPFD).
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-39sosu12hhywyunqf5s74ewf@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fc65eb82
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Give syscall return beautifier more context · 7ee57434
      Arnaldo Carvalho de Melo authored
      
      
      We need the current thread and the trace internal state so that we can
      use the fd beautifier to augment syscall returns, so use struct
      syscall_arg with some fields that make sense on returns (val, thread,
      trace).
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-lqag8e86ybidrh5zpqne05ov@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7ee57434
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty fcntl: Beautify F_[GS]ETFD arg/return value · c2e539d2
      Arnaldo Carvalho de Melo authored
      
      
      Now it will show 0 or CLOEXEC, the only !0 value returned by the kernel
      for fcntl(fd, F_GETFD).
      
      And for F_SETFD:
      
        6870.267 ( 0.004 ms): make/29812 fcntl(fd: 7</home/acme/git/linux/tools/build/Build.include>, cmd: SETFD, arg: CLOEXEC) = 0
        6873.805 ( 0.002 ms): make/29816 fcntl(fd: 6</home/acme/git/linux/tools/build/Makefile.build>, cmd: SETFD, arg: CLOEXEC) = 0
      <SNIP>
       77986.150 ( 0.006 ms): alsa-sink-ALC3/2042 fcntl(fd: 45</dev/snd/pcmC1D0p>, cmd: SETFD, arg: CLOEXEC) = 0
       77986.271 ( 0.006 ms): alsa-sink-ALC3/2042 fcntl(fd: 23</dev/snd/controlC1>, cmd: SETFD, arg: CLOEXEC) = 0
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-sz9dob7t4zd6m65femazpaah@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c2e539d2
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty fcntl flags: Beautify F_SETFL arg · 12c0c0ce
      Arnaldo Carvalho de Melo authored
      
      
      Result:
      
        0.011 (0.001 ms): Chrome_IOThrea/19863 fcntl(fd: 130</dev/shm/.com.google.Chrome.w5UBtZ (deleted)>, cmd: SETFL, arg: RDWR|APPEND|LARGEFILE) = 0
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-qgf8ggsq9chnjblxlq954deu@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      12c0c0ce
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty open flags: Move RDRW to the start of the output · e07f93c0
      Arnaldo Carvalho de Melo authored
      
      
      We were getting:
      
       62597.859 ( 0.005 ms): TaskSchedulerF/18107 fcntl(fd: 194, cmd: GETFL) = LARGEFILE|RDWR
      
      Instead of the more familiar (from looking at strace output):
      
       62597.859 ( 0.005 ms): TaskSchedulerF/18107 fcntl(fd: 194, cmd: GETFL) = RDWR|LARGEFILE
      
      Fix it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-d4d9nd88t4bu9y9odbrcb5z6@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e07f93c0
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty fcntl: Beautify F_GETFL return value · 89e8524a
      Arnaldo Carvalho de Melo authored
      
      
      The return for fcntl(fd, F_GETFL) is the fd file flags, so reuse the one
      for the open syscall flags parameter:
      
        997.992 (0.002 ms): Chrome_IOThrea/19863 fcntl(fd: 144</dev/shm/.com.google.Chrome.OhA8YL>, cmd: GETFL) = RDWR|LARGEFILE
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-5nn3n4p4yfs6u0leoq880apc@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      89e8524a
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty open flags: Do not depend on the system's O_LARGEFILE define · b84148a9
      Arnaldo Carvalho de Melo authored
      
      
      In x86_64 /usr/include/bits/fcntl.h sets it to zero, so just undef it
      and use the standard 00100000 value when decoding the open flags arg.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-k28megguz5snwop9obvn9mcr@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b84148a9
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty open flags: Support O_TMPFILE and O_NOFOLLOW · 6b3d5c97
      Arnaldo Carvalho de Melo authored
      
      
      The open syscall flags beautifier wasn't considering those flags, fix
      it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-ukzoldh4arrl8x2uwjafd22h@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6b3d5c97
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow syscall_arg beautifiers to set a different return formatter · 84486caa
      Arnaldo Carvalho de Melo authored
      
      
      Things like fcntl will use this to set the right formatter based on its
      'cmd' argument.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-4ea3wplb8b4j7aymj0d5uo0h@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      84486caa
    • Arnaldo Carvalho de Melo's avatar
      perf beauty open: Detach the syscall_arg agnostic bits from the flags formatter · b239ad28
      Arnaldo Carvalho de Melo authored
      
      
      We may want to use this in other contexts, like when formatting the
      return of fcntl(fd, F_GETFL).
      
      Make it have the following signature, so that we can set the formatter
      for the return argument while processing the arguments of a syscall, as
      fcntl, for instance, may return fds, flags, etc, so need different
      return value formatters:
      
      	size_t formatter(unsigned long value, char *bf, size_t size);
      
      This gets so detached from 'perf trace' internals that we may well get
      all these and move to a tools/lib/syscall_beauty/ library at some point
      and use it in other tools/ living utilities.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-9aw8t22ztvnkuv26l6sw1c18@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b239ad28
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Beautify new write hint fcntl commands · 64e4561d
      Arnaldo Carvalho de Melo authored
      Those introduced by the commit c75b1d94
      
       ("fs: add fcntl() interface for
      setting/getting write life time hints"), tested using the proggie in that
      commit comment:
      
        # perf trace -e fcntl ./write_hint write_hint.c
        fcntl: F_GET_RW_HINT: Invalid argument
           0.000 ( 0.006 ms): write_hint/7576 fcntl(fd: 3, cmd: GET_RW_HINT, arg: 0x7ffc6c918da0) = -1 EINVAL Invalid argument
           0.014 ( 0.004 ms): write_hint/7576 fcntl(fd: 4, cmd: GETFL) = 33794
        # perf trace -e fcntl ./write_hint write_hint.c 1
        fcntl: F_SET_RW_HINT: Invalid argument
           0.000 ( 0.007 ms): write_hint/7578 fcntl(fd: 3, cmd: SET_RW_HINT, arg: 0x7fff03866d70) = -1 EINVAL Invalid argument
           0.019 ( 0.002 ms): write_hint/7578 fcntl(fd: 4, cmd: GETFL) = 33794
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-iacglkc99cchou87k62736dn@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      64e4561d
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty fcntl: Basic 'arg' beautifier · 9c47f667
      Arnaldo Carvalho de Melo authored
      
      
      Sometimes it should be printed as an hex number, like with F_SETLK,
      F_SETLKW and F_GETLK, that treat 'arg' as a struct flock pointer, in
      other cases it is just an integer.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-2gykg6enk7vos6q0m97hkgsg@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9c47f667
    • Arnaldo Carvalho de Melo's avatar
      tools include uapi asm-generic: Grab a copy of fcntl.h · 84d1d8a1
      Arnaldo Carvalho de Melo authored
      
      
      We'll need defines for beautifying fcntl arguments that are not
      available in older distros, these:
      
        trace/beauty/fcntl.c: In function 'syscall_arg__scnprintf_fcntl_arg':
        trace/beauty/fcntl.c:93: error: 'F_OFD_SETLK' undeclared (first use in this function)
        trace/beauty/fcntl.c:93: error: (Each undeclared identifier is reported only once
        trace/beauty/fcntl.c:93: error: for each function it appears in.)
        trace/beauty/fcntl.c:93: error: 'F_OFD_SETLKW' undeclared (first use in this function)
        trace/beauty/fcntl.c:93: error: 'F_OFD_GETLK' undeclared (first use in this function)
        trace/beauty/fcntl.c:94: error: 'F_GETOWN_EX' undeclared (first use in this function)
        trace/beauty/fcntl.c:94: error: 'F_SETOWN_EX' undeclared (first use in this function)
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-gvlw67a47e9z65jdunj4je5s@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      84d1d8a1
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Introduce syscall arg beautifier for long integers · 5dde91ed
      Arnaldo Carvalho de Melo authored
      
      
      Will be used in the fcntl arg beautifier, that nowadays formats as '%ld'
      because there is no explicit arg beautifier attached, but as we will
      have to first decide what beautifier to use (i.e. it may be a pointer,
      etc) then we need to have this exported as a separate beautifier to be
      called from there.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-d7bfs3m8m70j3zckeam0kk5d@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5dde91ed
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Export the "int" and "hex" syscall arg formatters · 2c2b1623
      Arnaldo Carvalho de Melo authored
      
      
      The most basic ones, for pointers, unaugmented fds, etc, to be used
      in the initial fcntl 'arg' beautifier.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-g0lugj4vv6p4jtge32hid6q6@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2c2b1623
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Allow accessing syscall args values in a syscall arg formatter · f9f83b33
      Arnaldo Carvalho de Melo authored
      
      
      For instance, fcntl's upcoming 'arg' formatter needs to look at the
      'cmd' value to decide how to format its value, sometimes it is a file
      flags, sometimes an fd, a pointer to a structure, etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-2tw2jfaqm48dtw8a4addghze@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f9f83b33
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Mask ignored fcntl 'arg' parameter · 9cb7cf86
      Arnaldo Carvalho de Melo authored
      
      
      A series of fcntl cmds ignore the third argument, so mask it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-6vtl3zq1tauamrhm8o380ptn@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9cb7cf86
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Only build tools/perf/trace/beauty/ when building 'perf trace' · 5ca55ab6
      Arnaldo Carvalho de Melo authored
      
      
      As it calls functions in builtin-trace.c.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-bt3lhw1rvy3jzbsp2fvvegb0@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5ca55ab6
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Export the strarrays scnprintf method · 274e86fd
      Arnaldo Carvalho de Melo authored
      
      
      As we'll call it from the fcntl cmd scnprintf method, that needs to look
      at the cmd to mask the next fcntl argument when it is ignored.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-fzlvkhew5vbxefneuciihgbc@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      274e86fd
    • Arnaldo Carvalho de Melo's avatar
      tools: Update include/uapi/linux/fcntl.h copy from the kernel · ca3cf049
      Arnaldo Carvalho de Melo authored
      To get the changes in the commit c75b1d94
      
       ("fs: add fcntl()
      interface for setting/getting write life time hints").
      
      Silencing this perf build warning:
      
        Warning: include/uapi/linux/fcntl.h differs from kernel
      
      We already beautify the fcntl cmd argument, so an upcoming cset will
      update the 'cmd' strarray to cover these new commands.
      
      The hints are in the 3rd arg, a pointer, so not yet supported in 'perf
      trace', for that we need to copy it somehow, probably using eBPF, a new
      attempt at doing that is planned.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-al471wzs3x48alql0tm3mnfa@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ca3cf049
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Beautify linux specific fcntl commands · 83a51694
      Arnaldo Carvalho de Melo authored
      
      
      We were only beautifying (transforming from an integer to its name) the
      non-linux specific fcntl syscall cmd args, fix it:
      
      Before:
      
        # perf trace -e fcntl -p 2472
           0.000 ( 0.017 ms): gnome-terminal/2472 fcntl(fd: 55, cmd: 1030) = 56
        ^C#
      
      After:
      
        # trace -e fcntl -p 2472
           0.000 ( 0.015 ms): gnome-terminal/2472 fcntl(fd: 55, cmd: DUPFD_CLOEXEC) = 56
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-zigsxruk4wbfn8iylboy9wzo@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      83a51694
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Remove F_ from some of the fcntl command strings · e000e5e3
      Arnaldo Carvalho de Melo authored
      
      
      The initial ones already had that "F_" prefix stripped to make things
      shorter, some hadn't, do it now.
      
      We do this to make the 'perf trace' output more compact. At some point
      perhaps the best thing to do is to have the tool do this stripping
      automatically, letting the user also decide if this is to be done or
      not. For now, be consistent.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-2iot106xkl8rgb0hb8zm3gq5@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e000e5e3
    • Jin Yao's avatar
      perf annotate: Implement visual marker for macro fusion · 7e63a13a
      Jin Yao authored
      
      
      For marking fused instructions clearly this patch adds a line before the
      first instruction of pair and joins it with the arrow of the jump to its
      target.
      
      For example, when "je" is selected in annotate view, the line before
      cmpl is displayed and joins the arrow of "je".
      
             │   ┌──cmpl   $0x0,argp_program_version_hook
       81.93 │   ├──je     20
             │   │  lock   cmpxchg %esi,0x38a9a4(%rip)
             │   │↓ jne    29
             │   │↓ jmp    43
       11.47 │20:└─→cmpxch %esi,0x38a999(%rip)
      
      That means the cmpl+je is a fused instruction pair and they should be
      considered together.
      
      Changelog:
      
      v3: Use Arnaldo's fix to improve the arrow origin rendering.  To get the
          evsel->evlist->env->cpuid, save the evsel in annotate_browser.
      
      v2: new function "ins__is_fused" to check if the instructions are fused.
      
      Signed-off-by: default avatarYao Jin <yao.jin@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.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@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1499403995-19857-3-git-send-email-yao.jin@linux.intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7e63a13a
    • Jin Yao's avatar
      perf annotate: Check for fused instructions · 69fb09f6
      Jin Yao authored
      
      
      Macro fusion merges two instructions to a single micro-op. Intel core
      platform performs this hardware optimization under limited
      circumstances.
      
      For example, CMP + JCC can be "fused" and executed /retired together.
      While with sampling this can result in the sample sometimes being on the
      JCC and sometimes on the CMP.  So for the fused instruction pair, they
      could be considered together.
      
      On Nehalem, fused instruction pairs:
      
        cmp/test + jcc.
      
      On other new CPU:
      
        cmp/test/add/sub/and/inc/dec + jcc.
      
      This patch adds an x86-specific function which checks if 2 instructions
      are in a "fused" pair. For non-x86 arch, the function is just NULL.
      
      Changelog:
      
      v4: Move the CPU model checking to symbol__disassemble and save the CPU
          family/model in arch structure.
      
          It avoids checking every time when jump arrow printed.
      
      v3: Add checking for Nehalem (CMP, TEST). For other newer Intel CPUs
          just check it by default (CMP, TEST, ADD, SUB, AND, INC, DEC).
      
      v2: Remove the original weak function. Arnaldo points out that doing it
          as a weak function that will be overridden by the host arch doesn't
          work. So now it's implemented as an arch-specific function.
      
      Committer fix:
      
      Do not access evsel->evlist->env->cpuid, ->env can be null, introduce
      perf_evsel__env_cpuid(), just like perf_evsel__env_arch(), also used in
      this function call.
      
      The original patch was segfaulting 'perf top' + annotation.
      
      But this essentially disables this fused instructions augmentation in
      'perf top', the right thing is to get the cpuid from the running kernel,
      left for a later patch tho.
      
      Signed-off-by: default avatarYao Jin <yao.jin@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.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@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1499403995-19857-2-git-send-email-yao.jin@linux.intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      69fb09f6
  2. Jul 12, 2017
    • Arnaldo Carvalho de Melo's avatar
      perf symbols: Accept zero as the kernel base address · 4b1303d0
      Arnaldo Carvalho de Melo authored
      
      
      Which is the case in S/390, where symbols were not being resolved
      because machine__get_kernel_start was only setting machine->kernel_start
      when the just successfully loaded kernel symtab had its map->start set
      to !0, when it was left at (1ULL << 63) assuming a partitioning of the
      address space for user/kernel, which is not the case in S/390 nor in
      Sparc.
      
      So just check if map__load() was successfull and set
      machine->kernel_start to zero, fixing kernel symbol resolution on S/390.
      
      Test performed by Thomas:
      
       ----
      
        I like this patch. I have done a new build and removed all my debug output to start
        from scratch. Without your patch I get this:
      
        # Samples: 4  of event 'cpu-clock'
        # Event count (approx.): 1000000
        #
        # Children      Self  Command  Shared Object     Symbol
        # ........  ........  .......  ................  ........................
            75.00%     0.00%  true     [unknown]         [k] 0x00000000004bedda
                    |
                    ---0x4bedda
                       |
                       |--50.00%--0x42693a
                       |          |
                       |           --25.00%--0x2a72e0
                       |                     0x2af0ca
                       |                     0x3d1003fe4c0
                       |
                        --25.00%--0x4272bc
                                  0x26fa84
      
        and with your patch (I just rebuilt the perf tool, nothing else and used the same
        perf.data file as input):
      
        # Samples: 4  of event 'cpu-clock'
        # Event count (approx.): 1000000
        #
        # Children      Self  Command  Shared Object               Symbol
        # ........  ........  .......  ..........................  ..................................
            75.00%     0.00%  true     [kernel.vmlinux]            [k] pgm_check_handler
                    |
                    ---pgm_check_handler
                       do_dat_exception
                       handle_mm_fault
                       __handle_mm_fault
                       filemap_map_pages
                       |
                       |--25.00%--rcu_read_lock_held
                       |          rcu_lockdep_current_cpu_online
                       |          0x3d1003ff4c0
                       |
                        --25.00%--lock_release
      
        Looks good to me....
       ----
      
      Reported-and-Tested-by: default avatarThomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Zvonko Kosic <zvonko.kosic@de.ibm.com>
      Link: http://lkml.kernel.org/n/tip-dk0n1uzmbe0tbthrpfqlx6bz@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4b1303d0
  3. Jul 11, 2017
    • Ingo Molnar's avatar
      Revert "perf/core: Drop kernel samples even though :u is specified" · 6a8a75f3
      Ingo Molnar authored
      This reverts commit cc1582c2
      
      .
      
      This commit introduced a regression that broke rr-project, which uses sampling
      events to receive a signal on overflow (but does not care about the contents
      of the sample). These signals are critical to the correct operation of rr.
      
      There's been some back and forth about how to fix it - but to not keep
      applications in limbo queue up a revert.
      
      Reported-by: default avatarKyle Huey <me@kylehuey.com>
      Acked-by: default avatarKyle Huey <me@kylehuey.com>
      Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20170628105600.GC5981@leverpostej
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      6a8a75f3
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo-4.13-20170710' of... · 1922eec4
      Ingo Molnar authored
      
      Merge tag 'perf-urgent-for-mingo-4.13-20170710' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
       - Fix attr.exclude_kernel setting for default cycles:p (Arnaldo Carvalho de Melo)
      
       - Fix broken arrow at row 0 connecting jmp instruction to its target in
         the annotate TUI (Jin Yao)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      1922eec4
    • Jin Yao's avatar
      perf annotate: Fix broken arrow at row 0 connecting jmp instruction to its target · 80f62589
      Jin Yao authored
      
      
      When the jump instruction is displayed at the row 0 in annotate view,
      the arrow is broken. An example:
      
       16.86 │   ┌──je     82
        0.01 │      movsd  (%rsp),%xmm0
             │      movsd  0x8(%rsp),%xmm4
             │      movsd  0x8(%rsp),%xmm1
             │      movsd  (%rsp),%xmm3
             │      divsd  %xmm4,%xmm0
             │      divsd  %xmm3,%xmm1
             │      movsd  (%rsp),%xmm2
             │      addsd  %xmm1,%xmm0
             │      addsd  %xmm2,%xmm0
             │      movsd  %xmm0,(%rsp)
             │82:   sub    $0x1,%ebx
       83.03 │    ↑ jne    38
             │      add    $0x10,%rsp
             │      xor    %eax,%eax
             │      pop    %rbx
             │    ← retq
      
      The patch increments the row number before checking with 0.
      
      Signed-off-by: default avatarYao Jin <yao.jin@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.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@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: stable@vger.kernel.org
      Fixes: 944e1abe
      
       ("perf ui browser: Add method to draw up/down arrow line")
      Link: http://lkml.kernel.org/r/1496901704-30275-1-git-send-email-yao.jin@linux.intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      80f62589