1. 14 10月, 2020 6 次提交
  2. 13 10月, 2020 2 次提交
    • N
      perf inject: Do not load map/dso when injecting build-id · e7b60c5a
      Namhyung Kim 提交于
      No need to load symbols in a DSO when injecting build-id.  I guess the
      reason was to check the DSO is a special file like anon files.  Use some
      helper functions in map.c to check them before reading build-id.  Also
      pass sample event's cpumode to a new build-id event.
      
      It brought a speedup in the benchmark of 25 -> 21 msec on my laptop.
      Also the memory usage (Max RSS) went down by ~200 KB.
      
        # Running 'internals/inject-build-id' benchmark:
          Average build-id injection took: 21.389 msec (+- 0.138 msec)
          Average time per event: 2.097 usec (+- 0.014 usec)
          Average memory usage: 8225 KB (+- 0 KB)
      
      Committer notes:
      
      Before:
      
        $ perf stat -r5 perf bench internals inject-build-id > /dev/null
      
         Performance counter stats for 'perf bench internals inject-build-id' (5 runs):
      
                  4,020.56 msec task-clock:u              #    1.271 CPUs utilized            ( +-  0.74% )
                         0      context-switches:u        #    0.000 K/sec
                         0      cpu-migrations:u          #    0.000 K/sec
                   123,354      page-faults:u             #    0.031 M/sec                    ( +-  0.81% )
             7,119,951,568      cycles:u                  #    1.771 GHz                      ( +-  1.74% )  (83.27%)
               230,086,969      stalled-cycles-frontend:u #    3.23% frontend cycles idle     ( +-  1.97% )  (83.41%)
             1,168,298,765      stalled-cycles-backend:u  #   16.41% backend cycles idle      ( +-  1.13% )  (83.44%)
            11,173,083,669      instructions:u            #    1.57  insn per cycle
                                                          #    0.10  stalled cycles per insn  ( +-  1.58% )  (83.31%)
             2,413,908,936      branches:u                #  600.392 M/sec                    ( +-  1.69% )  (83.26%)
                46,576,289      branch-misses:u           #    1.93% of all branches          ( +-  2.20% )  (83.31%)
      
                    3.1638 +- 0.0309 seconds time elapsed  ( +-  0.98% )
      
        $
      
      After:
      
        $ perf stat -r5 perf bench internals inject-build-id > /dev/null
      
         Performance counter stats for 'perf bench internals inject-build-id' (5 runs):
      
                  2,379.94 msec task-clock:u              #    1.473 CPUs utilized            ( +-  0.18% )
                         0      context-switches:u        #    0.000 K/sec
                         0      cpu-migrations:u          #    0.000 K/sec
                    62,584      page-faults:u             #    0.026 M/sec                    ( +-  0.07% )
             2,372,389,668      cycles:u                  #    0.997 GHz                      ( +-  0.29% )  (83.14%)
               106,937,862      stalled-cycles-frontend:u #    4.51% frontend cycles idle     ( +-  4.89% )  (83.20%)
               581,697,915      stalled-cycles-backend:u  #   24.52% backend cycles idle      ( +-  0.71% )  (83.47%)
             3,659,692,199      instructions:u            #    1.54  insn per cycle
                                                          #    0.16  stalled cycles per insn  ( +-  0.10% )  (83.63%)
               791,372,961      branches:u                #  332.518 M/sec                    ( +-  0.27% )  (83.39%)
                10,648,083      branch-misses:u           #    1.35% of all branches          ( +-  0.22% )  (83.16%)
      
                   1.61570 +- 0.00172 seconds time elapsed  ( +-  0.11% )
      
        $
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Original-patch-by: NStephane Eranian <eranian@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Link: https://lore.kernel.org/r/20201012070214.2074921-5-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e7b60c5a
    • N
      perf bench: Add build-id injection benchmark · 0bf02a0d
      Namhyung Kim 提交于
      Sometimes I can see that 'perf record' piped with 'perf inject' take a
      long time processing build-ids.
      
      So introduce a inject-build-id benchmark to the internals benchmark
      suite to measure its overhead regularly.
      
      It runs the 'perf inject' command internally and feeds the given number
      of synthesized events (MMAP2 + SAMPLE basically).
      
        Usage: perf bench internals inject-build-id <options>
      
          -i, --iterations <n>  Number of iterations used to compute average (default: 100)
          -m, --nr-mmaps <n>    Number of mmap events for each iteration (default: 100)
          -n, --nr-samples <n>  Number of sample events per mmap event (default: 100)
          -v, --verbose         be more verbose (show iteration count, DSO name, etc)
      
      By default, it measures average processing time of 100 MMAP2 events
      and 10000 SAMPLE events.  Below is a result on my laptop.
      
        $ perf bench internals inject-build-id
        # Running 'internals/inject-build-id' benchmark:
          Average build-id injection took: 25.789 msec (+- 0.202 msec)
          Average time per event: 2.528 usec (+- 0.020 usec)
          Average memory usage: 8411 KB (+- 7 KB)
      
      Committer testing:
      
        $ perf bench
        Usage:
        	perf bench [<common options>] <collection> <benchmark> [<options>]
      
                # List of all available benchmark collections:
      
                 sched: Scheduler and IPC benchmarks
               syscall: System call benchmarks
                   mem: Memory access benchmarks
                  numa: NUMA scheduling and MM benchmarks
                 futex: Futex stressing benchmarks
                 epoll: Epoll stressing benchmarks
             internals: Perf-internals benchmarks
                   all: All benchmarks
      
        $ perf bench internals
      
                # List of available benchmarks for collection 'internals':
      
            synthesize: Benchmark perf event synthesis
        kallsyms-parse: Benchmark kallsyms parsing
        inject-build-id: Benchmark build-id injection
      
        $ perf bench internals inject-build-id
        # Running 'internals/inject-build-id' benchmark:
          Average build-id injection took: 14.202 msec (+- 0.059 msec)
          Average time per event: 1.392 usec (+- 0.006 usec)
          Average memory usage: 12650 KB (+- 10 KB)
          Average build-id-all injection took: 12.831 msec (+- 0.071 msec)
          Average time per event: 1.258 usec (+- 0.007 usec)
          Average memory usage: 11895 KB (+- 10 KB)
        $
      
        $ perf stat -r5 perf bench internals inject-build-id
        # Running 'internals/inject-build-id' benchmark:
          Average build-id injection took: 14.380 msec (+- 0.056 msec)
          Average time per event: 1.410 usec (+- 0.006 usec)
          Average memory usage: 12608 KB (+- 11 KB)
          Average build-id-all injection took: 11.889 msec (+- 0.064 msec)
          Average time per event: 1.166 usec (+- 0.006 usec)
          Average memory usage: 11838 KB (+- 10 KB)
        # Running 'internals/inject-build-id' benchmark:
          Average build-id injection took: 14.246 msec (+- 0.065 msec)
          Average time per event: 1.397 usec (+- 0.006 usec)
          Average memory usage: 12744 KB (+- 10 KB)
          Average build-id-all injection took: 12.019 msec (+- 0.066 msec)
          Average time per event: 1.178 usec (+- 0.006 usec)
          Average memory usage: 11963 KB (+- 10 KB)
        # Running 'internals/inject-build-id' benchmark:
          Average build-id injection took: 14.321 msec (+- 0.067 msec)
          Average time per event: 1.404 usec (+- 0.007 usec)
          Average memory usage: 12690 KB (+- 10 KB)
          Average build-id-all injection took: 11.909 msec (+- 0.041 msec)
          Average time per event: 1.168 usec (+- 0.004 usec)
          Average memory usage: 11938 KB (+- 10 KB)
        # Running 'internals/inject-build-id' benchmark:
          Average build-id injection took: 14.287 msec (+- 0.059 msec)
          Average time per event: 1.401 usec (+- 0.006 usec)
          Average memory usage: 12864 KB (+- 10 KB)
          Average build-id-all injection took: 11.862 msec (+- 0.058 msec)
          Average time per event: 1.163 usec (+- 0.006 usec)
          Average memory usage: 12103 KB (+- 10 KB)
        # Running 'internals/inject-build-id' benchmark:
          Average build-id injection took: 14.402 msec (+- 0.053 msec)
          Average time per event: 1.412 usec (+- 0.005 usec)
          Average memory usage: 12876 KB (+- 10 KB)
          Average build-id-all injection took: 11.826 msec (+- 0.061 msec)
          Average time per event: 1.159 usec (+- 0.006 usec)
          Average memory usage: 12111 KB (+- 10 KB)
      
         Performance counter stats for 'perf bench internals inject-build-id' (5 runs):
      
                  4,267.48 msec task-clock:u              #    1.502 CPUs utilized            ( +-  0.14% )
                         0      context-switches:u        #    0.000 K/sec
                         0      cpu-migrations:u          #    0.000 K/sec
                   102,092      page-faults:u             #    0.024 M/sec                    ( +-  0.08% )
             3,894,589,578      cycles:u                  #    0.913 GHz                      ( +-  0.19% )  (83.49%)
               140,078,421      stalled-cycles-frontend:u #    3.60% frontend cycles idle     ( +-  0.77% )  (83.34%)
               948,581,189      stalled-cycles-backend:u  #   24.36% backend cycles idle      ( +-  0.46% )  (83.25%)
             5,835,587,719      instructions:u            #    1.50  insn per cycle
                                                          #    0.16  stalled cycles per insn  ( +-  0.21% )  (83.24%)
             1,267,423,636      branches:u                #  296.996 M/sec                    ( +-  0.22% )  (83.12%)
                17,484,290      branch-misses:u           #    1.38% of all branches          ( +-  0.12% )  (83.55%)
      
                   2.84176 +- 0.00222 seconds time elapsed  ( +-  0.08% )
      
        $
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20201012070214.2074921-2-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0bf02a0d
  3. 01 10月, 2020 1 次提交
    • J
      perf python scripting: Fix printable strings in python3 scripts · 6fcd5ddc
      Jiri Olsa 提交于
      Hagen reported broken strings in python3 tracepoint scripts:
      
        make PYTHON=python3
        perf record -e sched:sched_switch -a -- sleep 5
        perf script --gen-script py
        perf script -s ./perf-script.py
      
        [..]
        sched__sched_switch      7 563231.759525792        0 swapper   prev_comm=bytearray(b'swapper/7\x00\x00\x00\x00\x00\x00\x00'), prev_pid=0, prev_prio=120, prev_state=, next_comm=bytearray(b'mutex-thread-co\x00'),
      
      The problem is in the is_printable_array function that does not take the
      zero byte into account and claim such string as not printable, so the
      code will create byte array instead of string.
      
      Committer testing:
      
      After this fix:
      
      sched__sched_switch 3 484522.497072626  1158680 kworker/3:0-eve  prev_comm=kworker/3:0, prev_pid=1158680, prev_prio=120, prev_state=I, next_comm=swapper/3, next_pid=0, next_prio=120
      Sample: {addr=0, cpu=3, datasrc=84410401, datasrc_decode=N/A|SNP N/A|TLB N/A|LCK N/A, ip=18446744071841817196, period=1, phys_addr=0, pid=1158680, tid=1158680, time=484522497072626, transaction=0, values=[(0, 0)], weight=0}
      
      sched__sched_switch 4 484522.497085610  1225814 perf             prev_comm=perf, prev_pid=1225814, prev_prio=120, prev_state=, next_comm=migration/4, next_pid=30, next_prio=0
      Sample: {addr=0, cpu=4, datasrc=84410401, datasrc_decode=N/A|SNP N/A|TLB N/A|LCK N/A, ip=18446744071841817196, period=1, phys_addr=0, pid=1225814, tid=1225814, time=484522497085610, transaction=0, values=[(0, 0)], weight=0}
      
      Fixes: 249de6e0 ("perf script python: Fix string vs byte array resolving")
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NHagen Paul Pfeifer <hagen@jauu.net>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200928201135.3633850-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6fcd5ddc
  4. 28 9月, 2020 5 次提交
  5. 23 9月, 2020 3 次提交
    • L
      perf tsc: Support cap_user_time_short for event TIME_CONV · d110162c
      Leo Yan 提交于
      The synthesized event TIME_CONV doesn't contain the complete parameters
      for counters, this will lead to wrong conversion between counter cycles
      and timestamp.
      
      This patch extends event TIME_CONV to record flags 'cap_user_time_zero'
      which is used to indicate the counter parameters are valid or not, if
      not will directly return 0 for timestamp calculation.  And record the
      flag 'cap_user_time_short' and its relevant fields 'time_cycles' and
      'time_mask' for cycle calibration.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kemeng Shi <shikemeng@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Gasson <nick.gasson@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Remi Bernon <rbernon@codeweavers.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Steve Maclean <steve.maclean@microsoft.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zou Wei <zou_wei@huawei.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20200914115311.2201-5-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d110162c
    • L
      perf tsc: Calculate timestamp with cap_user_time_short · 78a93d4c
      Leo Yan 提交于
      The perf mmap'ed buffer contains the flag 'cap_user_time_short' and two
      extra fields 'time_cycles' and 'time_mask', perf tool needs to know them
      for handling the counter wrapping case.
      
      This patch is to reads out the relevant parameters from the head of the
      first mmap'ed page and stores into the structure 'perf_tsc_conversion',
      if the flag 'cap_user_time_short' has been set, it will firstly
      calibrate cycle value for timestamp calculation.
      
      Committer testing:
      
      Before/after:
      
        # perf test tsc
        70: Convert perf time to TSC                                        : Ok
        #
        # perf test -v tsc
        70: Convert perf time to TSC                                        :
        --- start ---
        test child forked, pid 11059
        mmap size 528384B
        1st event perf time 996384576521 tsc 3850532906613
        rdtsc          time 996384578455 tsc 3850532913950
        2nd event perf time 996384578845 tsc 3850532915428
        test child finished with 0
        ---- end ----
        Convert perf time to TSC: Ok
        #
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kemeng Shi <shikemeng@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Gasson <nick.gasson@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Remi Bernon <rbernon@codeweavers.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Steve Maclean <steve.maclean@microsoft.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zou Wei <zou_wei@huawei.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/20200914115311.2201-4-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      78a93d4c
    • L
      perf tsc: Move out common functions from x86 · 03fca3af
      Leo Yan 提交于
      Functions perf_read_tsc_conversion() and perf_event__synth_time_conv()
      should work as common functions rather than x86 specific, so move these
      two functions out from arch/x86 folder and place them into util/tsc.c.
      
      Since the function perf_event__synth_time_conv() will be linked in
      util/tsc.c, remove its weak version.
      
      Committer testing:
      
      Before/after:
      
        # perf test tsc
        70: Convert perf time to TSC                                        : Ok
        #
        # perf test -v tsc
        70: Convert perf time to TSC                                        :
        --- start ---
        test child forked, pid 8520
        mmap size 528384B
        1st event perf time 592110439891 tsc 2317172044331
        rdtsc          time 592110441915 tsc 2317172052010
        2nd event perf time 592110442336 tsc 2317172053605
        test child finished with 0
        ---- end ----
        Convert perf time to TSC: Ok
        #
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kemeng Shi <shikemeng@huawei.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Gasson <nick.gasson@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Remi Bernon <rbernon@codeweavers.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Steve Maclean <steve.maclean@microsoft.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zou Wei <zou_wei@huawei.com>
      Link: http://lore.kernel.org/lkml/20200914115311.2201-2-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      03fca3af
  6. 18 9月, 2020 11 次提交
    • M
      perf probe: Fall back to debuginfod query if debuginfo and source not found locally · 7cd5738d
      Masami Hiramatsu 提交于
      Since 'perf probe' heavily depends on debuginfo, debuginfod gives us
      many benefits on the 'perf probe' command on remote machine.
      
      Especially, this will be helpful for the embedded devices which will not
      have enough storage, or boot with a cross-build kernel whose source code
      is in the host machine.
      
      This will work as similar to commit c7a14fdc ("perf build-ids:
      Fall back to debuginfod query if debuginfo not found")
      
      Tested with:
      
        (host) $ cd PATH/TO/KBUILD/DIR/
        (host) $ debuginfod -F .
        ...
      
        (remote) # perf probe -L vfs_read
        Failed to find the path for the kernel: No such file or directory
          Error: Failed to show lines.
      
        (remote) # export DEBUGINFOD_URLS="http://$HOST_IP:8002/"
        (remote) # perf probe -L vfs_read
        <vfs_read@...>
              0  ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
                 {
              2         ssize_t ret;
      
                        if (!(file->f_mode & FMODE_READ))
                                return -EBADF;
              6         if (!(file->f_mode & FMODE_CAN_READ))
                                return -EINVAL;
              8         if (unlikely(!access_ok(buf, count)))
                                return -EFAULT;
      
             11         ret = rw_verify_area(READ, file, pos, count);
             12         if (ret)
                                return ret;
                        if (count > MAX_RW_COUNT)
        ...
      
        (remote) # perf probe -a "vfs_read count"
        Added new event:
          probe:vfs_read       (on vfs_read with count)
      
        (remote) # perf probe -l
          probe:vfs_read       (on vfs_read@ksrc/linux/fs/read_write.c with count)
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: NFrank Ch. Eigler <fche@redhat.com>
      Cc: Aaron Merey <amerey@redhat.com>
      Cc: Daniel Thompson <daniel.thompson@linaro.org>
      Link: http://lore.kernel.org/lkml/160041610083.912668.13659563860278615846.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7cd5738d
    • M
      perf probe: Fix to adjust symbol address with correct reloc_sym address · ac7a75d1
      Masami Hiramatsu 提交于
      'perf probe' uses ref_reloc_sym to adjust symbol offset address from
      debuginfo address or ref_reloc_sym based address, but that is misusing
      reloc_sym->addr and reloc_sym->unrelocated_addr.  If map is not
      relocated (map->reloc == 0), we can use reloc_sym->addr as unrelocated
      address instead of reloc_sym->unrelocated_addr.
      
      This usually does not happen. If we have a non-stripped ELF binary, we
      will use it for map and debuginfo, if not, we use only kallsyms without
      debuginfo. Thus, the map is always relocated (ELF and DWARF binary) or
      not relocated (kallsyms).
      
      However, if we allow the combination of debuginfo and kallsyms based map
      (like using debuginfod), we have to check the map->reloc and choose the
      collect address of reloc_sym.
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: NFrank Ch. Eigler <fche@redhat.com>
      Cc: Aaron Merey <amerey@redhat.com>
      Cc: Daniel Thompson <daniel.thompson@linaro.org>
      Link: http://lore.kernel.org/lkml/160041609047.912668.14314639291419159274.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ac7a75d1
    • I
      perf metricgroup: Fix uncore metric expressions · dcc81be0
      Ian Rogers 提交于
      A metric like DRAM_BW_Use has on SkylakeX events uncore_imc/cas_count_read/
      and uncore_imc/case_count_write/.
      
      These events open 6 events per socket with pmu names of
      uncore_imc_[0-5].
      
      The current metric setup code in find_evsel_group assumes one ID will
      map to 1 event to be recorded in metric_events.
      
      For events with multiple matches, the first event is recorded in
      metric_events (avoiding matching >1 event with the same name) and the
      evlist_used updated so that duplicate events aren't removed when the
      evlist has unused events removed.
      
      Before this change:
      
        $ /tmp/perf/perf stat -M DRAM_BW_Use -a -- sleep 1
      
         Performance counter stats for 'system wide':
      
                     41.14 MiB  uncore_imc/cas_count_read/
             1,002,614,251 ns   duration_time
      
               1.002614251 seconds time elapsed
      
      After this change:
      
        $ /tmp/perf/perf stat -M DRAM_BW_Use -a -- sleep 1
      
         Performance counter stats for 'system wide':
      
                    157.47 MiB  uncore_imc/cas_count_read/ #     0.00 DRAM_BW_Use
                    126.97 MiB  uncore_imc/cas_count_write/
             1,003,019,728 ns   duration_time
      
      Erroneous duplication introduced in:
      commit 2440689d ("perf metricgroup: Remove duped metric group events").
      
      Fixes: ded80bda ("perf expr: Migrate expr ids table to a hashmap").
      Reported-by: NJin Yao <yao.jin@linux.intel.com>
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200917201807.4090224-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dcc81be0
    • A
      perf intel-pt: Fix "context_switch event has no tid" error · 7d537a8d
      Adrian Hunter 提交于
      A context_switch event can have no tid because pids can be detached from
      a task while the task is still running (in do_exit()). Note this won't
      happen with per-task contexts because then tracing stops at
      perf_event_exit_task()
      
      If a task with no tid gets preempted, or a dying task gets preempted and
      its parent releases it, when it subsequently gets switched back in,
      Intel PT will not be able to determine what task is running and prints
      an error "context_switch event has no tid". However, it is not really an
      error because the task is in kernel space and the decoder can continue
      to decode successfully. Fix by changing the error to be only a logged
      message, and make allowance for tid == -1.
      
      Example:
      
        Using 5.9-rc4 with Preemptible Kernel (Low-Latency Desktop) e.g.
        $ uname -r
        5.9.0-rc4
        $ grep PREEMPT .config
        # CONFIG_PREEMPT_NONE is not set
        # CONFIG_PREEMPT_VOLUNTARY is not set
        CONFIG_PREEMPT=y
        CONFIG_PREEMPT_COUNT=y
        CONFIG_PREEMPTION=y
        CONFIG_PREEMPT_RCU=y
        CONFIG_PREEMPT_NOTIFIERS=y
        CONFIG_DRM_I915_PREEMPT_TIMEOUT=640
        CONFIG_DEBUG_PREEMPT=y
        # CONFIG_PREEMPT_TRACER is not set
        # CONFIG_PREEMPTIRQ_DELAY_TEST is not set
      
      Before:
      
        $ cat forkit.c
      
        #include <sys/types.h>
        #include <unistd.h>
        #include <sys/wait.h>
      
        int main()
        {
                pid_t child;
                int status = 0;
      
                child = fork();
                if (child == 0)
                        return 123;
                wait(&status);
                return 0;
        }
      
        $ gcc -o forkit forkit.c
        $ sudo ~/bin/perf record --kcore -a -m,64M -e intel_pt/cyc/k &
        [1] 11016
        $ taskset 2 ./forkit
        $ sudo pkill perf
        $ [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 17.262 MB perf.data ]
      
        [1]+  Terminated              sudo ~/bin/perf record --kcore -a -m,64M -e intel_pt/cyc/k
        $ sudo ~/bin/perf script --show-task-events --show-switch-events --itrace=iqqe-o -C 1 --ns | grep -C 2 forkit
        context_switch event has no tid
                 taskset 11019 [001] 66663.270045029:          1 instructions:k:  ffffffffb1d9f844 strnlen_user+0xb4 ([kernel.kallsyms])
                 taskset 11019 [001] 66663.270201816:          1 instructions:k:  ffffffffb1a83121 unmap_page_range+0x561 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.270327553: PERF_RECORD_COMM exec: forkit:11019/11019
                  forkit 11019 [001] 66663.270420028:          1 instructions:k:  ffffffffb1db9537 __clear_user+0x27 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.270648704:          1 instructions:k:  ffffffffb18829e6 do_user_addr_fault+0xf6 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.270833163:          1 instructions:k:  ffffffffb230a825 irqentry_exit_to_user_mode+0x15 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.271092359:          1 instructions:k:  ffffffffb1aea3d9 lock_page_memcg+0x9 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.271207092: PERF_RECORD_FORK(11020:11020):(11019:11019)
                  forkit 11019 [001] 66663.271234775: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid: 11020/11020
                  forkit 11020 [001] 66663.271238407: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 11019/11019
                  forkit 11020 [001] 66663.271312066:          1 instructions:k:  ffffffffb1a88140 handle_mm_fault+0x10 ([kernel.kallsyms])
                  forkit 11020 [001] 66663.271476225: PERF_RECORD_EXIT(11020:11020):(11019:11019)
                  forkit 11020 [001] 66663.271497488: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 11019/11019
                  forkit 11019 [001] 66663.271500523: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 11020/11020
                  forkit 11019 [001] 66663.271517241:          1 instructions:k:  ffffffffb24012cd error_entry+0x6d ([kernel.kallsyms])
                  forkit 11019 [001] 66663.271664080: PERF_RECORD_EXIT(11019:11019):(1386:1386)
      
      After:
      
        $ sudo ~/bin/perf script --show-task-events --show-switch-events --itrace=iqqe-o -C 1 --ns | grep -C 2 forkit
                 taskset 11019 [001] 66663.270045029:          1 instructions:k:  ffffffffb1d9f844 strnlen_user+0xb4 ([kernel.kallsyms])
                 taskset 11019 [001] 66663.270201816:          1 instructions:k:  ffffffffb1a83121 unmap_page_range+0x561 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.270327553: PERF_RECORD_COMM exec: forkit:11019/11019
                  forkit 11019 [001] 66663.270420028:          1 instructions:k:  ffffffffb1db9537 __clear_user+0x27 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.270648704:          1 instructions:k:  ffffffffb18829e6 do_user_addr_fault+0xf6 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.270833163:          1 instructions:k:  ffffffffb230a825 irqentry_exit_to_user_mode+0x15 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.271092359:          1 instructions:k:  ffffffffb1aea3d9 lock_page_memcg+0x9 ([kernel.kallsyms])
                  forkit 11019 [001] 66663.271207092: PERF_RECORD_FORK(11020:11020):(11019:11019)
                  forkit 11019 [001] 66663.271234775: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid: 11020/11020
                  forkit 11020 [001] 66663.271238407: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 11019/11019
                  forkit 11020 [001] 66663.271312066:          1 instructions:k:  ffffffffb1a88140 handle_mm_fault+0x10 ([kernel.kallsyms])
                  forkit 11020 [001] 66663.271476225: PERF_RECORD_EXIT(11020:11020):(11019:11019)
                  forkit 11020 [001] 66663.271497488: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 11019/11019
                  forkit 11019 [001] 66663.271500523: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 11020/11020
                  forkit 11019 [001] 66663.271517241:          1 instructions:k:  ffffffffb24012cd error_entry+0x6d ([kernel.kallsyms])
                  forkit 11019 [001] 66663.271664080: PERF_RECORD_EXIT(11019:11019):(1386:1386)
                  forkit 11019 [001] 66663.271688752: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:    -1/-1
                     :-1    -1 [001] 66663.271692086: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 11019/11019
                      :-1    -1 [001] 66663.271707466:          1 instructions:k:  ffffffffb18eb096 update_load_avg+0x306 ([kernel.kallsyms])
      
      Fixes: 86c27869 ("perf intel-pt: Add support for PERF_RECORD_SWITCH")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
      Link: http://lore.kernel.org/lkml/20200909084923.9096-3-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7d537a8d
    • A
      perf script: Display negative tid in non-sample events · fc18380f
      Adrian Hunter 提交于
      The kernel can release tasks while they are still running. This can
      result in a task having no tid, in which case perf records a tid of -1.
      Improve the perf script output in that case.
      
      Example:
      
      Before:
      
        # cat ./autoreap.c
      
        #include <sys/types.h>
        #include <unistd.h>
        #include <sys/wait.h>
        #include <signal.h>
      
        struct sigaction act = {
                .sa_handler = SIG_IGN,
        };
      
        int main()
        {
                pid_t child;
                int status = 0;
      
                sigaction(SIGCHLD, &act, NULL);
                child = fork();
                if (child == 0)
                        return 123;
                wait(&status);
                return 0;
        }
      
        # gcc -o autoreap autoreap.c
        # ./perf record -a -e dummy --switch-events ./autoreap
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.948 MB perf.data ]
        # ./perf script --show-task-events --show-switch-events | grep -C2 'autoreap\|4294967295\|-1'
                 swapper     0 [004] 18462.673613: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 25189/25189
                    perf 25189 [004] 18462.673614: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                autoreap 25189 [004] 18462.673800: PERF_RECORD_COMM exec: autoreap:25189/25189
                autoreap 25189 [004] 18462.674042: PERF_RECORD_FORK(25191:25191):(25189:25189)
                autoreap 25189 [004] 18462.674050: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                 swapper     0 [004] 18462.674051: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 25189/25189
                 swapper     0 [005] 18462.674083: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 25191/25191
                autoreap 25191 [005] 18462.674084: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                 swapper     0 [003] 18462.674121: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
             rcu_preempt    11 [003] 18462.674121: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
             rcu_preempt    11 [003] 18462.674124: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                 swapper     0 [003] 18462.674124: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    11/11
                autoreap 25191 [005] 18462.674138: PERF_RECORD_EXIT(25191:25191):(25189:25189)
        PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                 swapper     0 [005] 18462.674149: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 4294967295/4294967295
                 swapper     0 [004] 18462.674182: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 25189/25189
                autoreap 25189 [004] 18462.674183: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                autoreap 25189 [004] 18462.674218: PERF_RECORD_EXIT(25189:25189):(25188:25188)
                autoreap 25189 [004] 18462.674225: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                 swapper     0 [004] 18462.674226: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 25189/25189
                 swapper     0 [007] 18462.674257: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 25188/25188
      
      After:
      
        # ./perf script --show-task-events --show-switch-events | grep -C2 'autoreap\|4294967295\|-1'
                 swapper     0 [004] 18462.673613: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 25189/25189
                    perf 25189 [004] 18462.673614: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                autoreap 25189 [004] 18462.673800: PERF_RECORD_COMM exec: autoreap:25189/25189
                autoreap 25189 [004] 18462.674042: PERF_RECORD_FORK(25191:25191):(25189:25189)
                autoreap 25189 [004] 18462.674050: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                 swapper     0 [004] 18462.674051: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 25189/25189
                 swapper     0 [005] 18462.674083: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 25191/25191
                autoreap 25191 [005] 18462.674084: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                 swapper     0 [003] 18462.674121: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:    11/11
             rcu_preempt    11 [003] 18462.674121: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
             rcu_preempt    11 [003] 18462.674124: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                 swapper     0 [003] 18462.674124: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    11/11
                autoreap 25191 [005] 18462.674138: PERF_RECORD_EXIT(25191:25191):(25189:25189)
                     :-1    -1 [005] 18462.674149: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                 swapper     0 [005] 18462.674149: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:    -1/-1
                 swapper     0 [004] 18462.674182: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 25189/25189
                autoreap 25189 [004] 18462.674183: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
                autoreap 25189 [004] 18462.674218: PERF_RECORD_EXIT(25189:25189):(25188:25188)
                autoreap 25189 [004] 18462.674225: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
                 swapper     0 [004] 18462.674226: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid: 25189/25189
                 swapper     0 [007] 18462.674257: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid: 25188/25188
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
      Link: http://lore.kernel.org/lkml/20200909084923.9096-2-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fc18380f
    • A
      perf stat: Support new per thread TopDown metrics · 55c36a9f
      Andi Kleen 提交于
      Icelake has support for reporting per thread TopDown metrics.
      
      These are reported differently than the previous TopDown support,
      each metric is standalone, but scaled to pipeline "slots".
      
      We don't need to do anything special for HyperThreading anymore.
      Teach perf stat --topdown to handle these new metrics and
      print them in the same way as the previous TopDown metrics.
      
      The restrictions of only being able to report information per core is
      gone.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Co-developed-by: NKan Liang <kan.liang@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200911144808.27603-4-kan.liang@linux.intel.comSigned-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      55c36a9f
    • K
      perf record: Support sample-read topdown metric group · acb65150
      Kan Liang 提交于
      With the hardware TopDown metrics feature, sample-read feature should be
      supported for a topdown group, e.g., sample a non-topdown event and read
      a topdown metric group. But the current perf record code errors out.
      
      For a topdown metric group, the slots event must be the leader of the
      group, but the leader slots event doesn't support sampling.
      
      To support sample-read the topdown metric group, use the 2nd event of
      the group as the "leader" for the purposes of sampling.
      
      Only the platform with Topdown metic feature supports sample-read the
      topdown group. Add arch_topdown_sample_read() to indicate whether the
      topdown group supports sample-read.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200911144808.27603-3-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      acb65150
    • K
      perf tools: Rename group to topdown · 687986bb
      Kan Liang 提交于
      The group.h/c only include TopDown group related functions. The name
      "group" is too generic and inaccurate. Use the name "topdown" to replace
      it.
      
      Move topdown related functions to a dedicated file, topdown.c.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200911144808.27603-2-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      687986bb
    • J
      perf machine: Add machine__for_each_dso() function · c57f5eaa
      Jiri Olsa 提交于
      Add the machine__for_each_dso() to iterate over all dso objects defined
      for the within a machine object. It will be used in the MMAP3 patch
      series.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Frank Ch. Eigler <fche@redhat.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: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200913210313.1985612-22-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c57f5eaa
    • N
      perf parse-event: Release cpu_map refcount if evsel alloc failed · 0f1b550e
      Namhyung Kim 提交于
      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>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200917060219.1287863-1-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0f1b550e
    • N
      perf parse-event: Fix cpu map refcounting · 5d680be3
      Namhyung Kim 提交于
      Like evlist cpu map, evsel's cpu map should have a proper refcount.
      
      As it's created with a refcount, we don't need to get an extra count.
      Thanks to Arnaldo for the simpler suggestion.
      
      This, together with the following patch, fixes the following ASAN
      report:
      
        Direct leak of 840 byte(s) in 70 object(s) allocated from:
          #0 0x7fe36703f628 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x107628)
          #1 0x559fbbf611ca in cpu_map__trim_new /home/namhyung/project/linux/tools/lib/perf/cpumap.c:79
          #2 0x559fbbf6229c in perf_cpu_map__new /home/namhyung/project/linux/tools/lib/perf/cpumap.c:237
          #3 0x559fbbcc6c6d in __add_event util/parse-events.c:357
          #4 0x559fbbcc6c6d in add_event_tool util/parse-events.c:408
          #5 0x559fbbcc6c6d in parse_events_add_tool util/parse-events.c:1414
          #6 0x559fbbd8474d in parse_events_parse util/parse-events.y:439
          #7 0x559fbbcc95da in parse_events__scanner util/parse-events.c:2096
          #8 0x559fbbcc95da in __parse_events util/parse-events.c:2141
          #9 0x559fbbc2788b in check_parse_id tests/pmu-events.c:406
          #10 0x559fbbc2788b in check_parse_id tests/pmu-events.c:393
          #11 0x559fbbc2788b in check_parse_fake tests/pmu-events.c:436
          #12 0x559fbbc2788b in metric_parse_fake tests/pmu-events.c:553
          #13 0x559fbbc27e2d in test_parsing_fake tests/pmu-events.c:599
          #14 0x559fbbc27e2d in test_parsing_fake tests/pmu-events.c:574
          #15 0x559fbbc0109b in run_test tests/builtin-test.c:410
          #16 0x559fbbc0109b in test_and_print tests/builtin-test.c:440
          #17 0x559fbbc03e69 in __cmd_test tests/builtin-test.c:695
          #18 0x559fbbc03e69 in cmd_test tests/builtin-test.c:807
          #19 0x559fbbc691f4 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:312
          #20 0x559fbbb071a8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:364
          #21 0x559fbbb071a8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:408
          #22 0x559fbbb071a8 in main /home/namhyung/project/linux/tools/perf/perf.c:538
          #23 0x7fe366b68cc9 in __libc_start_main ../csu/libc-start.c:308
      
      And I've failed which commit introduced this bug as the code was
      heavily changed since then. ;-/
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200917060219.1287863-2-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5d680be3
  7. 16 9月, 2020 1 次提交
  8. 15 9月, 2020 11 次提交
    • N
      perf test: Free formats for perf pmu parse test · d26383dc
      Namhyung Kim 提交于
      The following leaks were detected by ASAN:
      
        Indirect leak of 360 byte(s) in 9 object(s) allocated from:
          #0 0x7fecc305180e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10780e)
          #1 0x560578f6dce5 in perf_pmu__new_format util/pmu.c:1333
          #2 0x560578f752fc in perf_pmu_parse util/pmu.y:59
          #3 0x560578f6a8b7 in perf_pmu__format_parse util/pmu.c:73
          #4 0x560578e07045 in test__pmu tests/pmu.c:155
          #5 0x560578de109b in run_test tests/builtin-test.c:410
          #6 0x560578de109b in test_and_print tests/builtin-test.c:440
          #7 0x560578de401a in __cmd_test tests/builtin-test.c:661
          #8 0x560578de401a in cmd_test tests/builtin-test.c:807
          #9 0x560578e49354 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:312
          #10 0x560578ce71a8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:364
          #11 0x560578ce71a8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:408
          #12 0x560578ce71a8 in main /home/namhyung/project/linux/tools/perf/perf.c:538
          #13 0x7fecc2b7acc9 in __libc_start_main ../csu/libc-start.c:308
      
      Fixes: cff7f956 ("perf tests: Move pmu tests into separate object")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-12-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d26383dc
    • N
      perf metric: Do not free metric when failed to resolve · 6f47ed6c
      Namhyung Kim 提交于
      It's dangerous to free the original metric when it's called from
      resolve_metric() as it's already in the metric_list and might have other
      resources too.  Instead, it'd better let them bail out and be released
      properly at the later stage.
      
      So add a check when it's called from metricgroup__add_metric() and
      release it.  Also make sure that mp is set properly.
      
      Fixes: 83de0b7d ("perf metric: Collect referenced metrics in struct metric_ref_node")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-10-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6f47ed6c
    • N
      perf metric: Free metric when it failed to resolve · 27adafcd
      Namhyung Kim 提交于
      The metricgroup__add_metric() can find multiple match for a metric group
      and it's possible to fail.  Also it can fail in the middle like in
      resolve_metric() even for single metric.
      
      In those cases, the intermediate list and ids will be leaked like:
      
        Direct leak of 3 byte(s) in 1 object(s) allocated from:
          #0 0x7f4c938f40b5 in strdup (/lib/x86_64-linux-gnu/libasan.so.5+0x920b5)
          #1 0x55f7e71c1bef in __add_metric util/metricgroup.c:683
          #2 0x55f7e71c31d0 in add_metric util/metricgroup.c:906
          #3 0x55f7e71c3844 in metricgroup__add_metric util/metricgroup.c:940
          #4 0x55f7e71c488d in metricgroup__add_metric_list util/metricgroup.c:993
          #5 0x55f7e71c488d in parse_groups util/metricgroup.c:1045
          #6 0x55f7e71c60a4 in metricgroup__parse_groups_test util/metricgroup.c:1087
          #7 0x55f7e71235ae in __compute_metric tests/parse-metric.c:164
          #8 0x55f7e7124650 in compute_metric tests/parse-metric.c:196
          #9 0x55f7e7124650 in test_recursion_fail tests/parse-metric.c:318
          #10 0x55f7e7124650 in test__parse_metric tests/parse-metric.c:356
          #11 0x55f7e70be09b in run_test tests/builtin-test.c:410
          #12 0x55f7e70be09b in test_and_print tests/builtin-test.c:440
          #13 0x55f7e70c101a in __cmd_test tests/builtin-test.c:661
          #14 0x55f7e70c101a in cmd_test tests/builtin-test.c:807
          #15 0x55f7e7126214 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:312
          #16 0x55f7e6fc41a8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:364
          #17 0x55f7e6fc41a8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:408
          #18 0x55f7e6fc41a8 in main /home/namhyung/project/linux/tools/perf/perf.c:538
          #19 0x7f4c93492cc9 in __libc_start_main ../csu/libc-start.c:308
      
      Fixes: 83de0b7d ("perf metric: Collect referenced metrics in struct metric_ref_node")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-9-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      27adafcd
    • N
      perf metric: Release expr_parse_ctx after testing · 437822bf
      Namhyung Kim 提交于
      The test_generic_metric() missed to release entries in the pctx.  Asan
      reported following leak (and more):
      
        Direct leak of 128 byte(s) in 1 object(s) allocated from:
          #0 0x7f4c9396980e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10780e)
          #1 0x55f7e748cc14 in hashmap_grow (/home/namhyung/project/linux/tools/perf/perf+0x90cc14)
          #2 0x55f7e748d497 in hashmap__insert (/home/namhyung/project/linux/tools/perf/perf+0x90d497)
          #3 0x55f7e7341667 in hashmap__set /home/namhyung/project/linux/tools/perf/util/hashmap.h:111
          #4 0x55f7e7341667 in expr__add_ref util/expr.c:120
          #5 0x55f7e7292436 in prepare_metric util/stat-shadow.c:783
          #6 0x55f7e729556d in test_generic_metric util/stat-shadow.c:858
          #7 0x55f7e712390b in compute_single tests/parse-metric.c:128
          #8 0x55f7e712390b in __compute_metric tests/parse-metric.c:180
          #9 0x55f7e712446d in compute_metric tests/parse-metric.c:196
          #10 0x55f7e712446d in test_dcache_l2 tests/parse-metric.c:295
          #11 0x55f7e712446d in test__parse_metric tests/parse-metric.c:355
          #12 0x55f7e70be09b in run_test tests/builtin-test.c:410
          #13 0x55f7e70be09b in test_and_print tests/builtin-test.c:440
          #14 0x55f7e70c101a in __cmd_test tests/builtin-test.c:661
          #15 0x55f7e70c101a in cmd_test tests/builtin-test.c:807
          #16 0x55f7e7126214 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:312
          #17 0x55f7e6fc41a8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:364
          #18 0x55f7e6fc41a8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:408
          #19 0x55f7e6fc41a8 in main /home/namhyung/project/linux/tools/perf/perf.c:538
          #20 0x7f4c93492cc9 in __libc_start_main ../csu/libc-start.c:308
      
      Fixes: 6d432c4c ("perf tools: Add test_generic_metric function")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-8-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      437822bf
    • N
      perf parse-event: Fix memory leak in evsel->unit · b12eea5a
      Namhyung Kim 提交于
      The evsel->unit borrows a pointer of pmu event or alias instead of
      owns a string.  But tool event (duration_time) passes a result of
      strdup() caused a leak.
      
      It was found by ASAN during metric test:
      
        Direct leak of 210 byte(s) in 70 object(s) allocated from:
          #0 0x7fe366fca0b5 in strdup (/lib/x86_64-linux-gnu/libasan.so.5+0x920b5)
          #1 0x559fbbcc6ea3 in add_event_tool util/parse-events.c:414
          #2 0x559fbbcc6ea3 in parse_events_add_tool util/parse-events.c:1414
          #3 0x559fbbd8474d in parse_events_parse util/parse-events.y:439
          #4 0x559fbbcc95da in parse_events__scanner util/parse-events.c:2096
          #5 0x559fbbcc95da in __parse_events util/parse-events.c:2141
          #6 0x559fbbc28555 in check_parse_id tests/pmu-events.c:406
          #7 0x559fbbc28555 in check_parse_id tests/pmu-events.c:393
          #8 0x559fbbc28555 in check_parse_cpu tests/pmu-events.c:415
          #9 0x559fbbc28555 in test_parsing tests/pmu-events.c:498
          #10 0x559fbbc0109b in run_test tests/builtin-test.c:410
          #11 0x559fbbc0109b in test_and_print tests/builtin-test.c:440
          #12 0x559fbbc03e69 in __cmd_test tests/builtin-test.c:695
          #13 0x559fbbc03e69 in cmd_test tests/builtin-test.c:807
          #14 0x559fbbc691f4 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:312
          #15 0x559fbbb071a8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:364
          #16 0x559fbbb071a8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:408
          #17 0x559fbbb071a8 in main /home/namhyung/project/linux/tools/perf/perf.c:538
          #18 0x7fe366b68cc9 in __libc_start_main ../csu/libc-start.c:308
      
      Fixes: f0fbb114 ("perf stat: Implement duration_time as a proper event")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-6-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b12eea5a
    • N
      perf evlist: Fix cpu/thread map leak · bfd1b83d
      Namhyung Kim 提交于
      Asan reported leak of cpu and thread maps as they have one more refcount
      than released.  I found that after setting evlist maps it should release
      it's refcount.
      
      It seems to be broken from the beginning so I chose the original commit
      as the culprit.  But not sure how it's applied to stable trees since
      there are many changes in the code after that.
      
      Fixes: 7e2ed097 ("perf evlist: Store pointer to the cpu and thread maps")
      Fixes: 4112eb18 ("perf evlist: Default to syswide target when no thread/cpu maps set")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-4-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bfd1b83d
    • N
      perf metric: Fix some memory leaks - part 2 · b033ab11
      Namhyung Kim 提交于
      The metric_event_delete() missed to free expr->metric_events and it
      should free an expr when metric_refs allocation failed.
      
      Fixes: 4ea28967 ("perf metric: Collect referenced metrics in struct metric_expr")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-3-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b033ab11
    • N
      perf metric: Fix some memory leaks · 4f57a1ed
      Namhyung Kim 提交于
      I found some memory leaks while reading the metric code.  Some are real
      and others only occur in the error path.  When it failed during metric
      or event parsing, it should release all resources properly.
      
      Fixes: b18f3e36 ("perf stat: Support JSON metrics in perf stat")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-2-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4f57a1ed
    • N
      perf test: Free aliases for PMU event map aliases test · 22fe5a25
      Namhyung Kim 提交于
      The aliases were never released causing the following leaks:
      
        Indirect leak of 1224 byte(s) in 9 object(s) allocated from:
          #0 0x7feefb830628 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x107628)
          #1 0x56332c8f1b62 in __perf_pmu__new_alias util/pmu.c:322
          #2 0x56332c8f401f in pmu_add_cpu_aliases_map util/pmu.c:778
          #3 0x56332c792ce9 in __test__pmu_event_aliases tests/pmu-events.c:295
          #4 0x56332c792ce9 in test_aliases tests/pmu-events.c:367
          #5 0x56332c76a09b in run_test tests/builtin-test.c:410
          #6 0x56332c76a09b in test_and_print tests/builtin-test.c:440
          #7 0x56332c76ce69 in __cmd_test tests/builtin-test.c:695
          #8 0x56332c76ce69 in cmd_test tests/builtin-test.c:807
          #9 0x56332c7d2214 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:312
          #10 0x56332c6701a8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:364
          #11 0x56332c6701a8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:408
          #12 0x56332c6701a8 in main /home/namhyung/project/linux/tools/perf/perf.c:538
          #13 0x7feefb359cc9 in __libc_start_main ../csu/libc-start.c:308
      
      Fixes: 956a7835 ("perf test: Test pmu-events aliases")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Reviewed-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-11-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      22fe5a25
    • I
      perf record: Don't clear event's period if set by a term · 3b0a18c1
      Ian Rogers 提交于
      If events in a group explicitly set a frequency or period with leader
      sampling, don't disable the samples on those events.
      
      Prior to 5.8:
      
        perf record -e '{cycles/period=12345000/,instructions/period=6789000/}:S'
      
      would clear the attributes then apply the config terms. In commit
      5f342788 leader sampling configuration was moved to after applying the
      config terms, in the example, making the instructions' event have its period
      cleared.
      
      This change makes it so that sampling is only disabled if configuration
      terms aren't present.
      
      Committer testing:
      
      Before:
      
        # perf record -e '{cycles/period=1/,instructions/period=2/}:S' sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.051 MB perf.data (6 samples) ]
        #
        # perf evlist -v
        cycles/period=1/: size: 120, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|READ|ID, read_format: ID|GROUP, disabled: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
        instructions/period=2/: size: 120, config: 0x1, sample_type: IP|TID|TIME|READ|ID, read_format: ID|GROUP, sample_id_all: 1, exclude_guest: 1
        #
      
      After:
      
        # perf record -e '{cycles/period=1/,instructions/period=2/}:S' sleep 0.0001
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.052 MB perf.data (4 samples) ]
        # perf evlist -v
        cycles/period=1/: size: 120, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|READ|ID, read_format: ID|GROUP, disabled: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
        instructions/period=2/: size: 120, config: 0x1, { sample_period, sample_freq }: 2, sample_type: IP|TID|TIME|READ|ID, read_format: ID|GROUP, sample_id_all: 1, exclude_guest: 1
        #
      
      Fixes: 5f342788 ("perf evlist: Move leader-sampling configuration")
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: http://lore.kernel.org/lkml/20200912025655.1337192-4-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3b0a18c1
    • S
      perf record: Prevent override of attr->sample_period for libpfm4 events · ae5dcc8a
      Stephane Eranian 提交于
      Before:
      
        $ perf record -c 10000 --pfm-events=cycles:period=77777
      
      Would yield a cycles event with period=10000, instead of 77777.
      
      the event string and perf record initializing the event.
      This was due to an ordering issue between libpfm4 parsing
      
      events with attr->sample_period != 0 by the time
      intent of the author.
      perf_evsel__config() is invoked. This seems to have been the
      This patch fixes the problem by preventing override for
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: http://lore.kernel.org/lkml/20200912025655.1337192-3-irogers@google.comSigned-off-by: NIan Rogers <irogers@google.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ae5dcc8a