1. 16 5月, 2019 1 次提交
    • A
      perf record: Implement -z,--compression_level[=<n>] option · 504c1ad1
      Alexey Budankov 提交于
      Implemented -z,--compression_level[=<n>] option that enables compression
      of mmaped kernel data buffers content in runtime during perf record mode
      collection. Default option value is 1 (fastest compression).
      
      Compression overhead has been measured for serial and AIO streaming when
      profiling matrix multiplication workload:
      
            -------------------------------------------------------------
            | SERIAL			  | AIO-1                       |
        ----------------------------------------------------------------|
        |-z | OVH(x) | ratio(x) size(MiB) | OVH(x) | ratio(x) size(MiB) |
        |---------------------------------------------------------------|
        | 0 | 1,00   | 1,000    179,424   | 1,00   | 1,000    187,527   |
        | 1 | 1,04   | 8,427    181,148   | 1,01   | 8,474    188,562   |
        | 2 | 1,07   | 8,055    186,953   | 1,03   | 7,912    191,773   |
        | 3 | 1,04   | 8,283    181,908   | 1,03   | 8,220    191,078   |
        | 5 | 1,09   | 8,101    187,705   | 1,05   | 7,780    190,065   |
        | 8 | 1,05   | 9,217    179,191   | 1,12   | 6,111    193,024   |
        -----------------------------------------------------------------
      
      OVH = (Execution time with -z N) / (Execution time with -z 0)
      
      ratio - compression ratio
      size  - number of bytes that was compressed
      
      	size ~= trace size x ratio
      
      Committer notes:
      
      Testing it I noticed that it failed to disable build id processing when
      compression is enabled, and as we'd have to uncompress everything to
      look for the PERF_RECORD_{MMAP,SAMPLE,etc} to figure out which build ids
      to read from DSOs, we better disable build id processing when
      compression is enabled, logging with pr_debug() when doing so:
      
      Original patch:
      
        # perf record -z2
        ^C[ perf record: Woken up 1 times to write data ]
        0x1746e0 [0x76]: failed to process type: 81 [Invalid argument]
        [ perf record: Captured and wrote 1.568 MB perf.data, compressed (original 0.452 MB, ratio is 3.995) ]
        #
      
      After auto-disabling build id processing when compression is enabled:
      
        $ perf record -z2 sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.001 MB perf.data, compressed (original 0.001 MB, ratio is 2.292) ]
        $ perf record -v -z2 sleep 1
        Compression enabled, disabling build id collection at the end of the session.
        <SNIP extra -v pr_debug() messages>
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.001 MB perf.data, compressed (original 0.001 MB, ratio is 2.305) ]
        $
      
      Also, with parts of the patch originally after this one moved to just
      before this one we get:
      
        $ perf record -z2 sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.001 MB perf.data, compressed (original 0.001 MB, ratio is 2.371) ]
        $ perf report -D | grep COMPRESS
        0 0x1b8 [0x155]: PERF_RECORD_COMPRESSED: unhandled!
        0 0x30d [0x80]: PERF_RECORD_COMPRESSED: unhandled!
              COMPRESSED events:          2
              COMPRESSED events:          0
        $
      
      I.e. when faced with PERF_RECORD_COMPRESSED that we still have no code
      to process, we just show it as not being handled, skip them and
      continue, while before we had:
      
        $ perf report -D | grep COMPRESS
        0x1b8 [0x169]: failed to process type: 81 [Invalid argument]
        Error:
        failed to process sample
        0 0x1b8 [0x169]: PERF_RECORD_COMPRESSED
        $
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Reviewed-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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/9ff06518-ae63-a908-e44d-5d9e56dd66d9@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      504c1ad1
  2. 02 4月, 2019 1 次提交
    • A
      perf record: Implement --mmap-flush=<number> option · 470530bb
      Alexey Budankov 提交于
      Implement a --mmap-flush option that specifies minimal number of bytes
      that is extracted from mmaped kernel buffer to store into a trace. The
      default option value is 1 byte what means every time trace writing
      thread finds some new data in the mmaped buffer the data is extracted,
      possibly compressed and written to a trace.
      
        $ tools/perf/perf record --mmap-flush 1024 -e cycles -- matrix.gcc
        $ tools/perf/perf record --aio --mmap-flush 1K -e cycles -- matrix.gcc
      
      The option is independent from -z setting, doesn't vary with compression
      level and can serve two purposes.
      
      The first purpose is to increase the compression ratio of a trace data.
      Larger data chunks are compressed more effectively so the implemented
      option allows specifying data chunk size to compress. Also at some cases
      executing more write syscalls with smaller data size can take longer
      than executing less write syscalls with bigger data size due to syscall
      overhead so extracting bigger data chunks specified by the option value
      could additionally decrease runtime overhead.
      
      The second purpose is to avoid self monitoring live-lock issue in system
      wide (-a) profiling mode. Profiling in system wide mode with compression
      (-a -z) can additionally induce data into the kernel buffers along with
      the data from monitored processes. If performance data rate and volume
      from the monitored processes is high then trace streaming and
      compression activity in the tool is also high. High tool process
      activity can lead to subtle live-lock effect when compression of single
      new byte from some of mmaped kernel buffer leads to generation of the
      next single byte at some mmaped buffer. So perf tool process ends up in
      endless self monitoring.
      
      Implemented synch parameter is the mean to force data move independently
      from the specified flush threshold value. Despite the provided flush
      value the tool needs capability to unconditionally drain memory buffers,
      at least in the end of the collection.
      
      Committer testing:
      
      Running with the default value, i.e. as soon as there is something to
      read go on consuming, we first write the synthesized events, small
      chunks of about 128 bytes:
      
        # perf trace -m 2048 --call-graph dwarf -e write -- perf record
        <SNIP>
           101.142 ( 0.004 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x210db60, count: 120) = 120
                                               __libc_write (/usr/lib64/libpthread-2.28.so)
                                               ion (/home/acme/bin/perf)
                                               record__write (inlined)
                                               process_synthesized_event (/home/acme/bin/perf)
                                               perf_tool__process_synth_event (inlined)
                                               perf_event__synthesize_mmap_events (/home/acme/bin/perf)
      
      Then we move to reading the mmap buffers consuming the events put there
      by the kernel perf infrastructure:
      
           107.561 ( 0.005 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x7f1befc02000, count: 336) = 336
                                               __libc_write (/usr/lib64/libpthread-2.28.so)
                                               ion (/home/acme/bin/perf)
                                               record__write (inlined)
                                               record__pushfn (/home/acme/bin/perf)
                                               perf_mmap__push (/home/acme/bin/perf)
                                               record__mmap_read_evlist (inlined)
                                               record__mmap_read_all (inlined)
                                               __cmd_record (inlined)
                                               cmd_record (/home/acme/bin/perf)
           12919.953 ( 0.136 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x7f1befc83150, count: 184984) = 184984
        <SNIP same backtrace as in the 107.561 timestamp>
           12920.094 ( 0.155 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x7f1befc02150, count: 261816) = 261816
        <SNIP same backtrace as in the 107.561 timestamp>
           12920.253 ( 0.093 ms): perf/25821 write(fd: 3</root/perf.data>, buf: 0x7f1befb81120, count: 170832) = 170832
        <SNIP same backtrace as in the 107.561 timestamp>
      
      If we limit it to write only when more than 16MB are available for
      reading, it throttles that to a quarter of the --mmap-pages set for
      'perf record', which by default get to 528384 bytes, found out using
      'record -v':
      
        mmap flush: 132096
        mmap size 528384B
      
      With that in place all the writes coming from
      record__mmap_read_evlist(), i.e. from the mmap buffers setup by the
      kernel perf infrastructure were at least 132096 bytes long.
      
      Trying with a bigger mmap size:
      
         perf trace -e write perf record -v -m 2048 --mmap-flush 16M
         74982.928 ( 2.471 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff94a6cc000, count: 3580888) = 3580888
         74985.406 ( 2.353 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff949ecb000, count: 3453256) = 3453256
         74987.764 ( 2.629 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff9496ca000, count: 3859232) = 3859232
         74990.399 ( 2.341 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff948ec9000, count: 3769032) = 3769032
         74992.744 ( 2.064 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff9486c8000, count: 3310520) = 3310520
         74994.814 ( 2.619 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff947ec7000, count: 4194688) = 4194688
         74997.439 ( 2.787 ms): perf/26500 write(fd: 3</root/perf.data>, buf: 0x7ff9476c6000, count: 4029760) = 4029760
      
      Was again limited to a quarter of the mmap size:
      
        mmap flush: 2098176
        mmap size 8392704B
      
      A warning about that would be good to have but can be added later,
      something like:
      
        "max flush is a quarter of the mmap size, if wanting to bump the mmap
         flush further, bump the mmap size as well using -m/--mmap-pages"
      
      Also rename the 'sync' parameters to 'synch' to keep tools/perf building
      with older glibcs:
      
        cc1: warnings being treated as errors
        builtin-record.c: In function 'record__mmap_read_evlist':
        builtin-record.c:775: warning: declaration of 'sync' shadows a global declaration
        /usr/include/unistd.h:933: warning: shadowed declaration is here
        builtin-record.c: In function 'record__mmap_read_all':
        builtin-record.c:856: warning: declaration of 'sync' shadows a global declaration
        /usr/include/unistd.h:933: warning: shadowed declaration is here
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Reviewed-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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/f6600d72-ecfa-2eb7-7e51-f6954547d500@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      470530bb
  3. 19 3月, 2019 1 次提交
  4. 11 2月, 2019 1 次提交
  5. 06 2月, 2019 1 次提交
  6. 18 12月, 2018 2 次提交
  7. 16 7月, 2018 1 次提交
  8. 06 6月, 2018 1 次提交
    • A
      perf record: Enable arbitrary event names thru name= modifier · f92da712
      Alexey Budankov 提交于
      Enable complex event names containing [.:=,] symbols to be encoded into Perf
      trace using name= modifier e.g. like this:
      
        perf record -e cpu/name=\'OFFCORE_RESPONSE:request=DEMAND_RFO:response=L3_HIT.SNOOP_HITM\',\
      		  period=0x3567e0,event=0x3c,cmask=0x1/Duk ./futex
      
      Below is how it looks like in the report output. Please note explicit escaped
      quoting at cmdline string in the header so that thestring can be directly reused
      for another collection in shell:
      
      perf report --header
      
        # ========
        ...
        # cmdline : /root/abudanko/kernel/tip/tools/perf/perf record -v -e cpu/name=\'OFFCORE_RESPONSE:request=DEMAND_RFO:response=L3_HIT.SNOOP_HITM\',period=0x3567e0,event=0x3c,cmask=0x1/Duk ./futex
        # event : name = OFFCORE_RESPONSE:request=DEMAND_RFO:response=L3_HIT.SNOOP_HITM, , type = 4, size = 112, config = 0x100003c, { sample_period, sample_freq } = 3500000, sample_type = IP|TID|TIME, disabled = 1, inh
        ...
        # ========
        #
        #
        # Total Lost Samples: 0
        #
        # Samples: 24K of event 'OFFCORE_RESPONSE:request=DEMAND_RFO:response=L3_HIT.SNOOP_HITM'
        # Event count (approx.): 86492000000
        #
        # Overhead  Command  Shared Object     Symbol
        # ........  .......  ................  ..............................................
        #
            14.75%  futex    [kernel.vmlinux]  [k] __entry_trampoline_start
      ...
      
        perf stat -e cpu/name=\'CPU_CLK_UNHALTED.THREAD:cmask=0x1\',period=0x3567e0,event=0x3c,cmask=0x1/Duk ./futex
      
        10000000 process context switches in 16678890291ns (1667.9ns/ctxsw)
      
         Performance counter stats for './futex':
      
            88,095,770,571      CPU_CLK_UNHALTED.THREAD:cmask=0x1
      
              16.679542407 seconds time elapsed
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/c194b060-761d-0d50-3b21-bb4ed680002d@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f92da712
  9. 05 3月, 2018 2 次提交
    • A
      perf record: Throttle user defined frequencies to the maximum allowed · b09c2364
      Arnaldo Carvalho de Melo 提交于
        # perf record -F 200000 sleep 1
        warning: Maximum frequency rate (15,000 Hz) exceeded, throttling from 200,000 Hz to 15,000 Hz.
                 The limit can be raised via /proc/sys/kernel/perf_event_max_sample_rate.
                 The kernel will lower it when perf's interrupts take too long.
      	   Use --strict-freq to disable this throttling, refusing to record.
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.019 MB perf.data (15 samples) ]
        # perf evlist -v
        cycles:ppp: size: 112, { sample_period, sample_freq }: 15000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
      
      For those wanting that it fails if the desired frequency can't be used:
      
        # perf record --strict-freq -F 200000 sleep 1
        error: Maximum frequency rate (15,000 Hz) exceeded.
               Please use -F freq option with a lower value or consider
               tweaking /proc/sys/kernel/perf_event_max_sample_rate.
        #
      Suggested-by: NIngo Molnar <mingo@kernel.org>
      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-oyebruc44nlja499nqkr1nzn@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b09c2364
    • A
      perf record: Allow asking for the maximum allowed sample rate · 67230479
      Arnaldo Carvalho de Melo 提交于
      Add the handy '-F max' shortcut to reading and using the
      kernel.perf_event_max_sample_rate value as the user supplied
      sampling frequency:
      
        # perf record -F max sleep 1
        info: Using a maximum frequency rate of 15,000 Hz
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.019 MB perf.data (14 samples) ]
        # sysctl kernel.perf_event_max_sample_rate
        kernel.perf_event_max_sample_rate = 15000
        # perf evlist -v
        cycles:ppp: size: 112, { sample_period, sample_freq }: 15000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
      
        # perf record -F 10 sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.019 MB perf.data (4 samples) ]
        # perf evlist -v
        cycles:ppp: size: 112, { sample_period, sample_freq }: 10, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
        #
      Suggested-by: NIngo Molnar <mingo@kernel.org>
      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-4y0tiuws62c64gp4cf0hme0m@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      67230479
  10. 22 2月, 2018 1 次提交
  11. 08 1月, 2018 1 次提交
    • 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
  12. 17 10月, 2017 1 次提交
  13. 13 9月, 2017 1 次提交
  14. 02 9月, 2017 1 次提交
  15. 19 7月, 2017 1 次提交
  16. 04 5月, 2017 1 次提交
  17. 14 3月, 2017 1 次提交
    • H
      perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info · f3b3614a
      Hari Bathini 提交于
      Introduce a new option to record PERF_RECORD_NAMESPACES events emitted
      by the kernel when fork, clone, setns or unshare are invoked. And update
      perf-record documentation with the new option to record namespace
      events.
      
      Committer notes:
      
      Combined it with a later patch to allow printing it via 'perf report -D'
      and be able to test the feature introduced in this patch. Had to move
      here also perf_ns__name(), that was introduced in another later patch.
      
      Also used PRIu64 and PRIx64 to fix the build in some enfironments wrt:
      
        util/event.c:1129:39: error: format '%lx' expects argument of type 'long unsigned int', but argument 6 has type 'long long unsigned int' [-Werror=format=]
           ret  += fprintf(fp, "%u/%s: %lu/0x%lx%s", idx
                                               ^
      Testing it:
      
        # perf record --namespaces -a
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.083 MB perf.data (423 samples) ]
        #
        # perf report -D
        <SNIP>
        3 2028902078892 0x115140 [0xa0]: PERF_RECORD_NAMESPACES 14783/14783 - nr_namespaces: 7
                      [0/net: 3/0xf0000081, 1/uts: 3/0xeffffffe, 2/ipc: 3/0xefffffff, 3/pid: 3/0xeffffffc,
                       4/user: 3/0xeffffffd, 5/mnt: 3/0xf0000000, 6/cgroup: 3/0xeffffffb]
      
        0x1151e0 [0x30]: event: 9
        .
        . ... raw event: size 48 bytes
        .  0000:  09 00 00 00 02 00 30 00 c4 71 82 68 0c 7f 00 00  ......0..q.h....
        .  0010:  a9 39 00 00 a9 39 00 00 94 28 fe 63 d8 01 00 00  .9...9...(.c....
        .  0020:  03 00 00 00 00 00 00 00 ce c4 02 00 00 00 00 00  ................
        <SNIP>
              NAMESPACES events:          1
        <SNIP>
        #
      Signed-off-by: NHari Bathini <hbathini@linux.vnet.ibm.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: Alexei Starovoitov <ast@fb.com>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sargun Dhillon <sargun@sargun.me>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/148891930386.25309.18412039920746995488.stgit@hbathini.in.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f3b3614a
  18. 18 2月, 2017 1 次提交
  19. 12 1月, 2017 2 次提交
  20. 03 1月, 2017 1 次提交
  21. 24 10月, 2016 1 次提交
  22. 29 9月, 2016 1 次提交
  23. 28 9月, 2016 1 次提交
  24. 14 9月, 2016 1 次提交
  25. 03 8月, 2016 1 次提交
  26. 16 7月, 2016 2 次提交
    • W
      perf record: Add --tail-synthesize option · 4ea648ae
      Wang Nan 提交于
      When working with overwritable ring buffer there's a inconvenience
      problem: if perf dumps data after a long period after it starts,
      non-sample events may lost, which makes following 'perf report' unable
      to identify proc name and mmap layout. For example:
      
       # perf record -m 4 -e raw_syscalls:* -g --overwrite --switch-output \
              dd if=/dev/zero of=/dev/null
      
      send SIGUSR2 after dd runs long enough. The resuling perf.data lost
      correct comm and mmap events:
      
       # perf script -i perf.data.2016061522374354
       perf 24478 [004] 2581325.601789:  raw_syscalls:sys_exit: NR 0 = 512
       ^^^^
       Should be 'dd'
                         27b2e8 syscall_slow_exit_work+0xfe2000e3 (/lib/modules/4.6.0-rc3+/build/vmlinux)
                         203cc7 do_syscall_64+0xfe200117 (/lib/modules/4.6.0-rc3+/build/vmlinux)
                         b18d83 return_from_SYSCALL_64+0xfe200000 (/lib/modules/4.6.0-rc3+/build/vmlinux)
                   7f47c417edf0 [unknown] ([unknown])
                   ^^^^^^^^^^^^
                   Fail to unwind
      
      This patch provides a '--tail-synthesize' option, allows perf to collect
      system status when finalizing output file. In resuling output file, the
      non-sample events reflect system status when dumping data.
      
      After this patch:
       # perf record -m 4 -e raw_syscalls:* -g --overwrite --switch-output --tail-synthesize \
              dd if=/dev/zero of=/dev/null
      
       # perf script -i perf.data.2016061600544998
       dd 27364 [004] 2583244.994464: raw_syscalls:sys_enter: NR 1 (1, ...
       ^^
       Correct comm
                         203a18 syscall_trace_enter_phase2+0xfe2001a8 ([kernel.kallsyms])
                         203aa5 syscall_trace_enter+0xfe200055 ([kernel.kallsyms])
                         203caa do_syscall_64+0xfe2000fa ([kernel.kallsyms])
                         b18d83 return_from_SYSCALL_64+0xfe200000 ([kernel.kallsyms])
                          d8e50 __GI___libc_write+0xffff01d9639f4010 (/tmp/oxygen_root-w00229757/lib64/libc-2.18.so)
                          ^^^^^
                          Correct unwind
      
      This option doesn't aim to solve this problem completely. If a process
      terminates before SIGUSR2, we still lost its COMM and MMAP events. For
      example, we can't unwind correctly from the final perf.data we get from
      the previous example, because when perf collects the final output file
      (when we press C-c), 'dd' has been terminated so its '/proc/<pid>/mmap'
      becomes empty.
      
      However, this is a cheaper choice. To completely solve this problem we
      need to continously output non-sample events. To satisify the
      requirement of daemonization, we need to merge them periodically. It is
      possible but requires much more code and cycles.
      
      Automatically select --tail-synthesize when --overwrite is provided.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-16-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4ea648ae
    • W
      perf tools: Enable overwrite settings · 626a6b78
      Wang Nan 提交于
      This patch allows following config terms and option:
      
      Globally setting events to overwrite;
      
        # perf record --overwrite ...
      
      Set specific events to be overwrite or no-overwrite.
      
        # perf record --event cycles/overwrite/ ...
        # perf record --event cycles/no-overwrite/ ...
      
      Add missing config terms and update the config term array size because
      the longest string length has changed.
      
      For overwritable events, it automatically selects attr.write_backward
      since perf requires it to be backward for reading.
      
      Test result:
      
        # perf record --overwrite -e syscalls:*enter_nanosleep* usleep 1
        [ perf record: Woken up 2 times to write data ]
        [ perf record: Captured and wrote 0.011 MB perf.data (1 samples) ]
        # perf evlist -v
        syscalls:sys_enter_nanosleep: type: 2, size: 112, config: 0x134, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, write_backward: 1
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1468485287-33422-14-git-send-email-wangnan0@huawei.comSigned-off-by: NHe Kuang <hekuang@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      626a6b78
  27. 22 6月, 2016 1 次提交
  28. 28 4月, 2016 3 次提交
  29. 18 2月, 2016 1 次提交
    • J
      perf record: Add --all-user/--all-kernel options · 85723885
      Jiri Olsa 提交于
      Allow user to easily switch all events to user or kernel space with simple
      --all-user or --all-kernel options.
      
      This will be handy within perf mem/c2c wrappers to switch easily monitoring
      modes.
      
      Committer note:
      
      Testing it:
      
        # perf record --all-kernel --all-user -a sleep 2
         Error: option `all-user' cannot be used with all-kernel
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
              --all-user        Configure all used events to run in user space.
              --all-kernel      Configure all used events to run in kernel space.
        # perf record --all-user --all-kernel -a sleep 2
         Error: option `all-kernel' cannot be used with all-user
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
              --all-kernel      Configure all used events to run in kernel space.
              --all-user        Configure all used events to run in user space.
        # perf record --all-user -a sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.416 MB perf.data (162 samples) ]
        # perf report | grep '\[k\]'
        # perf record --all-kernel -a sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.423 MB perf.data (296 samples) ]
        # perf report | grep '\[\.\]'
        #
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1455525293-8671-2-git-send-email-jolsa@kernel.org
      [ Made those options to be mutually exclusive ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      85723885
  30. 12 1月, 2016 1 次提交
  31. 15 12月, 2015 2 次提交
    • N
      perf record: Add record.build-id config option · 7a29c087
      Namhyung Kim 提交于
      Post processing at 'perf record' takes a long time on big machines.
      
      What it does is to find the build-id of binaries found in the event
      stream, so that it can make sure, at 'report' time, that the symtabs (be
      it ELF, kallsyms, etc) being used to resolve symbols are the ones
      matching the binaries found at 'record' time.
      
      Sometimes we just want to skip this processing of events at the end of
      the session to get quicker results, making sure the binaries haven't
      changed from 'record' to 'report' time.
      
      Add a new config option to control this behavior.
      
      The record.build-id config variable can have one of the following
      values:
      
       - cache: post-process data and save/update the binaries into the
                build-id cache (in ~/.debug).  This is the default.
       - no-cache: post-process the data but not update the build-id cache.
                   Same effect as using the -N option.
       - skip: skip post-processing and do not update the cache.
               Same effect as using the -B option.
      Reported-and-Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Link: http://lkml.kernel.org/r/1450144196-22957-1-git-send-email-namhyung@kernel.org
      [ Added some more text to the documentation ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7a29c087
    • H
      perf record: Support custom vmlinux path · 7efe0e03
      He Kuang 提交于
      Make perf-record command support --vmlinux option if BPF_PROLOGUE is on.
      
      'perf record' needs vmlinux as the source of DWARF info to generate
      prologue for BPF programs, so path of vmlinux should be specified.
      
      Short name 'k' has been taken by 'clockid'. This patch skips the short
      option name and uses '--vmlinux' for vmlinux path.
      
      Documentation is also updated.
      
      Test result:
      
      In a production (or broken) environment:
       (by:
        # rm -rf ~/.debug/
        # mv /lib/modules/`uname -r`/build/vmlinux /tmp/
       )
      
       # ./perf record -e ./test_bpf_base.c ls
       Failed to find the path for kernel: No such file or directory
       event syntax error: './test_bpf_base.c'
                            \___ You need to check probing points in BPF file
       ...
      
       # ./perf record --vmlinux /tmp/vmlinux -e ./test_bpf_base.c ls
       ...
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.011 MB perf.data ]
      
      Help messages when build with NO_LIBBPF:
      
       # ./perf record -h
              --transaction     sample transaction flags (special events only)
              --vmlinux <file>  vmlinux pathname
                                (not built-in because NO_LIBBPF=1)
       # ./perf record --vmlinux /tmp/vmlinux ls /
        Warning: option `vmlinux' is being ignored because NO_LIBBPF=1
       ...
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.011 MB perf.data (11 samples) ]
      
      Help messages when build with NO_DWARF:
      
       # ./perf record -h
              --transaction     sample transaction flags (special events only)
              --vmlinux <file>  vmlinux pathname
                                (not built-in because NO_DWARF=1)
      Signed-off-by: NHe Kuang <hekuang@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1450089563-122430-15-git-send-email-wangnan0@huawei.comSigned-off-by: NWang Nan <wangnan0@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7efe0e03
  32. 30 10月, 2015 1 次提交
    • W
      perf record: Add clang options for compiling BPF scripts · 71dc2326
      Wang Nan 提交于
      Although previous patch allows setting BPF compiler related options in
      perfconfig, on some ad-hoc situation it still requires passing options
      through cmdline. This patch introduces 2 options to 'perf record' for
      this propose: --clang-path and --clang-opt.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1444826502-49291-9-git-send-email-wangnan0@huawei.com
      [ Add the new options to the 'record' man page ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      71dc2326
  33. 23 10月, 2015 1 次提交
    • N
      perf tools: Improve call graph documents and help messages · 76a26549
      Namhyung Kim 提交于
      The --call-graph option is complex so we should provide better guide for
      users.  Also change help message to be consistent with config option
      names.  Now perf top will show help like below:
      
        $ perf top --call-graph
          Error: option `call-graph' requires a value
      
         Usage: perf top [<options>]
      
            --call-graph <record_mode[,record_size],print_type,threshold[,print_limit],order,sort_key[,branch]>
                 setup and enables call-graph (stack chain/backtrace):
      
      		record_mode:	call graph recording mode (fp|dwarf|lbr)
      		record_size:	if record_mode is 'dwarf', max size of stack recording (<bytes>)
      				default: 8192 (bytes)
      		print_type:	call graph printing style (graph|flat|fractal|none)
      		threshold:	minimum call graph inclusion threshold (<percent>)
      		print_limit:	maximum number of call graph entry (<number>)
      		order:		call graph order (caller|callee)
      		sort_key:	call graph sort key (function|address)
      		branch:		include last branch info to call graph (branch)
      
      		Default: fp,graph,0.5,caller,function
      Requested-by: NIngo Molnar <mingo@kernel.org>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Chandler Carruth <chandlerc@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1445524112-5201-2-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      76a26549