1. 11 1月, 2018 1 次提交
  2. 10 1月, 2018 6 次提交
    • A
      perf report: Introduce --mmaps · 6439d7d1
      Arnaldo Carvalho de Melo 提交于
      Similar to --tasks, producing the same output plus /proc/<PID>/maps
      similar lines for each mmap record present in a perf.data file.
      
      Please note that not all mmaps are stored, for instance, some of the
      non-executable mmaps are only stored when 'perf record --data' is used,
      when the user wants to resolve data accesses in addition to asking for
      executable mmaps to get the DSO with symtabs.
      
      E.g.:
      
        # perf record sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.018 MB perf.data (7 samples) ]
        [root@jouet ~]# perf report --mmaps
        #      pid      tid     ppid  comm
                 0        0       -1 |swapper
              4137     4137       -1 |sleep
                                        5628a35a1000-5628a37aa000 r-xp 00000000 3147148 /usr/bin/sleep
                                        7fb65ad51000-7fb65b134000 r-xp 00000000 3149795 /usr/lib64/libc-2.26.so
                                        7fb65b134000-7fb65b35e000 r-xp 00000000 3149715 /usr/lib64/ld-2.26.so
                                        7ffd94b9f000-7ffd94ba1000 r-xp 00000000 0 [vdso]
        #
        # perf record sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.019 MB perf.data (8 samples) ]
        # perf report --mmaps
        #      pid      tid     ppid  comm
                 0        0       -1 |swapper
              4161     4161       -1 |sleep
                                        55afae69a000-55afae8a3000 r-xp 00000000 3147148 /usr/bin/sleep
                                        7f569f00d000-7f569f3f0000 r-xp 00000000 3149795 /usr/lib64/libc-2.26.so
                                        7f569f3f0000-7f569f61a000 r-xp 00000000 3149715 /usr/lib64/ld-2.26.so
                                        7fff6fffe000-7fff70000000 r-xp 00000000 0 [vdso]
        #
        # perf record time sleep 1
        0.00user 0.00system 0:01.00elapsed 0%CPU (0avgtext+0avgdata 2156maxresident)k
        0inputs+0outputs (0major+73minor)pagefaults 0swaps
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.019 MB perf.data (14 samples) ]
        # perf report --mmaps
        #      pid      tid     ppid  comm
                 0        0       -1 |swapper
              4281     4281       -1 |time
                                        560560dca000-560560fcf000 r-xp 00000000 3190458 /usr/bin/time
                                        7fc175196000-7fc175579000 r-xp 00000000 3149795 /usr/lib64/libc-2.26.so
                                        7fc175579000-7fc1757a3000 r-xp 00000000 3149715 /usr/lib64/ld-2.26.so
                                        7ffc924f6000-7ffc924f8000 r-xp 00000000 0 [vdso]
              4282     4282     4281 | sleep
                                         560560dca000-560560fcf000 r-xp 00000000 3190458 /usr/bin/time
                                         564b4de3c000-564b4e045000 r-xp 00000000 3147148 /usr/bin/sleep
                                         7f6a5a716000-7f6a5aaf9000 r-xp 00000000 3149795 /usr/lib64/libc-2.26.so
                                         7f6a5aaf9000-7f6a5ad23000 r-xp 00000000 3149715 /usr/lib64/ld-2.26.so
                                         7fc175196000-7fc175579000 r-xp 00000000 3149795 /usr/lib64/libc-2.26.so
                                         7fc175579000-7fc1757a3000 r-xp 00000000 3149715 /usr/lib64/ld-2.26.so
                                         7ffc924f6000-7ffc924f8000 r-xp 00000000 0 [vdso]
                                         7ffcec7e6000-7ffcec7e8000 r-xp 00000000 0 [vdso]
        #
      
      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: https://lkml.kernel.org/n/tip-zulwdlg5rfowogr1qznorvvc@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6439d7d1
    • J
      perf report: Add --tasks option to display monitored tasks · 930f8b34
      Jiri Olsa 提交于
      Add --tasks option to display monitored tasks stored in perf.data.
      Displaying pid/tid/ppid plus the command string aligned to distinguish
      parent and child tasks.
      
        $ perf record -a
        ...
        $ perf report --tasks
        #     pid     tid    ppid  comm
                0       0      -1 |swapper
                2       2       0 | kthreadd
            14080   14080       2 |  kworker/u17:1
                4       4       2 |  kworker/0:0H
                6       6       2 |  mm_percpu_wq
        ...
                1       1       0 | systemd
            23242   23242       1 |  firefox
            23242   23298   23242 |   Cache2 I/O
            23242   23304   23242 |   GMPThread
        ...
             1195    1195       1 |  login
             1611    1611    1195 |   bash
             1639    1639    1611 |    startx
             1663    1663    1639 |     xinit
             1673    1673    1663 |      xmonad-x86_64-l
            23939   23939    1673 |       xterm
            23941   23941   23939 |        bash
            23963   23963   23941 |         mutt
            24954   24954   23963 |          offlineimap
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180107160356.28203-13-jolsa@kernel.org
      [ Make it --tasks, plural, --task works as well, as its unambiguous ]
      [ Use machine__find_thread(), not findnew(), as pointed out by Namhyung ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      930f8b34
    • A
      perf trace: Beautify 'gettid' syscall result · 2d1073de
      Arnaldo Carvalho de Melo 提交于
      Before:
      
        # trace -a -e gettid sleep 0.01
      <SNIP>
           4.863 ( 0.005 ms): Chrome_ChildIO/26241 gettid() = 26241
           4.931 ( 0.004 ms): Chrome_IOThrea/26154 gettid() = 26154
           4.942 ( 0.001 ms): Chrome_IOThrea/26154 gettid() = 26154
           4.946 ( 0.001 ms): Chrome_IOThrea/26154 gettid() = 26154
           4.970 ( 0.002 ms): Chrome_IOThrea/26154 gettid() = 26154
        #
      
      After:
      
        # trace -a -e gettid sleep 0.01
           0.000 ( 0.009 ms): Chrome_IOThrea/26154 gettid() = 26154 (Chrome_IOThread)
      <SNIP>
           3.416 ( 0.002 ms): Chrome_ChildIO/26241 gettid() = 26241 (Chrome_ChildIOT)
           3.424 ( 0.001 ms): Chrome_ChildIO/26241 gettid() = 26241 (Chrome_ChildIOT)
           3.343 ( 0.002 ms): chrome/26116 gettid() = 26116 (chrome)
           3.386 ( 0.002 ms): Chrome_IOThrea/26154 gettid() = 26154 (Chrome_IOThread)
           4.003 ( 0.003 ms): Chrome_ChildIO/26241 gettid() = 26241 (Chrome_ChildIOT)
           4.031 ( 0.002 ms): Chrome_IOThrea/26154 gettid() = 26154 (Chrome_IOThread)
        #
      
      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: https://lkml.kernel.org/n/tip-kyg4gz2yy0vkrrh2vtq29u71@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2d1073de
    • J
      perf report: Add --stats option to display quick data statistics · a4a4d0a7
      Jiri Olsa 提交于
      Add --stats option to display quick data statistics of event numbers,
      without any further processing, like the one at the end of the perf
      report -D command.
      
        $ perf report --stat
      
        Aggregated stats:
                   TOTAL events:       4566
                    MMAP events:        113
                    LOST events:         19
                    COMM events:          3
                    FORK events:        400
                  SAMPLE events:       3315
                   MMAP2 events:         32
          FINISHED_ROUND events:        681
              THREAD_MAP events:          1
                 CPU_MAP events:          1
               TIME_CONV events:          1
      
      I found this useful when hunting lost events for another change.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180107160356.28203-12-jolsa@kernel.org
      [ Rename it to --stats, plural ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a4a4d0a7
    • J
      perf tools: Make the tool's warning messages optional · 075ca1eb
      Jiri Olsa 提交于
      I want to display the pure events status coming in the next patch and
      the tool's warnings are superfluous in the output. Making it optional,
      enabled by default.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180107160356.28203-11-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      075ca1eb
    • J
      perf script: Add support to display lost events · 3d7c27b6
      Jiri Olsa 提交于
      Adding option to display lost events:
      
        $ perf script --show-lost-events ...
         mplayer 13810 [002] 468011.402396:        100 cycles:ppp:  ff..
         mplayer 13810 [002] 468011.402396: PERF_RECORD_LOST lost 3880
         mplayer 13810 [002] 468011.402397:        100 cycles:ppp:  ff..
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180107160356.28203-10-jolsa@kernel.org
      [ Use PRIu64 when printing u64 values, fixing the build in some arches ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3d7c27b6
  3. 08 1月, 2018 15 次提交
    • J
      perf script: Add support to display sample misc field · 28a0b398
      Jiri Olsa 提交于
      Adding support to display sample misc field in form
      of letter for each bit:
      
        # perf script -F +misc ...
         sched-messaging  1414 K     28690.636582:       4590 cycles ...
         sched-messaging  1407 U     28690.636600:     325620 cycles ...
         sched-messaging  1414 K     28690.636608:      19473 cycles ...
        misc field  __________/
      
      The misc bits are assigned to following letters:
      
        PERF_RECORD_MISC_KERNEL        K
        PERF_RECORD_MISC_USER          U
        PERF_RECORD_MISC_HYPERVISOR    H
        PERF_RECORD_MISC_GUEST_KERNEL  G
        PERF_RECORD_MISC_GUEST_USER    g
        PERF_RECORD_MISC_MMAP_DATA*    M
        PERF_RECORD_MISC_COMM_EXEC     E
        PERF_RECORD_MISC_SWITCH_OUT    S
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180107160356.28203-9-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      28a0b398
    • J
      perf tools: Display perf_event_attr::namespaces debug info · db9fc765
      Jiri Olsa 提交于
      Display namespaces bit in -vv debug display:
      
        $ perf record -vv --namespaces ...
        ...
        perf_event_attr:
          size                             112
          ...
          namespaces                       1
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180107160356.28203-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      db9fc765
    • J
      perf tools: Enable LIBBABELTRACE by default · 24787afb
      Jiri Olsa 提交于
      There's no reason anymore to treat babel trace in a special way, because
      a) we no longer display its state b) the needed babeltrace library is
      now out and well adopted among distros.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180107160356.28203-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      24787afb
    • J
      perf script: Support time percent and multiple time ranges · 2ab046cd
      Jin Yao 提交于
      perf script has a --time option to limit the time range of output.  It
      only supports absolute time.
      
      Now this option is extended to support multiple time ranges and support
      the percent of time.
      
      For example:
      
      1. Select the first and second 10% time slices:
      
         perf script --time 10%/1,10%/2
      
      2. Select from 0% to 10% and 30% to 40% slices:
      
         perf script --time 0%-10%,30%-40%
      
      Changelog:
      
      v6: Fix the merge issue with latest perf/core branch.
          No functional changes.
      
      v5: Add checking of first/last sample time to detect if it's recorded
          in perf.data. If it's not recorded, returns error message to user.
      
      v4: Remove perf_time__skip_sample, only uses perf_time__ranges_skip_sample
      
      v3: Since the definitions of first_sample_time/last_sample_time
          are moved from perf_session to perf_evlist so change the
          related code.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1512738826-2628-7-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2ab046cd
    • J
      perf report: Support time percent and multiple time ranges · 5b969bc7
      Jin Yao 提交于
      perf report has a --time option to limit the time range of output.  It
      only supports absolute time.
      
      Now this option is extended to support multiple time ranges and support
      the percent of time.
      
      For example:
      
      1. Select the first and second 10% time slices:
      
      perf report --time 10%/1,10%/2
      
      2. Select from 0% to 10% and 30% to 40% slices:
      
      perf report --time 0%-10%,30%-40%
      
      Changelog:
      
      v6: Fix the merge issue with latest perf/core branch.
          No functional changes.
      
      v5: Add checking of first/last sample time to detect if it's recorded
          in perf.data. If it's not recorded, returns error message to user.
      
      v4: Remove perf_time__skip_sample, only uses perf_time__ranges_skip_sample
      
      v3: Since the definitions of first_sample_time/last_sample_time
          are moved from perf_session to perf_evlist so change the
          related code.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1512738826-2628-6-git-send-email-yao.jin@linux.intel.com
      [ Add missing colons at end of examples in the man page ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5b969bc7
    • J
      perf tools: Create function to perform multiple time range checking · 9a9b8b4b
      Jin Yao 提交于
      Previous patch supports the multiple time range.
      
      For example, select the first and second 10% time slices.
      perf report --time 10%/1,10%/2
      
      We need a function to check if a timestamp is in the ranges of
      [0, 10%) and [10%, 20%].
      
      Note that it includes the last element in [10%, 20%] but it doesn't
      include the last element in [0, 10%). It's to avoid the overlap.
      
      This patch implments a new function perf_time__ranges_skip_sample
      for this checking.
      
      Change log:
      
      v4: Let perf_time__ranges_skip_sample be compatible with
          perf_time__skip_sample when only one time range.
      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@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1512738826-2628-5-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9a9b8b4b
    • J
      perf tools: Create function to parse time percent · 13a70f35
      Jin Yao 提交于
      Current perf report/script/... have a --time option to limit the time
      range of output. But right now it only supports absolute time, add
      support for time percentage.
      
      For example:
      
      1. Select the second 10% time slice
         perf report --time 10%/2
      
      2. Select from 0% to 10% time slice
         perf report --time 0%-10%
      
      It also support the multiple time ranges.
      
      3. Select the first and second 10% time slices
         perf report --time 10%/1,10%/2
      
      4. Select from 0% to 10% and 30% to 40% slices
         perf report --time 0%-10%,30%-40%
      
      Changelog:
      
      v4: An issue is found. Following passes.
          perf script --time 10%/10x12321xsdfdasfdsafdsafdsa
      
          Now it uses strtol to replace atoi.
      
      Committer notes:
      
      This just puts in place the infrastructure, so the examples in this cset
      comment will only work later, after more patches in this series are
      applied.
      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@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1512738826-2628-4-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      13a70f35
    • J
      perf record: Record the first and last sample time in the header · 68588baf
      Jin Yao 提交于
      In the default 'perf record' configuration, all samples are processed,
      to create the HEADER_BUILD_ID table. So it's very easy to get the
      first/last samples and save the time to perf file header via the
      function write_sample_time().
      
      Later, at post processing time, perf report/script will fetch the time
      from perf file header.
      
      Committer testing:
      
        # perf record -a sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 2.099 MB perf.data (1101 samples) ]
        [root@jouet home]# perf report --header | grep "time of "
        # time of first sample : 22947.909226
        # time of last sample : 22948.910704
        #
        # perf report -D | grep PERF_RECORD_SAMPLE\(
        0 22947909226101 0x20bb68 [0x30]: PERF_RECORD_SAMPLE(IP, 0x4001): 0/0: 0xffffffffa21b1af3 period: 1 addr: 0
        0 22947909229928 0x20bb98 [0x30]: PERF_RECORD_SAMPLE(IP, 0x4001): 0/0: 0xffffffffa200d204 period: 1 addr: 0
        <SNIP>
        3 22948910397351 0x219360 [0x30]: PERF_RECORD_SAMPLE(IP, 0x4001): 28251/28251: 0xffffffffa22071d8 period: 169518 addr: 0
        0 22948910652380 0x20f120 [0x30]: PERF_RECORD_SAMPLE(IP, 0x4001): 0/0: 0xffffffffa2856816 period: 198807 addr: 0
        2 22948910704034 0x2172d0 [0x30]: PERF_RECORD_SAMPLE(IP, 0x4001): 0/0: 0xffffffffa2856816 period: 88111 addr: 0
        #
      
      Changelog:
      
      v7: Just update the patch description according to Arnaldo's suggestion.
      
      v6: Currently '--buildid-all' is not enabled at default. So the walking
          on all samples is the default operation. There is no big overhead
          to calculate the timestamp boundary in process_sample_event handler
          once we already go through all samples. So the timestamp boundary
          calculation is enabled by default when '--buildid-all' is not enabled.
      
          While if '--buildid-all' is enabled, we creates a new option
          "--timestamp-boundary" for user to decide if it enables the
          timestamp boundary calculation.
      
      v5: There is an issue that the sample walking can only work when
          '--buildid-all' is not enabled. So we need to let the walking
          be able to work even if '--buildid-all' is enabled and let the
          processing skips the dso hit marking for this case.
      
          At first, I want to provide a new option "--record-time-boundaries".
          While after consideration, I think a new option is not very
          necessary.
      
      v3: Remove the definitions of first_sample_time and last_sample_time
          from struct record and directly save them in perf_evlist.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1512738826-2628-3-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      68588baf
    • J
      perf header: Add infrastructure to record first and last sample time · 6011518d
      Jin Yao 提交于
      perf report/script/... have a --time option to limit the time range of
      output. That's very useful to slice large traces, e.g. when processing
      the output of perf script for some analysis.
      
      But right now --time only supports absolute time. Also there is no fast
      way to get the start/end times of a given trace except for looking at
      it.  This makes it hard to e.g. only decode the first half of the trace,
      which is useful for parallelization of scripts
      
      Another problem is that perf records are variable size and there is no
      synchronization mechanism. So the only way to find the last sample
      reliably would be to walk all samples. But we want to avoid that in perf
      report/...  because it is already quite expensive. That is why storing
      the first sample time and last sample time in perf record is better.
      
      This patch creates a new header feature type HEADER_SAMPLE_TIME and
      related ops. Save the first sample time and the last sample time to the
      feature section in perf file header. That will be done when, for
      instance, processing build-ids, where we already have to process all
      samples to create the build-id table, take advantage of that to further
      amortize that processing by storing HEADER_SAMPLE_TIME to make 'perf
      report/script' faster when using --time.
      
      Committer testing:
      
      After this patch is applied the header is written with zeroes, we need
      the next patch, for "perf record" to actually write the timestamps:
      
        # perf report -D | grep PERF_RECORD_SAMPLE\(
        22501155244406 0x44f0 [0x28]: PERF_RECORD_SAMPLE(IP, 0x4001): 25016/25016: 0xffffffffa21be8c5 period: 1 addr: 0
        <SNIP>
        22501155793625 0x4a30 [0x28]: PERF_RECORD_SAMPLE(IP, 0x4001): 25016/25016: 0xffffffffa21ffd50 period: 2828043 addr: 0
        # perf report --header | grep "time of "
        # time of first sample : 0.000000
        # time of last sample : 0.000000
        #
      
      Changelog:
      
      v7: 1. Rebase to latest perf/core branch.
      
          2. Add following clarification in patch description according to
             Arnaldo's suggestion.
      
             "That will be done when, for instance, processing build-ids,
      	where we already have to process all samples to create the
      	build-id table, take advantage of that to further amortize
      	that processing by storing HEADER_SAMPLE_TIME to make
      	'perf report/script' faster when using --time."
      
      v4: Use perf script time style for timestamp printing. Also add with
          the printing of sample duration.
      
      v3: Remove the definitions of first_sample_time/last_sample_time from
          perf_session. Just define them in perf_evlist
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1512738826-2628-2-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6011518d
    • J
      perf report: Fix a no annotate browser displayed issue · 40c39e30
      Jin Yao 提交于
      When enabling '-b' option in perf record, for example,
      
        perf record -b ...
        perf report
      
      and then browsing the annotate browser from perf report (press 'A'), it
      would fail (annotate browser can't be displayed).
      
      It's because the '.add_entry_cb' op of struct report is overwritten by
      hist_iter__branch_callback() in builtin-report.c. But this function doesn't do
      something like mapping symbols and sources. So next, do_annotate() will return
      directly.
      
              notes = symbol__annotation(act->ms.sym);
              if (!notes->src)
                      return 0;
      
      This patch adds the lost code to hist_iter__branch_callback (refer to
      hist_iter__report_callback).
      
      v2:
      
      Fix a crash bug when perform 'perf report --stdio'.
      
      The reason is that we init the symbol annotation only in browser mode, it
      doesn't allocate/init resources for stdio mode.
      
      So now in hist_iter__branch_callback(), it will return directly if it's not in
      browser mode.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Tested-by: NArnaldo 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/1514284963-18587-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      40c39e30
    • J
      perf report: Fix a wrong offset issue when using /proc/kcore · 935f5a9d
      Jin Yao 提交于
      When a valid vmlinux is not found, 'perf report' falls back to look at
      /proc/kcore. In this case, it will report the impossible large offset.
      
      For example:
      
        # perf record -b -e cycles:k find /etc/ > /dev/null
        # perf report --stdio --branch-history
      
          22.77%  _vm_normal_page+18446603336221188162
                  |
                  ---page_remove_rmap +18446603336221188324
                     page_remove_rmap +18446603336221188487 (cycles:5)
                     unlock_page_memcg +18446603336221188096
                     page_remove_rmap +18446603336221188327 (cycles:1)
      
      The issue is the value which is passed to parameter 'addr' in
      __get_srcline() is the objdump address. It's not correct if we calculate
      the offset by using 'addr - sym->start'.
      
      This patch creates a new parameter 'ip' in __get_srcline(). It is not
      converted to objdump address.
      
      With this patch, the perf report output is:
      
          22.77%  _vm_normal_page+66
                  |
                  ---page_remove_rmap +228
                     page_remove_rmap +391 (cycles:5)
                     unlock_page_memcg +0
                     page_remove_rmap +231 (cycles:1)
                     page_remove_rmap +236
      
      Committer testing:
      
      Make sure you get any valid vmlinux out of the way, using '-v' on the
      'perf report' case and deleting it from places where perf searches them,
      like your kernel build dir and the build-id cache, in ~/.debug/.
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Tested-by: NArnaldo 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/1514564812-17344-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      935f5a9d
    • W
      perf tools: Fix compile error with libunwind x86 · 44df1afd
      Wang Nan 提交于
      Fix a compile error:
      
       ...
         CC       util/libunwind/x86_32.o
       In file included from util/libunwind/x86_32.c:33:0:
       util/libunwind/../../arch/x86/util/unwind-libunwind.c: In function 'libunwind__x86_reg_id':
       util/libunwind/../../arch/x86/util/unwind-libunwind.c:110:11: error: 'EINVAL' undeclared (first use in this function)
          return -EINVAL;
                  ^
       util/libunwind/../../arch/x86/util/unwind-libunwind.c:110:11: note: each undeclared identifier is reported only once for each function it appears in
       mv: cannot stat 'util/libunwind/.x86_32.o.tmp': No such file or directory
       make[4]: *** [util/libunwind/x86_32.o] Error 1
       make[3]: *** [util] Error 2
       make[2]: *** [libperf-in.o] Error 2
       make[1]: *** [sub-make] Error 2
       make: *** [all] Error 2
      
      It happens when libunwind-x86 feature is detected.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20171206015040.114574-1-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      44df1afd
    • A
      perf test bpf: Hook on epoll_pwait() · e0337f4f
      Arnaldo Carvalho de Melo 提交于
      The 'perf test bpf' was hooking a eBPF program on the SyS_epoll_wait()
      kernel function, that was what the epoll_wait() glibc function ended up
      calling, but since at least glibc 2.26, the one that comes with, for
      instance, Fedora 27, glibc ends up calling SyS_epoll_pwait() when
      epoll_wait() is used, causing this 'perf test' entry to fail.
      
      So switch to using epoll_pwait() and hook the eBPF program to the
      SyS_epoll_pwait() kernel function to make it work on a wider range of
      glibc and kernel versions.
      Tested-by: NWang Nan <wangnan0@huawei.com>
      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>
      Link: https://lkml.kernel.org/n/tip-zynvquy63er8s5mrgsz65pto@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e0337f4f
    • A
      perf test bpf: Use designated struct field initializers · 13cb2d0f
      Arnaldo Carvalho de Melo 提交于
      To follow standard practice in the kernel sources, documenting the
      initialization better and helping quickly finding the value for some
      field in a struct with many entries.
      
      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: https://lkml.kernel.org/n/tip-syn3hz9hz7ukxlxbx5x6hv20@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      13cb2d0f
    • A
      perf test bpf: Improve message about expected samples · 6703c977
      Arnaldo Carvalho de Melo 提交于
      When failing on one of the BPF tests we were just stating:
      
        BPF filter result incorrect
      
      Add some more info to help figuring out the problem:
      
       BPF filter result incorrect, expected 56, got 0 samples
      
      This came out while investigating this failure, first seen after
      updating the kernel to the 4.15.0-rc6 tag:
      
        [root@jouet ~]# perf test bpf
        39: BPF filter               :
        39.1: Basic BPF filtering    : FAILED!
        39.2: BPF pinning            : Skip
        39.3: BPF prologue generation: Skip
        39.4: BPF relocation checker : Skip
        [root@jouet ~]#
      
      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: https://lkml.kernel.org/n/tip-403npu7daupv6b2bmxliv5pk@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6703c977
  4. 27 12月, 2017 18 次提交
    • J
      perf tools: Auto-complete for events with ':' · 5d4fd9c8
      Jin Yao 提交于
      It's a follow up patch for a previous patch "perf tool: Return all
      events as auto-completions after comma".
      
      With this patch, auto-completion can work well for events with a ':'.
      For example:
      
        root@skl:/tmp# perf stat -e block:block_<TAB>
        block:block_bio_backmerge   block:block_rq_complete
        block:block_bio_bounce      block:block_rq_insert
        block:block_bio_complete    block:block_rq_issue
        block:block_bio_frontmerge  block:block_rq_remap
        block:block_bio_queue       block:block_rq_requeue
        block:block_bio_remap       block:block_sleeprq
        block:block_dirty_buffer    block:block_split
        block:block_getrq           block:block_touch_buffer
        block:block_plug            block:block_unplug
      
        root@skl:/tmp# perf stat -e block:block_rq_<TAB>
        block:block_rq_complete  block:block_rq_issue     block:block_rq_requeue
        block:block_rq_insert    block:block_rq_remap
      
        root@skl:/tmp# perf stat -e block:block_rq_complete<TAB>
        block:block_rq_complete
      
        root@skl:/tmp# perf stat -e block:block_rq_complete
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Tested-by: NArnaldo 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/1513973758-19109-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5d4fd9c8
    • J
      perf tools: Return all events as auto-completions after comma · 34c16db0
      Jin Yao 提交于
      It's a follow up for one previous patch "perf tool: Improve bash command
      line auto-complete for multiple events with comma."
      
      It fixes an issue that no events are displayed when <TAB> is directly
      typed after comma.
      
      With this patch, now the result is:
      
        root@skl:/tmp# perf stat -e cpu-cycles,<TAB>
        Display all 2389 possibilities? (y or n)
        alarmtimer:alarmtimer_cancel
        alarmtimer:alarmtimer_fired
        alarmtimer:alarmtimer_start
        alarmtimer:alarmtimer_suspend
        alignment-faults
        arith.divider_active
        BAClear_Cost
        baclears.any
        block:block_bio_backmerge
        block:block_bio_bounce
        block:block_bio_complete
        block:block_bio_frontmerge
        block:block_bio_queue
        block:block_bio_remap
        block:block_dirty_buffer
        block:block_getrq
        block:block_plug
        block:block_rq_complete
        block:block_rq_insert
        block:block_rq_issue
        block:block_rq_remap
        block:block_rq_requeue
        block:block_sleeprq
        --More--
      
      One remaining issue is that the auto-completions doesn't work well
      for the event with ':'. For example, clk:clk_enable.
      
      Because ':' is set as WORDBREAK by default in bash. Need more work
      for this case.
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Tested-by: NArnaldo 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/1513940255-16528-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      34c16db0
    • J
      perf tool: Improve bash command line auto-complete for multiple events with comma · 74cd5815
      Jin Yao 提交于
      perf has perf-completion.sh to define command line auto-completion in
      bash/zsh.
      
      For record/stat -e it works for single events, but isn't working when
      specifying multiple events with comma.
      
      It would be very useful if it could be fixed to make it easier by
      supporting multiple events, comma separated.
      
      With this patch, the result can be like this:
      
      1. Support the events returned from 'perf list --raw-dump'
      
      root@skl:/tmp# perf stat -e cpu/cache<TAB>
      cpu/cache-misses/      cpu/cache-references/
      
      root@skl:/tmp# perf stat -e cpu/cache-misses/,cpu/branch-<TAB>
      cpu/branch-instructions/  cpu/branch-misses/
      
      root@skl:/tmp# perf stat -e cpu/cache-misses/,cpu/branch-i<TAB>
      root@skl:/tmp# perf stat -e cpu/cache-misses/,cpu/branch-instructions/
      
      2. Support the events listed in /sys/bus/event_source/devices/cpu/events
      
      root@skl:/tmp# perf stat -e cycle<TAB>
      cycle_activity.cycles_l1d_miss  cycle_activity.stalls_l3_miss
      cycle_activity.cycles_l2_miss   cycle_activity.stalls_mem_any
      cycle_activity.cycles_l3_miss   cycle_activity.stalls_total
      cycle_activity.cycles_mem_any   cycles-ct
      cycle_activity.stalls_l1d_miss  cycles-t
      cycle_activity.stalls_l2_miss
      
      root@skl:/tmp# perf stat -e cycles-<TAB>
      cycles-ct  cycles-t
      
      root@skl:/tmp# perf stat -e cycles-t,cpu/c<TAB>
      cpu/cache-misses/      cpu/cpu-cycles/        cpu/cycles-t/
      cpu/cache-references/  cpu/cycles-ct/
      
      root@skl:/tmp# perf stat -e cycles-t,cpu/cache-<TAB>
      cpu/cache-misses/      cpu/cache-references/
      
      root@skl:/tmp# perf stat -e cycles-t,cpu/cache-misses/
      
      3. Support the uppercase event which is with prefix "cpu/"
      
      root@skl:/tmp# perf stat -e cpu/c<TAB>
      cpu/cache-misses/      cpu/cpu-cycles/        cpu/cycles-t/
      cpu/cache-references/  cpu/cycles-ct/
      
      root@skl:/tmp# perf stat -e cpu/cache-misses/,cpu/C<TAB>
      cpu/CACHE-MISSES/      cpu/CPU-CYCLES/        cpu/CYCLES-T/
      cpu/CACHE-REFERENCES/  cpu/CYCLES-CT/
      
      root@skl:/tmp# perf stat -e cpu/cache-misses/,cpu/CACHE-REFERENCES/
      
      Note that:
      
      a) This patch only supports bash.
      
      b) It doesn't support the cases like {},{} or {...,...}.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Tested-by: NArnaldo 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/1513848370-8098-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      74cd5815
    • K
      perf probe arm64: Fix symbol fixup issues due to ELF type · f1031c8d
      Kim Phillips 提交于
      On an arm64 machine running a CONFIG_RANDOMIZE_BASE=y kernel, perf
      kernel symbol resolution fails.  Debugging saw symsrc_init calling the
      default elf__needs_adjust_symbols() where checks for an ET_DYN (3)
      ehdr.e_type failed when they should have succeeded.
      
      Fix by adopting powerpc version of the weak elf__needs_adjust_symbols()
      function, as done in commit d2332098 ("perf probe ppc: Fix symbol
      fixup issues due to ELF type").
      
      Prior to this patch, perf test 1 would fail:
      
        $ sudo oldperf test -v 1 |& head
         1: vmlinux symtab matches kallsyms                       :
        test child forked, pid 33374
        Looking at the vmlinux_path (8 entries long)
        Using /usr/lib/debug/boot/vmlinux for symbols
        ERR : 0xfffe0000100f1000: do_undefinstr not on kallsyms
        ERR : 0xfffe0000100f1320: do_sysinstr not on kallsyms
        ERR : 0xfffe0000100f13b0: do_debug_exception not on kallsyms
        ERR : 0xfffe0000100f1498: do_mem_abort not on kallsyms
        ERR : 0xfffe0000100f1580: do_sp_pc_abort not on kallsyms
        ...
      
      After applying this patch, perf test 1 now succeeds:
      
        $ sudo ./newperf test -v 1 |& head
         1: vmlinux symtab matches kallsyms                       :
        test child forked, pid 33378
        Looking at the vmlinux_path (8 entries long)
        Using /usr/lib/debug/boot/vmlinux for symbols
        WARN: 0xffff000008081000: diff name v: do_undefinstr k: __exception_text_start
        WARN: 0xffff0000080819e8: diff name v: __irqentry_text_end k: __softirqentry_text_start
        WARN: 0xffff000008081d08: diff name v: __entry_text_start k: __softirqentry_text_end
        WARN: 0xffff00000809db5c: diff name v: flush_icache_range k: __flush_cache_user_range
        WARN: 0xffff000008101908: diff name v: sys_ni_syscall k: sys_vm86old
        ...
      Signed-off-by: NKim Phillips <kim.phillips@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20171214175242.e30450f17f93ad675d968fa3@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f1031c8d
    • M
      perf evsel: Enable ignore_missing_thread for pid option · ca800068
      Mengting Zhang 提交于
      While monitoring a multithread process with pid option, perf sometimes
      may return sys_perf_event_open failure with 3(No such process) if any of
      the process's threads die before we open the event. However, we want
      perf continue monitoring the remaining threads and do not exit with
      error.
      
      Here, the patch enables perf_evsel::ignore_missing_thread for -p option
      to ignore complete failure if any of threads die before we open the event.
      But it may still return sys_perf_event_open failure with 22(Invalid) if we
      monitors several event groups.
      
              sys_perf_event_open: pid 28960  cpu 40  group_fd 118202  flags 0x8
              sys_perf_event_open: pid 28961  cpu 40  group_fd 118203  flags 0x8
              WARNING: Ignored open failure for pid 28962
              sys_perf_event_open: pid 28962  cpu 40  group_fd [118203]  flags 0x8
              sys_perf_event_open failed, error -22
      
      That is because when we ignore a missing thread, we change the thread_idx
      without dealing with its fds, FD(evsel, cpu, thread). Then get_group_fd()
      may return a wrong group_fd for the next thread and sys_perf_event_open()
      return with 22.
      
              sys_perf_event_open(){
                 ...
                 if (group_fd != -1)
                     perf_fget_light()//to get corresponding group_leader by group_fd
                 ...
                 if (group_leader)
                    if (group_leader->ctx->task != ctx->task)//should on the same task
                         goto err_context
                 ...
              }
      
      This patch also fixes this bug by introducing perf_evsel__remove_fd() and
      update_fds to allow removing fds for the missing thread.
      
      Changes since v1:
      - Change group_fd__remove() into a more genetic way without changing code logic
      - Remove redundant condition
      
      Changes since v2:
      - Use a proper function name and add some comment.
      - Multiline comment style fixes.
      
      Committer testing:
      
      Before this patch the recently added 'perf stat --per-thread' for system
      wide counting would race while enumerating all threads using /proc:
      
        [root@jouet ~]# perf stat --per-thread
        failed to parse CPUs map: No such file or directory
      
         Usage: perf stat [<options>] [<command>]
      
            -C, --cpu <cpu>       list of cpus to monitor in system-wide
            -a, --all-cpus        system-wide collection from all CPUs
        [root@jouet ~]# perf stat --per-thread
        failed to parse CPUs map: No such file or directory
      
         Usage: perf stat [<options>] [<command>]
      
            -C, --cpu <cpu>       list of cpus to monitor in system-wide
            -a, --all-cpus        system-wide collection from all CPUs
        [root@jouet ~]#
      
      When, say, the kernel was being built, so lots of shortlived threads,
      after this patch this doesn't happen.
      Signed-off-by: NMengting Zhang <zhangmengting@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Cheng Jian <cj.chengjian@huawei.com>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1513148513-6974-1-git-send-email-zhangmengting@huawei.com
      [ Remove one use 'evlist' alias variable ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ca800068
    • H
      perf s390: Always build with -fPIC · a9a3f1d1
      Hendrik Brueckner 提交于
      On s390, object files must be compiled with position-indepedent code in
      order to be incrementally linked or linked to shared libraries.
      
      Therefore, add -fPIC to the CFLAGS for s390 to ensure each object file
      is built properly.
      Reported-by: NJonathan Hermann <jonathan.hermann@de.ibm.com>
      Signed-off-by: NHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: linux s390 list <linux-s390@vger.kernel.org>
      Link: https://lkml.kernel.org/r/20171207080951.GC4889@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a9a3f1d1
    • A
      Revert "perf s390: Always build with -fPIC" · 922991c2
      Arnaldo Carvalho de Melo 提交于
      This one made x86 always build with -fPIC, when the intention was for
      s390 to be built that way, due to a rebase mistake.
      Reported-by: NHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      This reverts commit 1dc4ddf1.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      922991c2
    • M
      perf test shell: Fix check open filename arg using 'perf trace' · 69b5c953
      Michael Petlan 提交于
      Commit f231af78 ("perf test shell: Fix check open filename arg using
      'perf trace' on s390x") added an exception for s390x to use openat()
      instead of open() in the test that intercepts a open syscall to look for
      the filename argument as obtained by the vfs_getname 'perf probe' it
      puts in place at the getname_flags kernel function.
      
      Its not just s390x that uses openat() instead of open(), so use 'perf
      list' to look for the syscall:sys_enter_open(at)? present in the system
      being tested instead of checking if the system is s390x.
      
      In fact Namhyung pointed out that glibc 2.26 changed this behaviour, as
      described in https://lwn.net/Articles/738694/, so systems where glibc is
      >= 2.26 will need this patch for this test to work, which already took
      place in some distros for architectures such as s390x, while Fedora 26
      x86_64 is at glibc 2.25, i.e. still uses open().
      Signed-off-by: NMichael Petlan <mpetlan@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NThomas Richter <tmricht@linux.vnet.ibm.com>
      Link: https://lkml.kernel.org/r/ab23fe42-1080-a46b-503e-744e097f414f@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>
      LPU-Reference: 1275675985.12835754.1513095723265.JavaMail.zimbra@redhat.com
      Link: https://lkml.kernel.org/n/tip-j2wbz9av1rw3thr3t0g4dtuk@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      69b5c953
    • J
      perf evsel: Fix swap for samples with raw data · f9d8adb3
      Jiri Olsa 提交于
      When we detect a different endianity we swap event before processing.
      It's tricky for samples because we have no idea what's inside. We treat
      it as an array of u64s, swap them and later on we swap back parts which
      are different.
      
      We mangle this way also the tracepoint raw data, which ends up in report
      showing wrong data:
      
        1.95%  comm=Q^B pid=29285 prio=16777216 target_cpu=000
        1.67%  comm=l^B pid=0 prio=16777216 target_cpu=000
      
      Luckily the traceevent library handles the endianity by itself (thank
      you Steven!), so we can pass the RAW data directly in the other
      endianity.
      
        2.51%  comm=beah-rhts-task pid=1175 prio=120 target_cpu=002
        2.23%  comm=kworker/0:0 pid=11566 prio=120 target_cpu=000
      
      The fix is basically to swap back the raw data if different endianity is
      detected.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/20171129184346.3656-1-jolsa@kernel.org
      [ Add util/memswap.c to python-ext-sources to link missing mem_bswap_64() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f9d8adb3
    • M
      perf probe: Support escaped character in parser · c588d158
      Masami Hiramatsu 提交于
      Support the special characters escaped by '\' in parser.  This allows
      user to specify versions directly like below.
      
        =====
        # ./perf probe -x /lib64/libc-2.25.so malloc_get_state\\@GLIBC_2.2.5
        Added new event:
          probe_libc:malloc_get_state (on malloc_get_state@GLIBC_2.2.5 in /usr/lib64/libc-2.25.so)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe_libc:malloc_get_state -aR sleep 1
      
        =====
      
      Or, you can use separators in source filename, e.g.
      
        =====
        # ./perf probe -x /opt/test/a.out foo+bar.c:3
        Semantic error :There is non-digit character in offset.
          Error: Command Parse Error.
        =====
      
      Usually "+" in source file cause parser error, but
      
        =====
        # ./perf probe -x /opt/test/a.out foo\\+bar.c:4
        Added new event:
          probe_a:main         (on @foo+bar.c:4 in /opt/test/a.out)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe_a:main -aR sleep 1
        =====
      
      escaped "\+" allows you to specify that.
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: NThomas Richter <tmricht@linux.vnet.ibm.com>
      Acked-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: bhargavb <bhargavaramudu@gmail.com>
      Cc: linux-rt-users@vger.kernel.org
      Link: http://lkml.kernel.org/r/151309111236.18107.5634753157435343410.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c588d158
    • M
      perf string: Add {strdup,strpbrk}_esc() · 1e9f9e8a
      Masami Hiramatsu 提交于
      To support the special characters escaped by '\' in 'perf probe' event parser.
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: NThomas Richter <tmricht@linux.vnet.ibm.com>
      Acked-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: bhargavb <bhargavaramudu@gmail.com>
      Cc: linux-rt-users@vger.kernel.org
      Link: http://lkml.kernel.org/r/151275052163.24652.18205979384585484358.stgit@devbox
      [ Split from a larger patch ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1e9f9e8a
    • M
      perf probe: Find versioned symbols from map · 4b3a2716
      Masami Hiramatsu 提交于
      Commit d8040645 ("perf symbols: Allow user probes on versioned
      symbols") allows user to find default versioned symbols (with "@@") in
      map. However, it did not enable normal versioned symbol (with "@") for
      perf-probe.  E.g.
      
        =====
        # ./perf probe -x /lib64/libc-2.25.so malloc_get_state
        Failed to find symbol malloc_get_state in /usr/lib64/libc-2.25.so
          Error: Failed to add events.
        =====
      
      This solves above issue by improving perf-probe symbol search function,
      as below.
      
        =====
        # ./perf probe -x /lib64/libc-2.25.so malloc_get_state
        Added new event:
          probe_libc:malloc_get_state (on malloc_get_state in /usr/lib64/libc-2.25.so)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe_libc:malloc_get_state -aR sleep 1
      
        # ./perf probe -l
          probe_libc:malloc_get_state (on malloc_get_state@GLIBC_2.2.5 in /usr/lib64/libc-2.25.so)
        =====
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: NThomas Richter <tmricht@linux.vnet.ibm.com>
      Acked-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: bhargavb <bhargavaramudu@gmail.com>
      Cc: linux-rt-users@vger.kernel.org
      Link: http://lkml.kernel.org/r/151275049269.24652.1639103455496216255.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4b3a2716
    • M
      perf probe: Add __return suffix for return events · e63c625a
      Masami Hiramatsu 提交于
      Add __return suffix for function return events automatically. Without
      this, user have to give --force option and will see the number suffix
      for each event like "function_1", which is not easy to recognize.
      Instead, this adds __return suffix to it automatically.  E.g.
      
        =====
        # ./perf probe -x /lib64/libc-2.25.so 'malloc*%return'
        Added new events:
          probe_libc:malloc_printerr__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_consolidate__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_check__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_hook_ini__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_trim__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_usable_size__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_stats__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_info__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:mallochook__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_get_state__return (on malloc*%return in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_set_state__return (on malloc*%return in /usr/lib64/libc-2.25.so)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe_libc:malloc_set_state__return -aR sleep 1
      
        =====
      Reported-by: NArnaldo Carvalho de Melo <acme@kernel.org>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Acked-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Reviewed-by: NThomas Richter <tmricht@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: bhargavb <bhargavaramudu@gmail.com>
      Cc: linux-rt-users@vger.kernel.org
      Link: http://lkml.kernel.org/r/151275046418.24652.6696011972866498489.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e63c625a
    • M
      perf probe: Cut off the version suffix from event name · a3110cd9
      Masami Hiramatsu 提交于
      Cut off the version suffix (e.g. @GLIBC_2.2.5 etc.) from automatic
      generated event name. This fixes wildcard event adding like below case;
      
        =====
        # perf probe -x /lib64/libc-2.25.so malloc*
        Internal error: "malloc_get_state@GLIBC_2" is wrong event name.
          Error: Failed to add events.
        =====
      
      This failure was caused by a versioned suffix symbol.
      
      With this fix, perf probe automatically cuts the suffix after @ as
      below.
      
        =====
        # ./perf probe -x /lib64/libc-2.25.so malloc*
        Added new events:
          probe_libc:malloc_printerr (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_consolidate (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_check (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_hook_ini (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc    (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_trim (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_usable_size (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_stats (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_info (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:mallochook (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_get_state (on malloc* in /usr/lib64/libc-2.25.so)
          probe_libc:malloc_set_state (on malloc* in /usr/lib64/libc-2.25.so)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe_libc:malloc_set_state -aR sleep 1
      
        =====
      Reported-by: NArnaldo Carvalho de Melo <acme@kernel.org>
      Reported-by: Nbhargavb <bhargavaramudu@gmail.com>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Acked-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Reviewed-by: NThomas Richter <tmricht@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: linux-rt-users@vger.kernel.org
      Link: http://lkml.kernel.org/r/NoneSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a3110cd9
    • M
      perf probe: Add warning message if there is unexpected event name · 9f5c6d87
      Masami Hiramatsu 提交于
      This improve the error message so that user can know event-name error
      before writing new events to kprobe-events interface.
      
      E.g.
         ======
         #./perf probe -x /lib64/libc-2.25.so malloc_get_state*
         Internal error: "malloc_get_state@GLIBC_2" is an invalid event name.
           Error: Failed to add events.
         ======
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Acked-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Reviewed-by: NThomas Richter <tmricht@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: bhargavb <bhargavaramudu@gmail.com>
      Cc: linux-rt-users@vger.kernel.org
      Link: http://lkml.kernel.org/r/151275040665.24652.5188568529237584489.stgit@devboxSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9f5c6d87
    • A
      perf env: Adopt perf_env__arch() from the annotate code · 4e8fbc1c
      Arnaldo Carvalho de Melo 提交于
      And use it in the libunwind case, with both passing a valid perf_env to
      extract the arch to be normalized from and passing NULL with the same
      semantic as in the annotate code: to get it from uname() uts.machine.
      
      Now the code to generate per arch errno translation tables (int/string)
      can use it to decode perf.data files recorded in a different arch than
      that where 'perf trace' (or any other analysis tool) runs.
      
      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: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-p2epffgash69w38kvj3ntpc9@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4e8fbc1c
    • A
      perf annotate: Use perf_env when obtaining the arch name · 3285deba
      Arnaldo Carvalho de Melo 提交于
      Paving the way to reuse these routines in other areas, like when
      generating errno tables.
      
      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: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-rh1qv051vb8gfdcswskrn53h@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3285deba
    • A
      perf annotate: Get the cpuid from evsel->evlist->env in symbol__annotate() · 5449f13c
      Arnaldo Carvalho de Melo 提交于
      To reduce its function signature, since we get this from 'evsel' which
      is already one of its arguments.
      
      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: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-070eap7t6uicg9c3w086xy2z@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5449f13c