1. 04 Apr, 2017 1 commit
  2. 01 Apr, 2017 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.12-20170331' of... · fcc309e6
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-4.12-20170331' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      New features:
      
      - Beautify the statx syscall arguments in 'perf trace' (Arnaldo Carvalho de Melo)
      
          e.g.:
      
        System wide strace like session:
      
        # trace -e statx
         16612.967 ( 0.028 ms): statx/4562 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffef195d660) = 0
         36050.891 ( 0.007 ms): statx/4576 statx(dfd: CWD, filename: /etc/passwd, flags: SYMLINK_NOFOLLOW|STATX_DONT_SYNC, mask: BTIME, buffer: 0x7ffda9bf50f0) = 0
        ^C#
      
      User visible changes:
      
      - Handle unpaired raw_syscalls:sys_exit events in 'perf trace', i.e. we
        shouldn't try to calculate duration or print the timestamp for a missing
        matching raw_syscalls:sys_enter (Arnaldo Carvalho de Melo)
      
      - Do not print "cycles: 0" in perf report LBR lines in platforms not
        supporting 'cycles', such as Intel's Broadwell (Jin Yao)
      
      - Handle missing $HOME env var (Jiri Olsa)
      
      - Map 8-bit registers (al, bl, etc), not supported in uprobes_events, to
        the next best thing (ax, bx, etc) supported (Ravi Bangoria)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      fcc309e6
  3. 31 Mar, 2017 3 commits
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Beautify statx syscall 'flag' and 'mask' arguments · fd5cead2
      Arnaldo Carvalho de Melo authored
      To test it, build samples/statx/test_statx, which I did as:
      
        $ make headers_install
        $ cc -I ~/git/linux/usr/include samples/statx/test-statx.c -o /tmp/statx
      
      And then use perf trace on it:
      
        # perf trace -e statx /tmp/statx /etc/passwd
        statx(/etc/passwd) = 0
        results=7ff
          Size: 3496            Blocks: 8          IO Block: 4096    regular file
        Device: fd:00           Inode: 280156      Links: 1
        Access: (0644/-rw-r--r--)  Uid:     0   Gid:     0
        Access: 2017-03-29 16:01:01.650073438-0300
        Modify: 2017-03-10 16:25:14.156479354-0300
        Change: 2017-03-10 16:25:14.171479328-0300
           0.000 ( 0.007 ms): statx/30648 statx(dfd: CWD, filename: 0x7ef503f4, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff7ef4eb10) = 0
        #
      
      Using the test-stat.c options to change the mask:
      
        # perf trace -e statx /tmp/statx -O /etc/passwd > /dev/null
           0.000 ( 0.008 ms): statx/30745 statx(dfd: CWD, filename: 0x3a0753f4, flags: SYMLINK_NOFOLLOW, mask: BTIME, buffer: 0x7ffd3a0735c0) = 0
        #
        # perf trace -e statx /tmp/statx -A /etc/passwd > /dev/null
           0.000 ( 0.010 ms): statx/30757 statx(dfd: CWD, filename: 0xa94e63f4, flags: SYMLINK_NOFOLLOW|NO_AUTOMOUNT, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffea94e49d0) = 0
        #
        # trace --no-inherit -e statx /tmp/statx -F /etc/passwd > /dev/null
           0.000 ( 0.011 ms): statx(dfd: CWD, filename: 0x3b02d3f3, flags: SYMLINK_NOFOLLOW|STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffd3b02c850) = 0
        #
        # trace --no-inherit -e statx /tmp/statx -F -L /etc/passwd > /dev/null
           0.000 ( 0.008 ms): statx(dfd: CWD, filename: 0x15cff3f3, flags: STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff15cfdda0) = 0
        #
        # trace --no-inherit -e statx /tmp/statx -D -O /etc/passwd > /dev/null
           0.000 ( 0.009 ms): statx(dfd: CWD, filename: 0xfa37f3f3, flags: SYMLINK_NOFOLLOW|STATX_DONT_SYNC, mask: BTIME, buffer: 0x7ffffa37da20) = 0
        #
      
      Adding a probe to get the filename collected as well:
      
        # perf probe 'vfs_getname=getname_flags:72 pathname=result->name:string'
        Added new event:
          probe:vfs_getname    (on getname_flags:72 with pathname=result->name:string)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe:vfs_getname -aR sleep 1
      
        # trace --no-inherit -e statx /tmp/statx -D -O /etc/passwd > /dev/null
           0.169 ( 0.007 ms): statx(dfd: CWD, filename: /etc/passwd, flags: SYMLINK_NOFOLLOW|STATX_DONT_SYNC, mask: BTIME, buffer: 0x7ffda9bf50f0) = 0
        #
      
      Same technique could be used to collect and beautify the result put in
      the 'buffer' argument.
      
      Finally do a system wide 'perf trace' session looking for any use of statx,
      then run the test proggie with various flags:
      
        # trace -e statx
         16612.967 ( 0.028 ms): statx/4562 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffef195d660) = 0
         33064.447 ( 0.011 ms): statx/4569 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW|STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffc5484c790) = 0
         36050.891 ( 0.023 ms): statx/4576 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: BTIME, buffer: 0x7ffeb18b66e0) = 0
         38039.889 ( 0.023 ms): statx/4584 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff1db0ea90) = 0
        ^C#
      
      This one also starts moving the beautifiers from files directly included
      in builtin-trace.c to separate objects + a beauty.h header with
      prototypes, so that we can add test cases in tools/perf/tests/ to fire
      syscalls with various arguments and then get them intercepted as
      syscalls:sys_enter_foo or raw_syscalls:sys_enter + sys_exit to then
      format and check that the formatted output is the one we expect.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Howells <dhowells@redhat.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-xvzw8eynffvez5czyzidhrno@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fd5cead2
    • Jiri Olsa's avatar
      perf tools: Do not fail in case of empty HOME env variable · 3e00cbe8
      Jiri Olsa authored
      Currently we fail in the following case:
      
        $ unset HOME
        $ ./perf record ls
        $ echo $?
        255
      
      It's because the config code init fails due to a missing HOME variable
      value. Fix this by skipping the user config init if there's no HOME
      variable value.
      Reported-by: default avatarJan Stancek <jstancek@redhat.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170330144637.7468-1-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3e00cbe8
    • Arnaldo Carvalho de Melo's avatar
      tools include uapi: Grab copies of stat.h and fcntl.h · 67ef2879
      Arnaldo Carvalho de Melo authored
      We will need it to build tools/perf/trace/beauty/statx.h.
      
      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-nin41ve2fa63lrfbdr6x57yr@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      67ef2879
  4. 30 Mar, 2017 13 commits
  5. 29 Mar, 2017 1 commit
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Handle unpaired raw_syscalls:sys_exit event · fd2b2975
      Arnaldo Carvalho de Melo authored
      Which may happen when we start a tracing session and a thread is waiting
      for something like "poll" to return, in which case we better print "?"
      both for the syscall entry timestamp and for the duration.
      
      E.g.:
      
      Tracing existing mutt session:
      
        # perf trace -p `pidof mutt`
                ? (     ?   ): mutt/17135  ... [continued]: poll()) = 1
            0.027 ( 0.013 ms): mutt/17135 read(buf: 0x7ffcb3c42cef, count: 1) = 1
            0.047 ( 0.008 ms): mutt/17135 poll(ufds: 0x7ffcb3c42c50, nfds: 1, timeout_msecs: 1000) = 1
            0.059 ( 0.008 ms): mutt/17135 read(buf: 0x7ffcb3c42cef, count: 1) = 1
        <SNIP>
      
      Before it would print a large number because we'd do:
      
        ttrace->entry_time - trace->base_time
      
      And entry_time would be 0, while base_time would be the timestamp for
      the first event 'perf trace' reads, oops.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Claudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-wbcb93ofva2qdjd5ltn5eeqq@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fd2b2975
  6. 28 Mar, 2017 15 commits
  7. 27 Mar, 2017 6 commits
    • Tommi Rantala's avatar
      perf utils: Readlink /proc/self/exe to find the perf binary · 55f77128
      Tommi Rantala authored
      Simplification: it is easier to open /proc/self/exe than /proc/$pid/exe.
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20170322130624.21881-7-tommi.t.rantala@nokia.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      55f77128
    • Tommi Rantala's avatar
      perf utils: Null terminate buf in read_ftrace_printk() · d4b364df
      Tommi Rantala authored
      Ensure that the string that we read from the data file is null terminated.
      
      Valgrind was complaining:
      
        ==31357== Invalid read of size 1
        ==31357==    at 0x4EC8C1: __strtok_r_1c (string2.h:200)
        ==31357==    by 0x4EC8C1: parse_ftrace_printk (trace-event-parse.c:161)
        ==31357==    by 0x4F82A8: read_ftrace_printk (trace-event-read.c:204)
        ==31357==    by 0x4F82A8: trace_report (trace-event-read.c:468)
        ==31357==    by 0x4CD552: process_tracing_data (header.c:1576)
        ==31357==    by 0x4D3397: perf_file_section__process (header.c:2705)
        ==31357==    by 0x4D3397: perf_header__process_sections (header.c:2488)
        ==31357==    by 0x4D3397: perf_session__read_header (header.c:2925)
        ==31357==    by 0x4E71E2: perf_session__open (session.c:32)
        ==31357==    by 0x4E71E2: perf_session__new (session.c:139)
        ==31357==    by 0x429F5D: cmd_annotate (builtin-annotate.c:472)
        ==31357==    by 0x497150: run_builtin (perf.c:359)
        ==31357==    by 0x428CE0: handle_internal_command (perf.c:421)
        ==31357==    by 0x428CE0: run_argv (perf.c:467)
        ==31357==    by 0x428CE0: main (perf.c:614)
        ==31357==  Address 0x8ac0efb is 0 bytes after a block of size 1,963 alloc'd
        ==31357==    at 0x4C2DB9D: malloc (vg_replace_malloc.c:299)
        ==31357==    by 0x4F827B: read_ftrace_printk (trace-event-read.c:195)
        ==31357==    by 0x4F827B: trace_report (trace-event-read.c:468)
        ==31357==    by 0x4CD552: process_tracing_data (header.c:1576)
        ==31357==    by 0x4D3397: perf_file_section__process (header.c:2705)
        ==31357==    by 0x4D3397: perf_header__process_sections (header.c:2488)
        ==31357==    by 0x4D3397: perf_session__read_header (header.c:2925)
        ==31357==    by 0x4E71E2: perf_session__open (session.c:32)
        ==31357==    by 0x4E71E2: perf_session__new (session.c:139)
        ==31357==    by 0x429F5D: cmd_annotate (builtin-annotate.c:472)
        ==31357==    by 0x497150: run_builtin (perf.c:359)
        ==31357==    by 0x428CE0: handle_internal_command (perf.c:421)
        ==31357==    by 0x428CE0: run_argv (perf.c:467)
        ==31357==    by 0x428CE0: main (perf.c:614)
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20170322130624.21881-6-tommi.t.rantala@nokia.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d4b364df
    • Tommi Rantala's avatar
      perf utils: use sizeof(buf) - 1 in readlink() call · b7126ef7
      Tommi Rantala authored
      Ensure that we have space for the null byte in buf.
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20170322130624.21881-5-tommi.t.rantala@nokia.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b7126ef7
    • Tommi Rantala's avatar
      perf tests: Do not assume that readlink() returns a null terminated string · 0e6ba115
      Tommi Rantala authored
      Ensure that the string in buf is null terminated.
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20170322130624.21881-4-tommi.t.rantala@nokia.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0e6ba115
    • Tommi Rantala's avatar
      perf buildid: Do not assume that readlink() returns a null terminated string · 5a234211
      Tommi Rantala authored
      Valgrind was complaining:
      
        $ valgrind ./perf list >/dev/null
        ==11643== Memcheck, a memory error detector
        ==11643== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
        ==11643== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
        ==11643== Command: ./perf list
        ==11643==
        ==11643== Conditional jump or move depends on uninitialised value(s)
        ==11643==    at 0x4C30620: rindex (vg_replace_strmem.c:199)
        ==11643==    by 0x49DAA9: build_id_cache__origname (build-id.c:198)
        ==11643==    by 0x49E1C7: build_id_cache__valid_id (build-id.c:222)
        ==11643==    by 0x49E1C7: build_id_cache__list_all (build-id.c:507)
        ==11643==    by 0x4B9C8F: print_sdt_events (parse-events.c:2067)
        ==11643==    by 0x4BB0B3: print_events (parse-events.c:2313)
        ==11643==    by 0x439501: cmd_list (builtin-list.c:53)
        ==11643==    by 0x497150: run_builtin (perf.c:359)
        ==11643==    by 0x428CE0: handle_internal_command (perf.c:421)
        ==11643==    by 0x428CE0: run_argv (perf.c:467)
        ==11643==    by 0x428CE0: main (perf.c:614)
        [...]
      
      Additionally, a zero length result from readlink() is not very interesting.
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20170322130624.21881-3-tommi.t.rantala@nokia.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5a234211
    • Tommi Rantala's avatar
      perf buildid: Do not update SDT cache with null filename · 2ccc2202
      Tommi Rantala authored
      Valgrind was complaining:
      
        ==2633== Syscall param open(filename) points to unaddressable byte(s)
        ==2633==    at 0x5281CC0: __open_nocancel (syscall-template.S:84)
        ==2633==    by 0x537D38: open (fcntl2.h:53)
        ==2633==    by 0x537D38: get_sdt_note_list (symbol-elf.c:2017)
        ==2633==    by 0x5396FD: probe_cache__scan_sdt (probe-file.c:700)
        ==2633==    by 0x49EA2C: build_id_cache__add_sdt_cache (build-id.c:625)
        ==2633==    by 0x49EA2C: build_id_cache__add_s (build-id.c:697)
        ==2633==    by 0x49EE72: build_id_cache__add_b (build-id.c:717)
        ==2633==    by 0x49EE72: dso__cache_build_id (build-id.c:782)
        ==2633==    by 0x49F190: __dsos__cache_build_ids (build-id.c:793)
        ==2633==    by 0x49F190: machine__cache_build_ids (build-id.c:801)
        ==2633==    by 0x49F190: perf_session__cache_build_ids (build-id.c:815)
        ==2633==    by 0x4CD4F2: write_build_id (header.c:165)
        ==2633==    by 0x4D26F7: do_write_feat (header.c:2296)
        ==2633==    by 0x4D26F7: perf_header__adds_write (header.c:2335)
        ==2633==    by 0x4D26F7: perf_session__write_header (header.c:2414)
        ==2633==    by 0x43B324: __cmd_record (builtin-record.c:1154)
        ==2633==    by 0x43B324: cmd_record (builtin-record.c:1839)
        ==2633==    by 0x455A07: __cmd_record (builtin-kmem.c:1868)
        ==2633==    by 0x455A07: cmd_kmem (builtin-kmem.c:1944)
        ==2633==    by 0x497150: run_builtin (perf.c:359)
        ==2633==    by 0x428CE0: handle_internal_command (perf.c:421)
        ==2633==    by 0x428CE0: run_argv (perf.c:467)
        ==2633==    by 0x428CE0: main (perf.c:614)
        ==2633==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
      Signed-off-by: default avatarTommi Rantala <tommi.t.rantala@nokia.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tommi Rantala <tommi.t.rantala@nokia.com>
      Link: http://lkml.kernel.org/r/20170322130624.21881-2-tommi.t.rantala@nokia.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2ccc2202