1. 20 Jan, 2021 22 commits
    • Jiri Olsa's avatar
      perf tools: Add 'evlist' control command · 142544a9
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarNamhyung 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      142544a9
    • Jiri Olsa's avatar
      perf tools: Allow to enable/disable events via control file · 991ae4eb
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarNamhyung 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      991ae4eb
    • Jiri Olsa's avatar
      perf config: Make perf_config_global() global · e8b2db07
      Jiri Olsa authored
      Make perf_config_global global, it will be used outside the config.c
      object in the following patches.
      Signed-off-by: default avatarJiri Olsa <jolsa@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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210102220441.794923-7-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e8b2db07
    • Jiri Olsa's avatar
      perf config: Make perf_config_system() global · b2946282
      Jiri Olsa authored
      Make perf_config_system global, it will be used outside the config.c
      object in the following patches.
      Signed-off-by: default avatarJiri Olsa <jolsa@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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210102220441.794923-6-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b2946282
    • Jiri Olsa's avatar
      perf config: Add perf_home_perfconfig function · f5f03e19
      Jiri Olsa authored
      Factor out the perf_home_perfconfig, that looks for .perfconfig in home
      directory including check for PERF_CONFIG_NOGLOBAL and for proper
      permission.
      Signed-off-by: default avatarJiri Olsa <jolsa@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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210102220441.794923-5-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f5f03e19
    • Jiri Olsa's avatar
      perf debug: Add debug_set_display_time function · bcbd79d1
      Jiri Olsa authored
      Allow to display time in perf debug output via new
      debug_set_display_time function.
      
      It will be used in perf daemon command to get verbose output into log
      file.
      
      The debug time format is:
      
        [2020-12-03 18:25:31.822152] affinity: SYS
        [2020-12-03 18:25:31.822164] mmap flush: 1
        [2020-12-03 18:25:31.822175] comp level: 0
        [2020-12-03 18:25:32.002047] mmap size 528384B
      
      Committer notes:
      
      Cast tod.tv_usec to long to avoid this problem:
      
          78    12.70 ubuntu:18.04-x-sparc64        : FAIL sparc64-linux-gnu-gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
      
        util/debug.c: In function 'fprintf_time':
        util/debug.c:63:32: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type '__suseconds_t {aka int}' [-Werror=format=]
          return fprintf(file, "[%s.%06lu] ", date, tod.tv_usec);
                                    ~~~~^           ~~~~~~~~~~~
                                    %06u
      Signed-off-by: default avatarJiri Olsa <jolsa@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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210102220441.794923-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bcbd79d1
    • Jiri Olsa's avatar
      perf config: Add config set interface · a523026c
      Jiri Olsa authored
      Add interface to load config set from custom file by using
      perf_config_set__load_file function.
      
      It will be used in perf daemon command to process custom config file.
      Signed-off-by: default avatarJiri Olsa <jolsa@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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210102220441.794923-3-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a523026c
    • Jiri Olsa's avatar
      perf config: Make perf_config_from_file() static · 64b9705b
      Jiri Olsa authored
      It's not used outside config.c object.
      Signed-off-by: default avatarJiri Olsa <jolsa@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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20210102220441.794923-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      64b9705b
    • Stephane Eranian's avatar
      perf test: Add test case for PERF_SAMPLE_CODE_PAGE_SIZE · d8eda898
      Stephane Eranian authored
      Extend sample-parsing test cases to support new sample type
      PERF_SAMPLE_CODE_PAGE_SIZE.
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung 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-7-kan.liang@linux.intel.comSigned-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d8eda898
    • Stephane Eranian's avatar
      perf report: Add support for PERF_SAMPLE_CODE_PAGE_SIZE · 9fd74f20
      Stephane Eranian authored
      Add a new sort dimension "code_page_size" for common sort.
      With this option applied, perf can sort and report by sample's code page
      size.
      
      For example:
      
        # perf report --stdio --sort=comm,symbol,code_page_size
        # To display the perf.data header info, please use
        # --header/--header-only options.
        #
        #
        # Total Lost Samples: 0
        #
        # Samples: 3K of event 'mem-loads:uP'
        # Event count (approx.): 1470769
        #
        # Overhead  Command  Symbol                        Code Page Size IPC [IPC Coverage]
        # ........  .......  ............................  .............. ....................
        #
            69.56%  dtlb     [.] GetTickCount              4K              -   -
            17.93%  dtlb     [.] Calibrate                 4K              -   -
            11.40%  dtlb     [.] __gettimeofday            4K              -   -
        #
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung 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-6-kan.liang@linux.intel.comSigned-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9fd74f20
    • Stephane Eranian's avatar
      perf script: Add support for PERF_SAMPLE_CODE_PAGE_SIZE · c513de8a
      Stephane Eranian authored
      Display sampled code page sizes when PERF_SAMPLE_CODE_PAGE_SIZE was set.
      
      For example:
      
        # perf script --fields comm,event,ip,code_page_size
                  dtlb mem-loads:uP:            445777 4K
                  dtlb mem-loads:uP:            40f724 4K
                  dtlb mem-loads:uP:            474926 4K
                  dtlb mem-loads:uP:            401075 4K
                  dtlb mem-loads:uP:            401095 4K
                  dtlb mem-loads:uP:            401095 4K
                  dtlb mem-loads:uP:            4010cc 4K
                  dtlb mem-loads:uP:            440b6f 4K
        #
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung 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-5-kan.liang@linux.intel.comSigned-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c513de8a
    • Kan Liang's avatar
      perf record: Add support for PERF_SAMPLE_CODE_PAGE_SIZE · c1de7f3d
      Kan Liang authored
      Adds the infrastructure to sample the code address page size.
      
      Introduce a new --code-page-size option for perf record.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Originally-by: default avatarStephane Eranian <eranian@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c1de7f3d
    • Kan Liang's avatar
      perf mem: Support data page size · 06280e3b
      Kan Liang authored
      Add option --data-page-size in "perf mem" to record/report data page
      size.
      
      Here are some examples:
      
        # perf mem --phys-data --data-page-size report -D
        # PID, TID, IP, ADDR, PHYS ADDR, DATA PAGE SIZE, LOCAL WEIGHT, DSRC, SYMBOL
        20134 20134 0xffffffffb5bd2fd0 0x016ffff9a274e96a308 0x000000044e96a308 4K  1168 0x5080144 /lib/modules/4.18.0-rc7+/build/vmlinux:perf_ctx_unlock
        20134 20134 0xffffffffb63f645c 0xffffffffb752b814 0xcfb52b814 2M 225 0x26a100142 /lib/modules/4.18.0-rc7+/build/vmlinux:_raw_spin_lock
        20134 20134 0xffffffffb660300c 0xfffffe00016b8bb0 0x0 4K 0 0x5080144 /lib/modules/4.18.0-rc7+/build/vmlinux:__x86_indirect_thunk_rax
        #
      
        # perf mem --phys-data --data-page-size report --stdio
        # To display the perf.data header info, please use
        # --header/--header-only options.
        #
        #
        # Total Lost Samples: 0
        #
        # Samples: 5K of event 'cpu/mem-loads,ldlat=30/P'
        # Total weight : 281234
        # Sort order   :
        # mem,sym,dso,symbol_daddr,dso_daddr,tlb,locked,phys_daddr,data_page_size
        #
        # Overhead  Samples  Memory access  Symbol                        Shared Object     Data Symbol             Data Object  TLB access    Locked  Data Physical Address   Data Page Size
        # ........  .......  .............  ............................  ................  ......................  ...........  ............  ......  ......................  ..............
      
          28.54%     1826    L1 or L1 hit   [k] __x86_indirect_thunk_rax  [kernel.vmlinux]  [k] 0xffffb0df31b0ff28  [unknown]    L1 or L2 hit  No      [k] 0x0000000000000000  4K
           6.02%      256    L1 or L1 hit   [.] touch_buffer              dtlb              [.] 0x00007ffd50109da8  [stack]      L1 or L2 hit  No      [.] 0x000000042454ada8  4K
           3.23%        5    L1 or L1 hit   [k] clear_huge_page           [kernel.vmlinux]  [k] 0xffff9a2753b8ce60  [unknown]    L1 or L2 hit  No      [k] 0x0000000453b8ce60  2M
           2.98%        4    L1 or L1 hit   [k] clear_page_erms           [kernel.vmlinux]  [k] 0xffffb0df31b0fd00  [unknown]    L1 or L2 hit  No      [k] 0x0000000000000000  4K
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung 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: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20210105195752.43489-3-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      06280e3b
    • Kan Liang's avatar
      perf mem: Clean up output format · 407ee5c9
      Kan Liang authored
      Now, "--phys-data" is the only option which impacts the output format.
      
      A simple "if else" is enough to handle the option. But there will be
      more options added, e.g. "--data-page-size", which also impact the
      output format. The code will become too complex to be maintained.
      
      Divide the big printf into several small pieces. Output the specific
      piece only if the related option is applied.
      
      No functional change.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung 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: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20210105195752.43489-2-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      407ee5c9
    • James Clark's avatar
      perf cs-etm: Update ARM's CoreSight hardware tracing OpenCSD library to v1.0.0 · 80ec45d9
      James Clark authored
      Replace the OCSD_INSTR switch statement with an if to fix compilation
      error about unhandled values and avoid this issue again in the future.
      
      Add new OCSD_GEN_TRC_ELEM_SYNC_MARKER and OCSD_GEN_TRC_ELEM_MEMTRANS
      enum values to fix unhandled value compilation error. Currently they are
      ignored.
      
      Increase the minimum version number to v1.0.0 now that new enum values
      are used that are only present in this version.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: default avatarMike Leach <mike.leach@linaro.org>
      Tested-by: default avatarMike Leach <mike.leach@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20210108142752.27872-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      80ec45d9
    • Leo Yan's avatar
      perf c2c: Add local variables for output metrics · 0998d960
      Leo Yan authored
      This patch adds several local variables:
      
        "cl_output": pointer for outputting single cache line metrics;
        "output_str": pointer for outputting cache line metrics;
        "sort_str": pointer to the sorting metrics.
      
      This can improve readability for the code and it's more flexible when
      later extend to different strings for the output metrics.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Joe Mario <jmario@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20210114154646.209024-7-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0998d960
    • Leo Yan's avatar
      perf c2c: Refactor node display · f3d0a551
      Leo Yan authored
      The macro DISPLAY_HITM() is used to calculate HITM percentage introduced
      by every node and it's shown for the node info.
      
      This patch introduces the static function display_metrics() to replace
      the macro, and the parameters are refined for passing the metric's
      statistic and sum value.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Joe Mario <jmario@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20210114154646.209024-6-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f3d0a551
    • Leo Yan's avatar
      perf c2c: Fix argument type for percent() · 111c1415
      Leo Yan authored
      For percent() its arguments are defined as integers; this is not
      consistent with its consumers which pass u32 arguments.
      
      Thus this patch makes argument type as u32 for percent().
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Joe Mario <jmario@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20210114154646.209024-5-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      111c1415
    • Leo Yan's avatar
      perf c2c: Refactor display filter · 69a95bfd
      Leo Yan authored
      When sorting on the respective metrics (lcl_hitm, rmt_hitm, tot_hitm),
      the FILTER_HITM macro is used to filter out the cache line entries if
      its overhead is less than 1%.
      
      This patch introduces a static function filter_display() to replace that
      macro and refines its parameters with a more flexible way, rather than
      passing field name, it changes to pass the cache line's statistic and
      sum value.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Joe Mario <jmario@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20210114154646.209024-4-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      69a95bfd
    • Leo Yan's avatar
      perf c2c: Refactor hist entry validation · 2290e1d6
      Leo Yan authored
      This patch has no functionality changes but refactors hist entry
      validation for cache line resorting.
      
      It renames function "valid_hitm_or_store()" to "is_valid_hist_entry()",
      changes return type from integer type to bool type.  In the function,
      it uses switch-case instead of ternary operators, which is easier
      to extend for more display types.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Joe Mario <jmario@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20210114154646.209024-3-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2290e1d6
    • Leo Yan's avatar
      perf c2c: Rename for shared cache line stats · 1834436e
      Leo Yan authored
      For shared cache line statistics, 'perf c2c' relies on HITM.  We can use
      more general naming rather than only binding to HITM, so replace
      "hitm_stats" with "shared_clines_stats" in structure perf_c2c, and
      rename function resort_hitm_cb() to resort_shared_cl_cb().
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Joe Mario <jmario@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/r/20210114154646.209024-2-leo.yan@linaro.org
      1834436e
    • Song Liu's avatar
      perf stat: Enable counting events for BPF programs · fa853c4b
      Song Liu authored
      Introduce 'perf stat -b' option, which counts events for BPF programs, like:
      
        [root@localhost ~]# ~/perf stat -e ref-cycles,cycles -b 254 -I 1000
           1.487903822            115,200      ref-cycles
           1.487903822             86,012      cycles
           2.489147029             80,560      ref-cycles
           2.489147029             73,784      cycles
           3.490341825             60,720      ref-cycles
           3.490341825             37,797      cycles
           4.491540887             37,120      ref-cycles
           4.491540887             31,963      cycles
      
      The example above counts 'cycles' and 'ref-cycles' of BPF program of id
      254.  This is similar to bpftool-prog-profile command, but more
      flexible.
      
      'perf stat -b' creates per-cpu perf_event and loads fentry/fexit BPF
      programs (monitor-progs) to the target BPF program (target-prog). The
      monitor-progs read perf_event before and after the target-prog, and
      aggregate the difference in a BPF map. Then the user space reads data
      from these maps.
      
      A new 'struct bpf_counter' is introduced to provide a common interface
      that uses BPF programs/maps to count perf events.
      
      Committer notes:
      
      Removed all but bpf_counter.h includes from evsel.h, not needed at all.
      
      Also BPF map lookups for PERCPU_ARRAYs need to have as its value receive
      buffer passed to the kernel libbpf_num_possible_cpus() entries, not
      evsel__nr_cpus(evsel), as the former uses
      /sys/devices/system/cpu/possible while the later uses
      /sys/devices/system/cpu/online, which may be less than the 'possible'
      number making the bpf map lookup overwrite memory and cause hard to
      debug memory corruption.
      
      We need to continue using evsel__nr_cpus(evsel) when accessing the
      perf_counts array tho, not to overwrite another are of memory :-)
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/lkml/20210120163031.GU12699@kernel.org/Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Link: http://lore.kernel.org/lkml/20201229214214.3413833-4-songliubraving@fb.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fa853c4b
  2. 15 Jan, 2021 2 commits
  3. 28 Dec, 2020 13 commits
    • Hans-Peter Nilsson's avatar
      perf record: Tweak "Lowering..." warning in record_opts__config_freq · c07b45a3
      Hans-Peter Nilsson authored
      That is, instead of "Lowering default frequency rate to <F>" say
      "Lowering default frequency rate from <f> to <F>", specifying the
      overridden default frequency <f>, so you don't have to grep through the
      source to "remember" that was e.g. 4000.
      Signed-off-by: default avatarHans-Peter Nilsson <hp@axis.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20201228031908.B049B203B5@pchp3.se.axis.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c07b45a3
    • Jiri Olsa's avatar
      perf buildid-list: Add support for mmap2's buildid events · d176db95
      Jiri Olsa authored
      Add buildid-list support for mmap2's build id data, so we can display
      build ids for dso objects for data without the build id cache update.
      
        $ perf buildid-list
        1805c738c8f3ec0f47b7ea09080c28f34d18a82b /usr/lib64/ld-2.31.so
        d278249792061c6b74d1693ca59513be1def13f2 /usr/lib64/libc-2.31.so
      
      By default only dso objects with hits are shown.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung 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: 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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201214105457.543111-15-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d176db95
    • Jiri Olsa's avatar
      perf buildid-cache: Add --debuginfod option to specify a server to fetch debug files · e8a2061f
      Jiri Olsa authored
      Add the --debuginfod option to specify debuginfod URL and support to do
      that through config file as well.
      
      Use the following in ~/.perfconfig file:
      
        [buildid-cache]
        debuginfod=http://192.168.122.174:8002Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung 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-14-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e8a2061f
    • Jiri Olsa's avatar
      perf tools: Add support to display build ids when available in PERF_RECORD_MMAP2 events · 0b5c8821
      Jiri Olsa authored
      Add support to display the build id in PERF_RECORD_MMAP2 events, when
      available:
      
        $ perf script --show-mmap-events | head -4
        swapper ... @ 0xffffffff81000000 <ff1969b3ba5e43911208bb46fa7d5b1eb809e422>]: ---p [kernel.kallsyms]_text
        swapper ... @ 0 <5f62adb730272c9417883ae8b8a8ec224df8cddd>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/drivers/firmware/qemu_fw_cfg.ko
        swapper ... @ 0 <c9ac6e1dafc1ebdadb048f967854e810706c8bab>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/drivers/char/virtio_console.ko
        swapper ... @ 0 <86441a4c5b2c2ff5b440682f4c612bd4b426eb5c>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/lib/libcrc32c.ko
      
        $ perf report -D | grep MMAP2 | head -4
        0 0 ... @ 0xffffffff81000000 <ff1969b3ba5e43911208bb46fa7d5b1eb809e422>]: ---p [kernel.kallsyms]_text
        0 0 ... @ 0 <5f62adb730272c9417883ae8b8a8ec224df8cddd>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/drivers/firmware/qemu_fw_cfg.ko
        0 0 ... @ 0 <c9ac6e1dafc1ebdadb048f967854e810706c8bab>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/drivers/char/virtio_console.ko
        0 0 ... @ 0 <86441a4c5b2c2ff5b440682f4c612bd4b426eb5c>]: ---p /lib/modules/5.9.0-rc5buildid+/kernel/lib/libcrc32c.ko
      
      Adding build id data into <> brackets.
      
      Committer testing:
      
        $ 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
        $
        $ perf script --show-mmap-events | head -4
                 sleep 274800  2843.556112: PERF_RECORD_MMAP2 274800/274800: [0x564e2fd32000(0x3000) @ 0x2000 <c37cb90b77c79fc719798b066d78ef121285843e>]: r-xp /usr/bin/sleep
                 sleep 274800  2843.556129: PERF_RECORD_MMAP2 274800/274800: [0x7fa9550d7000(0x21000) @ 0x1000 <fc190f17c4f4dc4a8a26df18eaeed41ecdb2c61b>]: r-xp /usr/lib64/ld-2.32.so
                 sleep 274800  2843.556140: PERF_RECORD_MMAP2 274800/274800: [0x7ffd8fa96000(0x2000) @ 0 00:00 0 0]: r-xp [vdso]
                 sleep 274800  2843.556162:          1 cycles:u:  ffffffffbb26bff4 [unknown] ([unknown])
        $
        $ perf buildid-list -i /usr/bin/sleep
        c37cb90b77c79fc719798b066d78ef121285843e
        $ perf buildid-list -i /usr/lib64/ld-2.32.so
        fc190f17c4f4dc4a8a26df18eaeed41ecdb2c61b
      
      And now on a system wide session to check the build ids synthesized for
      the kernel and some kernel modules:
      
        # perf record -a --buildid-mmap sleep 2s
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.717 MB perf.data ]
        # perf script --show-mmap-events | head -4
                 swapper     0 [000]     0.000000: PERF_RECORD_MMAP2 -1/0: [0xffffffffbb000000(0xe02557) @ 0xffffffffbb000000 <e71ac4b0b0631c27181dab25d63be18dad02feb8>]: ---p [kernel.kallsyms]_text
                 swapper     0 [000]     0.000000: PERF_RECORD_MMAP2 -1/0: [0xffffffffc01dc000(0x6000) @ 0 <36d21515c0b22eb2859b6419a6cdf87ef4cd01c8>]: ---p /lib/modules/5.11.0-rc1+/kernel/drivers/i2c/i2c-dev.ko
                 swapper     0 [000]     0.000000: PERF_RECORD_MMAP2 -1/0: [0xffffffffc01eb000(0x24000) @ 0 <c4fbfea32d0518b3e7879de8deca40ea142bb782>]: ---p /lib/modules/5.11.0-rc1+/kernel/fs/fuse/fuse.ko
                 swapper     0 [000]     0.000000: PERF_RECORD_MMAP2 -1/0: [0xffffffffc0210000(0x7000) @ 0 <dd6cfb10ae66aa7b1e7b37000a004004be8092e0>]: ---p /lib/modules/5.11.0-rc1+/kernel/drivers/block/zram/zram.ko
        # perf buildid-list -h kernel
      
         Usage: perf buildid-list [<options>]
      
            -k, --kernel          Show current kernel build id
      
        # perf buildid-list --kernel
        e71ac4b0b0631c27181dab25d63be18dad02feb8
        # file /lib/modules/5.11.0-rc1+/kernel/drivers/i2c/i2c-dev.ko
        /lib/modules/5.11.0-rc1+/kernel/drivers/i2c/i2c-dev.ko: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), BuildID[sha1]=36d21515c0b22eb2859b6419a6cdf87ef4cd01c8, with debug_info, not stripped
        # perf buildid-list -i /lib/modules/5.11.0-rc1+/kernel/drivers/i2c/i2c-dev.ko
        36d21515c0b22eb2859b6419a6cdf87ef4cd01c8
        # perf buildid-list -i /lib/modules/5.11.0-rc1+/kernel/fs/fuse/fuse.ko
        c4fbfea32d0518b3e7879de8deca40ea142bb782
        # perf buildid-list -i /lib/modules/5.11.0-rc1+/kernel/drivers/block/zram/zram.ko
        dd6cfb10ae66aa7b1e7b37000a004004be8092e0
        #
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung 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-12-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0b5c8821
    • Jiri Olsa's avatar
      perf record: Add --buildid-mmap option to enable PERF_RECORD_MMAP2's build id · e29386c8
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e29386c8
    • Jiri Olsa's avatar
      perf tools: Allow synthesizing the build id for kernel/modules/tasks in PERF_RECORD_MMAP2 · 4183a8d7
      Jiri Olsa authored
      Adding build id to synthesized mmap2 events for everything -
      kernel/modules/tasks, when symbol_conf.buildid_mmap2 is true.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung 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: 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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201214105457.543111-11-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4183a8d7
    • Jiri Olsa's avatar
      perf tools: Allow using PERF_RECORD_MMAP2 to synthesize the kernel modules maps · e0dbf18f
      Jiri Olsa authored
      Allow using PERF_RECORD_MMAP2 to synthesize the kernel modules maps so
      that we can use PERF_RECORD_MMAP2 to encode the kernel modules build ids
      in the following csets.
      
      It's enabled by a new symbol_conf.buildid_mmap2 bool field, which will
      be switchable in following changes.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung 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-10-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e0dbf18f
    • Jiri Olsa's avatar
      perf tools: Allow using PERF_RECORD_MMAP2 to synthesize the kernel map · 978410ff
      Jiri Olsa authored
      Allow using PERF_RECORD_MMAP2 to synthesize the kernel map so that we
      can use PERF_RECORD_MMAP2 to encode the kernel build id in the following
      csets.
      
      It's enabled by a new symbol_conf.buildid_mmap2 bool field, which will
      be switchable in following changes.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung 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: 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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201214105457.543111-9-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      978410ff
    • Jiri Olsa's avatar
      perf tools: Store build id when available in PERF_RECORD_MMAP2 metadata events · 1ca6e802
      Jiri Olsa authored
      When processing a PERF_RECORD_MMAP2 metadata event, check on the build
      id misc bit: PERF_RECORD_MISC_MMAP_BUILD_ID and if it is set, store the
      build id in mmap's dso object.
      
      Also adding the build id data to struct perf_record_mmap2 event
      definition.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung 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: 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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201214105457.543111-8-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1ca6e802
    • Jiri Olsa's avatar
      perf tools: Do not swap mmap2 fields in case it contains build id · 29245ae8
      Jiri Olsa authored
      If the PERF_RECORD_MISC_MMAP_BUILD_ID misc bit is set, mmap2 events
      carries a build id, placed in the following union:
      
        union {
                struct {
                        u32       maj;
                        u32       min;
                        u64       ino;
                        u64       ino_generation;
                };
                struct {
                        u8        build_id_size;
                        u8        __reserved_1;
                        u16       __reserved_2;
                        u8        build_id[20];
                };
        };
      
      In this case we can't swap above fields.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung 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: 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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201214105457.543111-6-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      29245ae8
    • Jiri Olsa's avatar
      tools headers uapi: Sync tools/include/uapi/linux/perf_event.h · dde587aa
      Jiri Olsa authored
      Syncing tools's uapi with mmap2 build id data changes.
      
      Committer notes:
      
      I'm taking the tools/ bits, so this will be in fact ahead of the kernel
      till the bpf/perf-kernel bits are merged.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung 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: 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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201214105457.543111-5-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dde587aa
    • Leo Yan's avatar
      perf arm64: Add argument support for SDT · feab999e
      Leo Yan authored
      Now the two OP formats are used for SDT marker argument in Arm64 ELF,
      one format is general register xNUM (e.g. x1, x2, etc), another is for
      using stack pointer to access local variables (e.g. [sp], [sp, 8]).
      
      This patch adds support SDT marker argument for Arm64, it parses OP and
      converts to uprobe compatible format.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Truong <alexandre.truong@arm.com>
      Cc: Alexis Berlemont <alexis.berlemont@gmail.com>
      Cc: He Zhe <zhe.he@windriver.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20201225052751.24513-4-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      feab999e
    • Leo Yan's avatar
      perf probe: Fixup Arm64 SDT arguments · f19b5872
      Leo Yan authored
      Arm64 ELF section '.note.stapsdt' uses string format "-4@[sp, NUM]" if
      the probe is to access data in stack, e.g. below is an example for
      dumping Arm64 ELF file and shows the argument format:
      
        Arguments: -4@[sp, 12] -4@[sp, 8] -4@[sp, 4]
      
      Comparing against other archs' argument format, Arm64's argument
      introduces an extra space character in the middle of square brackets,
      due to argv_split() uses space as splitter, the argument is wrongly
      divided into two items.
      
      To support Arm64 SDT, this patch fixes up for this case, if any item
      contains sub string "[sp", concatenates the two continuous items.  And
      adds the detailed explaination in comment.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Truong <alexandre.truong@arm.com>
      Cc: Alexis Berlemont <alexis.berlemont@gmail.com>
      Cc: He Zhe <zhe.he@windriver.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20201225052751.24513-3-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f19b5872
  4. 27 Dec, 2020 3 commits