1. 23 9月, 2020 4 次提交
    • 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: Add rdtsc() for Arm64 · 4979e861
      Leo Yan 提交于
      The system register CNTVCT_EL0 can be used to retrieve the counter from
      user space.  Add rdtsc() for Arm64.
      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-3-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4979e861
    • 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
  2. 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
    • 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
    • Z
      perf docs: Improve help information in perf.txt · 99f63817
      Zejiang Tang 提交于
      perf has many undocumented options, such as:-vv, --exec-path,
      --html-path, -p, --paginate,--no-pager, --debugfs-dir, --buildid-dir,
      --list-cmds, --list-opts.
      
      Add entris for these options in perf.txt.
      Signed-off-by: NZejiang Tang <tangzejiang@loongson.cn>
      Acked-by: NNamhyung 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: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/1599645194-8438-1-git-send-email-tangzejiang@loongson.cnSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      99f63817
    • Y
      perf metric: Remove duplicate include · a803fbe6
      YueHaibing 提交于
      Remove duplicate header which is included twice.
      Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200915081541.41004-1-yuehaibing@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a803fbe6
    • A
      perf tools: Add documentation for topdown metrics · 328781df
      Andi Kleen 提交于
      Add some documentation how to use the topdown metrics in ring 3.
      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-5-kan.liang@linux.intel.comSigned-off-by: NKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      328781df
    • 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
  3. 16 9月, 2020 1 次提交
  4. 15 9月, 2020 17 次提交
    • 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 test: Fix memory leaks in parse-metric test · f5a56570
      Namhyung Kim 提交于
      It didn't release resources when there's an error so the
      test_recursion_fail() will leak some memory.
      
      Fixes: 0a507af9 ("perf tests: Add parse metric test for ipc metric")
      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-7-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f5a56570
    • 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
    • H
      perf vendor events amd: Remove trailing commas · 56f3a1cd
      Henry Burns 提交于
      The amdzen2/core.json and amdzen/core.json vendor events files have the
      occasional trailing comma. Since that goes against the JSON standard,
      lets remove it.
      Signed-off-by: NHenry Burns <henrywolfeburns@gmail.com>
      Acked-by: NKim Phillips <kim.phillips@amd.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Vijay Thakkar <vijaythakkar@me.com>
      Link: http://lore.kernel.org/lkml/20200915004125.971-1-henrywolfeburns@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      56f3a1cd
    • I
      perf test: Leader sampling shouldn't clear sample period · 880a7843
      Ian Rogers 提交于
      Add test that a sibling with leader sampling doesn't have its period
      cleared.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.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: 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/20200912025655.1337192-5-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      880a7843
    • 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
    • D
      perf record: Set PERF_RECORD_PERIOD if attr->freq is set. · ce4326d2
      David Sharp 提交于
      evsel__config() would only set PERF_RECORD_PERIOD if it set attr->freq
      from perf record options. When it is set by libpfm events, it would not
      get set. This changes evsel__config to see if attr->freq is set outside
      of whether or not it changes attr->freq itself.
      Signed-off-by: NDavid Sharp <dhsharp@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: Ian Rogers <irogers@google.com>
      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: david sharp <dhsharp@google.com>
      Link: http://lore.kernel.org/lkml/20200912025655.1337192-2-irogers@google.comSigned-off-by: NIan Rogers <irogers@google.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ce4326d2
    • I
      perf bench: Fix 2 memory sanitizer warnings · d2c73501
      Ian Rogers 提交于
      Memory sanitizer warns if a write is performed where the memory being
      read for the write is uninitialized. Avoid this warning by initializing
      the memory.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.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/20200912053725.1405857-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d2c73501
    • J
      perf test: Fix the "signal" test inline assembly · 8a39e8c4
      Jiri Olsa 提交于
      When compiling with DEBUG=1 on Fedora 32 I'm getting crash for 'perf
      test signal':
      
        Program received signal SIGSEGV, Segmentation fault.
        0x0000000000c68548 in __test_function ()
        (gdb) bt
        #0  0x0000000000c68548 in __test_function ()
        #1  0x00000000004d62e9 in test_function () at tests/bp_signal.c:61
        #2  0x00000000004d689a in test__bp_signal (test=0xa8e280 <generic_ ...
        #3  0x00000000004b7d49 in run_test (test=0xa8e280 <generic_tests+1 ...
        #4  0x00000000004b7e7f in test_and_print (t=0xa8e280 <generic_test ...
        #5  0x00000000004b8927 in __cmd_test (argc=1, argv=0x7fffffffdce0, ...
        ...
      
      It's caused by the symbol __test_function being in the ".bss" section:
      
        $ readelf -a ./perf | less
          [Nr] Name              Type             Address           Offset
               Size              EntSize          Flags  Link  Info  Align
          ...
          [28] .bss              NOBITS           0000000000c356a0  008346a0
               00000000000511f8  0000000000000000  WA       0     0     32
      
        $ nm perf | grep __test_function
        0000000000c68548 B __test_function
      
      I guess most of the time we're just lucky the inline asm ended up in the
      ".text" section, so making it specific explicit with push and pop
      section clauses.
      
        $ readelf -a ./perf | less
          [Nr] Name              Type             Address           Offset
               Size              EntSize          Flags  Link  Info  Align
          ...
          [13] .text             PROGBITS         0000000000431240  00031240
               0000000000306faa  0000000000000000  AX       0     0     16
      
        $ nm perf | grep __test_function
        00000000004d62c8 T __test_function
      
      Committer testing:
      
        $ readelf -wi ~/bin/perf | grep producer -m1
          <c>   DW_AT_producer    : (indirect string, offset: 0x254a): GNU C99 10.2.1 20200723 (Red Hat 10.2.1-1) -mtune=generic -march=x86-64 -ggdb3 -std=gnu99 -fno-omit-frame-pointer -funwind-tables -fstack-protector-all
                                                                                                                                               ^^^^^
                                                                                                                                               ^^^^^
                                                                                                                                               ^^^^^
        $
      
      Before:
      
        $ perf test signal
        20: Breakpoint overflow signal handler                    : FAILED!
        $
      
      After:
      
        $ perf test signal
        20: Breakpoint overflow signal handler                    : Ok
        $
      
      Fixes: 8fd34e1c ("perf test: Improve bp_signal")
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lore.kernel.org/lkml/20200911130005.1842138-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8a39e8c4
  5. 10 9月, 2020 7 次提交
    • J
      perf tests: Call test_attr__open() directly · 8366f0d2
      Jiri Olsa 提交于
      There's no longer need to call test_attr__open() from
      sys_perf_event_open(), because both 'perf record' and 'perf stat' call
      evsel__open_cpu(), so we can call it directly from there and not polute
      the perf-sys.h header.
      
      Committer testing:
      
      Before and after:
      
        # perf test attr
        17: Setup struct perf_event_attr                                    : Ok
        49: Synthesize attr update                                          : Ok
        # perf test -v attr
        17: Setup struct perf_event_attr                                    :
        --- start ---
        test child forked, pid 2170868
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any_ret'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any_ret'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-C0'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-graph-fp'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-period'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-group-sampling'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-freq'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-detailed-3'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-k'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-k'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-group1'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-u'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-u'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-basic'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any_call'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any_call'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-default'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-graph-dwarf'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-no-buffering'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-raw'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-detailed-2'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-count'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-data'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-any'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-group'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-any'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-any'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-graph-default'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-no-samples'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-C0'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-no-inherit'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-ind_call'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-ind_call'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-basic'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-group1'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-pfm-period'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-pfm-period'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-detailed-1'
        running '/home/acme/libexec/perf-core/tests/attr/test-stat-no-inherit'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-hv'
        unsupp  '/home/acme/libexec/perf-core/tests/attr/test-record-branch-filter-hv'
        running '/home/acme/libexec/perf-core/tests/attr/test-record-group'
        test child finished with 0
        ---- end ----
        Setup struct perf_event_attr: Ok
        49: Synthesize attr update                                          :
        --- start ---
        test child forked, pid 2171004
        test child finished with 0
        ---- end ----
        Synthesize attr update: Ok
        #
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200827193201.GB127372@kravaSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8366f0d2
    • K
      perf vendor events power9: Add hv_24x7 core level metric events · b1f815c4
      Kajol Jain 提交于
      This patch adds hv_24x7 core level events in nest_metric.json file and
      also add PerChip/PerCore field in metric events.
      
      Result:
      
      power9 platform:
      
      command:# ./perf stat --metric-only -M PowerBUS_Frequency -C 0 -I 1000
           1.000070601                        1.9                        2.0
           2.000253881                        2.0                        1.9
           3.000364810                        2.0                        2.0
      Signed-off-by: NKajol Jain <kjain@linux.ibm.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20200907064133.75090-6-kjain@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b1f815c4
    • K
      perf metricgroup: Pass pmu_event structure as a parameter for arch_get_runtimeparam() · f5a489dc
      Kajol Jain 提交于
      This patch adds passing of  pmu_event as a parameter in function
      'arch_get_runtimeparam' which can be used to get details like if the
      event is percore/perchip.
      Signed-off-by: NKajol Jain <kjain@linux.ibm.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20200907064133.75090-5-kjain@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f5a489dc
    • K
      perf jevents: Add support for parsing perchip/percore events · 560ccbc4
      Kajol Jain 提交于
      Initially, every time we want to add new terms like chip, core thread etc,
      we need to create corrsponding fields in pmu_events and event struct.
      
      This patch adds an enum called 'aggr_mode_class' which store all these
      aggregation like perchip/percore. It also adds new field 'aggr_mode'
      to capture these terms.
      
      Now, if user wants to add any new term, they just need to add it in
      the enum defined.
      Signed-off-by: NKajol Jain <kjain@linux.ibm.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: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20200907064133.75090-4-kjain@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      560ccbc4
    • K
      perf jevents: Add new structure to pass json fields. · 71a374bb
      Kajol Jain 提交于
      This patch adds new structure called 'json_event' inside jevents.c
      file to improve the callback prototype inside jevent files.
      
      Initially, whenever user want to add new field, they need to update
      in all function callback which make it more and more complex with
      increased number of parmeters.
      
      With this change, we just need to add it in new structure 'json_event'.
      Signed-off-by: NKajol Jain <kjain@linux.ibm.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Reviewed-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20200907064133.75090-3-kjain@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      71a374bb
    • K
      perf jevents: Make json_events() static and ditch jevents.h file · 0d52b788
      Kajol Jain 提交于
      This patch removes jevents.h and makes json_events function static.
      Signed-off-by: NKajol Jain <kjain@linux.ibm.com>
      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: Jin Yao <yao.jin@linux.intel.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20200907064133.75090-2-kjain@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0d52b788
    • L
      perf test: Introduce script for Arm CoreSight testing · fe0aed19
      Leo Yan 提交于
      We need a simple method to test Perf with ARM CoreSight drivers, this
      could be used for smoke testing when new patch is coming for perf or
      CoreSight drivers, and we also can use the test to confirm if the
      CoreSight has been enabled successfully on new platforms.
      
      This patch introduces the shell script test_arm_coresight.sh which is
      under the 'pert test' framework.  This script provides three testing
      scenarios:
      
      Test scenario 1: traverse all possible paths between source and sink
      
      For traversing possible paths, simply to say, the testing rationale is
      source oriented testing, it traverses every source (now only refers to
      ETM device) and test its all possible sinks.  To search the complete
      paths from one specific source to its sinks, this patch relies on the
      sysfs '/sys/bus/coresight/devices/devX/out:Y' for depth-first search
      (DFS) for iteration connected device nodes, if the output device is
      detected as a sink device (the script will exclude TPIU device which can
      not be supported for perf PMU), then it will test trace data recording
      and decoding for it.
      
      The script runs three output testings for every trace data:
      
      - Test branch samples dumping with 'perf script' command;
      
      - Test branch samples reporting with 'perf report' command;
      
      - Use option '--itrace=i1000i' to insert synthesized instructions events
        and the script will check if perf can output the percentage value
        successfully based on the instruction samples.
      
      Test scenario 2: system-wide test
      
      For system-wide testing, it passes option '-a' to perf tool to enable
      tracing on all CPUs, so it's hard to say which program will be traced.
      But perf tool itself contributes much overload in this case, so it will
      parse trace data and check if process 'perf' can be detected or not.
      
      Test scenario 3: snapshot mode test.
      
      For snapshot mode testing, it uses 'dd' command to launch a long running
      program, so this can give chance to send signal -USR2; it will check the
      captured trace data contains 'dd' related thread info or not.
      
      If any test fails, it will report failure and directly exit with error.
      This test will be only applied on a platform with PMU event 'cs_etm//',
      otherwise will skip the testing.
      
      Below is detailed usage for it:
      
        # cd $linux/tools/perf  -> This is important so can use shell script
        # perf test list
          [...]
          70: probe libc's inet_pton & backtrace it with ping
          71: Check Arm CoreSight trace data recording and synthesized samples
          72: Check open filename arg using perf trace + vfs_getname
          73: Zstd perf.data compression/decompression
          74: Add vfs_getname probe to get syscall args filenames
          75: Use vfs_getname probe to get syscall args filenames
      
        # perf test 71
          71: Check Arm CoreSight trace data recording and branch samples: Ok
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: NSuzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200907130154.9601-1-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fe0aed19