1. 02 8月, 2021 1 次提交
  2. 10 7月, 2021 3 次提交
  3. 01 6月, 2021 1 次提交
    • N
      perf record: Move probing cgroup sampling support · 4f2abe91
      Namhyung Kim 提交于
      I found that checking cgroup sampling support using the missing features
      doesn't work on old kernels.  Because it added both attr.cgroup bit and
      PERF_SAMPLE_CGROUP bit, it needs to check whichever comes first (usually
      the actual event, not dummy).
      
      But it only checks the attr.cgroup bit which is set only in the dummy
      event so cannot detect failtures due the sample bits.  Also we don't
      ignore the missing feature and retry, it'd be better checking it with
      the API probing logic.
      
      Committer notes:
      
      Extracted the minimal part to check using the new cgroup API probe
      routine, the part that removes the cgroup member can be left for further
      discussion.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210527182835.1634339-1-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4f2abe91
  4. 12 5月, 2021 1 次提交
    • A
      perf record: Set timestamp boundary for AUX area events · 66286ed3
      Adrian Hunter 提交于
      AUX area data is not processed by 'perf record' and consequently the
       --timestamp-boundary option may result in no values for "time of first
      sample" and "time of last sample". However there are non-sample events
      that can be used instead, namely 'itrace_start' and 'aux'.
      'itrace_start' is issued before tracing starts, and 'aux' is issued
      every time data is ready.
      
      Implement tool callbacks for those two for 'perf record', to update the
      timestamp boundary.
      
      Example:
      
       $ perf record -e intel_pt//u --timestamp-boundary uname
       Linux
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.022 MB perf.data ]
       $ perf script --header-only | grep "time of"
       # time of first sample : 4574.835541
       # time of last sample : 4574.835907
       $ perf script --itrace=be -F-ip | head -1
                 uname 13752 [001]  4574.835589:          1 branches:uH:
       $ perf script --itrace=be -F-ip | tail -1
                 uname 13752 [001]  4574.835867:          1 branches:uH:
       $
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20210503064222.5319-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      66286ed3
  5. 29 4月, 2021 2 次提交
    • J
      perf record: Uniquify hybrid event name · 91c0f5ec
      Jin Yao 提交于
      For perf-record, it would be useful to tell user the pmu which the
      event belongs to.
      
      For example,
      
        # perf record -a -- sleep 1
        # perf report
      
        # To display the perf.data header info, please use --header/--header-only options.
        #
        #
        # Total Lost Samples: 0
        #
        # Samples: 106  of event 'cpu_core/cycles/'
        # Event count (approx.): 22043448
        #
        # Overhead  Command       Shared Object            Symbol
        # ........  ............  .......................  ............................
        #
        ...
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20210427070139.25256-18-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      91c0f5ec
    • J
      perf record: Create two hybrid 'cycles' events by default · b53a0755
      Jin Yao 提交于
      When evlist is empty, for example no '-e' specified in perf record,
      one default 'cycles' event is added to evlist.
      
      While on hybrid platform, it needs to create two default 'cycles'
      events. One is for cpu_core, the other is for cpu_atom.
      
      This patch actually calls evsel__new_cycles() two times to create
      two 'cycles' events.
      
        # ./perf record -vv -a -- sleep 1
        ...
        ------------------------------------------------------------
        perf_event_attr:
          size                             120
          config                           0x400000000
          { sample_period, sample_freq }   4000
          sample_type                      IP|TID|TIME|ID|CPU|PERIOD
          read_format                      ID
          disabled                         1
          inherit                          1
          freq                             1
          precise_ip                       3
          sample_id_all                    1
          exclude_guest                    1
        ------------------------------------------------------------
        sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 5
        sys_perf_event_open: pid -1  cpu 1  group_fd -1  flags 0x8 = 6
        sys_perf_event_open: pid -1  cpu 2  group_fd -1  flags 0x8 = 7
        sys_perf_event_open: pid -1  cpu 3  group_fd -1  flags 0x8 = 9
        sys_perf_event_open: pid -1  cpu 4  group_fd -1  flags 0x8 = 10
        sys_perf_event_open: pid -1  cpu 5  group_fd -1  flags 0x8 = 11
        sys_perf_event_open: pid -1  cpu 6  group_fd -1  flags 0x8 = 12
        sys_perf_event_open: pid -1  cpu 7  group_fd -1  flags 0x8 = 13
        sys_perf_event_open: pid -1  cpu 8  group_fd -1  flags 0x8 = 14
        sys_perf_event_open: pid -1  cpu 9  group_fd -1  flags 0x8 = 15
        sys_perf_event_open: pid -1  cpu 10  group_fd -1  flags 0x8 = 16
        sys_perf_event_open: pid -1  cpu 11  group_fd -1  flags 0x8 = 17
        sys_perf_event_open: pid -1  cpu 12  group_fd -1  flags 0x8 = 18
        sys_perf_event_open: pid -1  cpu 13  group_fd -1  flags 0x8 = 19
        sys_perf_event_open: pid -1  cpu 14  group_fd -1  flags 0x8 = 20
        sys_perf_event_open: pid -1  cpu 15  group_fd -1  flags 0x8 = 21
        ------------------------------------------------------------
        perf_event_attr:
          size                             120
          config                           0x800000000
          { sample_period, sample_freq }   4000
          sample_type                      IP|TID|TIME|ID|CPU|PERIOD
          read_format                      ID
          disabled                         1
          inherit                          1
          freq                             1
          precise_ip                       3
          sample_id_all                    1
          exclude_guest                    1
        ------------------------------------------------------------
        sys_perf_event_open: pid -1  cpu 16  group_fd -1  flags 0x8 = 22
        sys_perf_event_open: pid -1  cpu 17  group_fd -1  flags 0x8 = 23
        sys_perf_event_open: pid -1  cpu 18  group_fd -1  flags 0x8 = 24
        sys_perf_event_open: pid -1  cpu 19  group_fd -1  flags 0x8 = 25
        sys_perf_event_open: pid -1  cpu 20  group_fd -1  flags 0x8 = 26
        sys_perf_event_open: pid -1  cpu 21  group_fd -1  flags 0x8 = 27
        sys_perf_event_open: pid -1  cpu 22  group_fd -1  flags 0x8 = 28
        sys_perf_event_open: pid -1  cpu 23  group_fd -1  flags 0x8 = 29
        ------------------------------------------------------------
      
      We have to create evlist-hybrid.c otherwise due to the symbol
      dependency the perf test python would be failed.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20210427070139.25256-14-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b53a0755
  6. 16 4月, 2021 1 次提交
    • A
      perf record: Improve 'Workload failed' message printing events + what was exec'ed · 3535a696
      Arnaldo Carvalho de Melo 提交于
      Before:
      
        # perf record -a cycles,instructions,cache-misses
        Workload failed: No such file or directory
        #
      
      After:
      
        # perf record -a cycles,instructions,cache-misses
        Failed to collect 'cycles' for the 'cycles,instructions,cache-misses' workload: No such file or directory
        #
      
      Helps disambiguating other error scenarios:
      
        # perf record -a -e cycles,instructions,cache-misses bla
        Failed to collect 'cycles,instructions,cache-misses' for the 'bla' workload: No such file or directory
        # perf record -a cycles,instructions,cache-misses sleep 1
        Failed to collect 'cycles' for the 'cycles,instructions,cache-misses' workload: No such file or directory
        #
      
      When all goes well we're back to the usual:
      
        # perf record -a -e cycles,instructions,cache-misses sleep 1
        [ perf record: Woken up 3 times to write data ]
        [ perf record: Captured and wrote 3.151 MB perf.data (21242 samples) ]
        #
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20210414131628.2064862-3-acme@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3535a696
  7. 19 2月, 2021 2 次提交
  8. 21 1月, 2021 5 次提交
    • J
      perf tools: Add 'ping' control command · 47fddcb4
      Jiri Olsa 提交于
      Add a control 'ping' command to detect if perf is up and its control
      interface is operational.
      
      It will be used in following daemon patches to synchronize with record
      session - when control interface is up and running, we know that perf
      record is monitoring and ready to receive signals.
      
      Example session:
      
        terminal 1:
      
          # mkfifo control ack
          # perf record --control=fifo:control,ack
      
        terminal 2:
      
          # echo ping > control
          # cat ack
          ack
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201226232038.390883-5-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      47fddcb4
    • J
      perf tools: Add 'stop' control command · f186cd61
      Jiri Olsa 提交于
      Adding control 'stop' command to stop perf record.
      
      When it is received, perf will set the 'done' variable to 1 to stop its
      mmap ring buffer reading loop.
      
      Example session:
      
        terminal 1:
          # mkfifo control ack
          # perf record --control=fifo:control,ack
      
        terminal 2:
          # echo stop > control
      
        terminal 1:
          [ perf record: Woken up 7 times to write data ]
          [ perf record: Captured and wrote 3.214 MB perf.data (38280 samples) ]
          #
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201226232038.390883-4-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f186cd61
    • J
      perf tools: Add 'evlist' control command · 142544a9
      Jiri Olsa 提交于
      Add a new 'evlist' control command to display all the evlist events.
      When it is received, perf will scan and print current evlist into perf
      record terminal.
      
      The interface string for control file is:
      
        evlist [-v|-g|-F]
      
      The syntax follows perf evlist command:
        -F  Show just the sample frequency used for each event.
        -v  Show all fields.
        -g  Show event group information.
      
      Example session:
      
        terminal 1:
          # mkfifo control ack
          # perf record --control=fifo:control,ack -e '{cycles,instructions}'
      
        terminal 2:
          # echo evlist > control
      
        terminal 1:
          cycles
          instructions
          dummy:HG
      
        terminal 2:
          # echo 'evlist -v' > control
      
        terminal 1:
          cycles: size: 120, { sample_period, sample_freq }: 4000, sample_type:            \
          IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, disabled: 1, inherit: 1, freq: 1,    \
          sample_id_all: 1, exclude_guest: 1
          instructions: size: 120, config: 0x1, { sample_period, sample_freq }: 4000,      \
          sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, inherit: 1, freq: 1,    \
          sample_id_all: 1, exclude_guest: 1
          dummy:HG: type: 1, size: 120, config: 0x9, { sample_period, sample_freq }: 4000, \
          sample_type: IP|TID|TIME|ID|CPU|PERIOD, read_format: ID, inherit: 1, mmap: 1,    \
          comm: 1, freq: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, \
           bpf_event: 1
      
        terminal 2:
          # echo 'evlist -g' > control
      
        terminal 1:
          {cycles,instructions}
          dummy:HG
      
        terminal 2:
          # echo 'evlist -F' > control
      
        terminal 1:
          cycles: sample_freq=4000
          instructions: sample_freq=4000
          dummy:HG: sample_freq=4000
      
      This new evlist command is handy to get real event names when
      wildcards are used.
      
      Adding evsel_fprintf.c object to python/perf.so build, because
      it's now evlist.c dependency.
      
      Adding PYTHON_PERF define for python/perf.so compilation, so we
      can use it to compile in only evsel__fprintf from evsel_fprintf.c
      object.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201226232038.390883-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      142544a9
    • J
      perf tools: Allow to enable/disable events via control file · 991ae4eb
      Jiri Olsa 提交于
      Adding new control events to enable/disable specific event.
      The interface string for control file are:
      
        'enable <EVENT NAME>'
        'disable <EVENT NAME>'
      
      when received the command, perf will scan the current evlist
      for <EVENT NAME> and if found it's enabled/disabled.
      
      Example session:
      
        terminal 1:
          # mkfifo control ack perf.pipe
          # perf record --control=fifo:control,ack -D -1 --no-buffering -e 'sched:*' -o - > perf.pipe
      
        terminal 2:
          # cat perf.pipe | perf --no-pager script -i -
      
        terminal 1:
          Events disabled
      
        NOTE Above message will show only after read side of the pipe ('>')
        is started on 'terminal 2'. The 'terminal 1's bash does not execute
        perf before that, hence the delyaed perf record message.
      
        terminal 3:
          # echo 'enable sched:sched_process_fork' > control
      
        terminal 1:
          event sched:sched_process_fork enabled
      
        terminal 2:
          bash 33349 [034] 149587.674295: sched:sched_process_fork: comm=bash pid=33349 child_comm=bash child_pid=34056
          bash 33349 [034] 149588.239521: sched:sched_process_fork: comm=bash pid=33349 child_comm=bash child_pid=34057
      
        terminal 3:
          # echo 'enable sched:sched_wakeup_new' > control
      
        terminal 1:
          event sched:sched_wakeup_new enabled
      
        terminal 2:
          bash 33349 [034] 149632.228023: sched:sched_process_fork: comm=bash pid=33349 child_comm=bash child_pid=34059
          bash 33349 [034] 149632.228050:   sched:sched_wakeup_new: bash:34059 [120] success=1 CPU:036
          bash 33349 [034] 149633.950005: sched:sched_process_fork: comm=bash pid=33349 child_comm=bash child_pid=34060
          bash 33349 [034] 149633.950030:   sched:sched_wakeup_new: bash:34060 [120] success=1 CPU:036
      
      Committer testing:
      
      If I use 'sched:*' and then enable all events, I can't get 'perf record'
      to react to further commands, so I tested it with:
      
        [root@five ~]# perf record --control=fifo:control,ack -D -1 --no-buffering -e 'sched:sched_process_*' -o - > perf.pipe
        Events disabled
        Events enabled
        Events disabled
      
      And then it works as expected, so we need to fix this pre-existing
      problem.
      
      Another issue, we need to check if a event is already enabled or
      disabled and change the message to be clearer, i.e.:
      
        [root@five ~]# perf record --control=fifo:control,ack -D -1 --no-buffering -e 'sched:sched_process_*' -o - > perf.pipe
        Events disabled
      
      If we receive a 'disable' command, then it should say:
      
        [root@five ~]# perf record --control=fifo:control,ack -D -1 --no-buffering -e 'sched:sched_process_*' -o - > perf.pipe
        Events disabled
        Events already disabled
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201226232038.390883-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      991ae4eb
    • K
      perf record: Add support for PERF_SAMPLE_CODE_PAGE_SIZE · c1de7f3d
      Kan Liang 提交于
      Adds the infrastructure to sample the code address page size.
      
      Introduce a new --code-page-size option for perf record.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Originally-by: NStephane Eranian <eranian@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20210105195752.43489-4-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c1de7f3d
  9. 28 12月, 2020 1 次提交
    • J
      perf record: Add --buildid-mmap option to enable PERF_RECORD_MMAP2's build id · e29386c8
      Jiri Olsa 提交于
      Add --buildid-mmap option to enable build id in PERF_RECORD_MMAP2 events.
      
      It will only work if there's kernel support for that and it disables
      build id cache (implies --no-buildid).
      
      It's also possible to enable it permanently via config option in
      ~/.perfconfig file:
      
        [record]
        build-id=mmap
      
      Also added build_id bit in the verbose output for perf_event_attr:
      
        # perf record --buildid-mmap -vv
        ...
        perf_event_attr:
          type                             1
          size                             120
          ...
          build_id                         1
      
      Adding also missing text_poke bit.
      
      Committer testing:
      
        $ perf record -h build
      
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
            -B, --no-buildid      do not collect buildids in perf.data
            -N, --no-buildid-cache
                                  do not update the buildid cache
                --buildid-all     Record build-id of all DSOs regardless of hits
                --buildid-mmap    Record build-id in map events
      
        $
      
        $ perf record --buildid-mmap sleep 1
        Failed: no support to record build id in mmap events, update your kernel.
        $
      
      After adding the needed kernel bits in a test kernel:
      
        $ perf record -vv --buildid-mmap sleep 1 |& grep -m1 build
        Enabling build id in mmap2 events.
        $ perf evlist -v
        cycles:u: size: 120, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 1, exclude_kernel: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, build_id: 1
        $
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201214105457.543111-16-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e29386c8
  10. 18 12月, 2020 1 次提交
  11. 01 12月, 2020 6 次提交
  12. 30 11月, 2020 4 次提交
  13. 05 9月, 2020 4 次提交
  14. 01 9月, 2020 2 次提交
  15. 07 8月, 2020 1 次提交
    • J
      perf record: Skip side-band event setup if HAVE_LIBBPF_SUPPORT is not set · 1101c872
      Jin Yao 提交于
      We received an error report that perf-record caused 'Segmentation fault'
      on a newly system (e.g. on the new installed ubuntu).
      
        (gdb) backtrace
        #0  __read_once_size (size=4, res=<synthetic pointer>, p=0x14) at /root/0-jinyao/acme/tools/include/linux/compiler.h:139
        #1  atomic_read (v=0x14) at /root/0-jinyao/acme/tools/include/asm/../../arch/x86/include/asm/atomic.h:28
        #2  refcount_read (r=0x14) at /root/0-jinyao/acme/tools/include/linux/refcount.h:65
        #3  perf_mmap__read_init (map=map@entry=0x0) at mmap.c:177
        #4  0x0000561ce5c0de39 in perf_evlist__poll_thread (arg=0x561ce68584d0) at util/sideband_evlist.c:62
        #5  0x00007fad78491609 in start_thread (arg=<optimized out>) at pthread_create.c:477
        #6  0x00007fad7823c103 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      
      The root cause is, evlist__add_bpf_sb_event() just returns 0 if
      HAVE_LIBBPF_SUPPORT is not defined (inline function path). So it will
      not create a valid evsel for side-band event.
      
      But perf-record still creates BPF side band thread to process the
      side-band event, then the error happpens.
      
      We can reproduce this issue by removing the libelf-dev. e.g.
      1. apt-get remove libelf-dev
      2. perf record -a -- sleep 1
      
        root@test:~# ./perf record -a -- sleep 1
        perf: Segmentation fault
        Obtained 6 stack frames.
        ./perf(+0x28eee8) [0x5562d6ef6ee8]
        /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fbfdc65f210]
        ./perf(+0x342e74) [0x5562d6faae74]
        ./perf(+0x257e39) [0x5562d6ebfe39]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x9609) [0x7fbfdc990609]
        /lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7fbfdc73b103]
        Segmentation fault (core dumped)
      
      To fix this issue,
      
      1. We either install the missing libraries to let HAVE_LIBBPF_SUPPORT
         be defined.
         e.g. apt-get install libelf-dev and install other related libraries.
      
      2. Use this patch to skip the side-band event setup if HAVE_LIBBPF_SUPPORT
         is not set.
      
      Committer notes:
      
      The side band thread is not used just with BPF, it is also used with
      --switch-output-event, so narrow the ifdef to the BPF specific part.
      
      Fixes: 23cbb41c ("perf record: Move side band evlist setup to separate routine")
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200805022937.29184-1-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1101c872
  16. 06 8月, 2020 3 次提交
    • J
      perf tools: Move clockid_res_ns under clock struct · 9d88a1a1
      Jiri Olsa 提交于
      Move the clockid_res_ns struct member to the clock struct, so we have
      the clock related stuff in one place.
      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: Geneviève Bastien <gbastien@versatic.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jeremie Galarneau <jgalar@efficios.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lore.kernel.org/lkml/20200805093444.314999-5-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9d88a1a1
    • J
      perf header: Store clock references for -k/--clockid option · d1e325cf
      Jiri Olsa 提交于
      Add a new CLOCK_DATA feature that stores reference times when
      -k/--clockid option is specified.
      
      It contains the clock id and its reference time together with wall clock
      time taken at the 'same time', both values are in nanoseconds.
      
      The format of data is as below:
      
        struct {
             u32 version;  /* version = 1 */
             u32 clockid;
             u64 wall_clock_ns;
             u64 clockid_time_ns;
        };
      
      This clock reference times will be used in following changes to display
      wall clock for perf events.
      
      It's available only for recording with clockid specified, because it's
      the only case where we can get reference time to wallclock time. It's
      can't do that with perf clock yet.
      
      Committer testing:
      
        $ perf record -h -k
      
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
            -k, --clockid <clockid>
                                  clockid to use for events, see clock_gettime()
      
        $ perf record -k monotonic sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.017 MB perf.data (8 samples) ]
        $ perf report --header-only | grep clockid -A1
        # event : name = cycles:u, , id = { 88815, 88816, 88817, 88818, 88819, 88820, 88821, 88822 }, size = 120, { sample_period, sample_freq } = 4000, sample_type = IP|TID|TIME|PERIOD, read_format = ID, disabled = 1, inherit = 1, exclude_kernel = 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, use_clockid = 1, ksymbol = 1, bpf_event = 1, clockid = 1
        # CPU_TOPOLOGY info available, use -I to display
        --
        # clockid frequency: 1000 MHz
        # cpu pmu capabilities: branches=32, max_precise=3, pmu_name=skylake
        # clockid: monotonic (1)
        # reference time: 2020-08-06 09:40:21.619290 = 1596717621.619290 (TOD) = 21931.077673635 (monotonic)
        $
      Original-patch-by: NDavid Ahern <dsahern@gmail.com>
      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: Geneviève Bastien <gbastien@versatic.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jeremie Galarneau <jgalar@efficios.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lore.kernel.org/lkml/20200805093444.314999-4-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d1e325cf
    • J
      perf clockid: Move parse_clockid() to new clockid object · 6953beb4
      Jiri Olsa 提交于
      Move parse_clockid and all needed clcckid related stuff into clockid
      object. We are going to add clockid_name function in following change,
      so it's better it's placed in separated object and not in
      builtin-record.c.
      
      No functional change is intended.
      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: Geneviève Bastien <gbastien@versatic.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jeremie Galarneau <jgalar@efficios.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lore.kernel.org/lkml/20200805093444.314999-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6953beb4
  17. 04 8月, 2020 2 次提交