1. 18 Sep, 2020 2 commits
    • Masami Hiramatsu's avatar
      perf probe: Fall back to debuginfod query if debuginfo and source not found locally · 7cd5738d
      Masami Hiramatsu authored
      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: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarFrank 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7cd5738d
    • Masami Hiramatsu's avatar
      perf probe: Fix to adjust symbol address with correct reloc_sym address · ac7a75d1
      Masami Hiramatsu authored
      '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: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarFrank 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ac7a75d1
  2. 17 Sep, 2020 10 commits
    • Adrian Hunter's avatar
      perf intel-pt: Fix "context_switch event has no tid" error · 7d537a8d
      Adrian Hunter authored
      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: default avatarAdrian 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7d537a8d
    • Adrian Hunter's avatar
      perf script: Display negative tid in non-sample events · fc18380f
      Adrian Hunter authored
      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: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fc18380f
    • Zejiang Tang's avatar
      perf docs: Improve help information in perf.txt · 99f63817
      Zejiang Tang authored
      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: default avatarZejiang Tang <tangzejiang@loongson.cn>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/1599645194-8438-1-git-send-email-tangzejiang@loongson.cnSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      99f63817
    • YueHaibing's avatar
      perf metric: Remove duplicate include · a803fbe6
      YueHaibing authored
      Remove duplicate header which is included twice.
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Acked-by: default avatarNamhyung 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a803fbe6
    • Andi Kleen's avatar
      perf tools: Add documentation for topdown metrics · 328781df
      Andi Kleen authored
      Add some documentation how to use the topdown metrics in ring 3.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Co-developed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: 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: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      328781df
    • Andi Kleen's avatar
      perf stat: Support new per thread TopDown metrics · 55c36a9f
      Andi Kleen authored
      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: default avatarAndi Kleen <ak@linux.intel.com>
      Co-developed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: 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: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      55c36a9f
    • Kan Liang's avatar
      perf record: Support sample-read topdown metric group · acb65150
      Kan Liang authored
      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: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      acb65150
    • Kan Liang's avatar
      perf tools: Rename group to topdown · 687986bb
      Kan Liang authored
      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: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      687986bb
    • Jiri Olsa's avatar
      perf machine: Add machine__for_each_dso() function · c57f5eaa
      Jiri Olsa authored
      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: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c57f5eaa
    • Arnaldo Carvalho de Melo's avatar
      056c1722
  3. 16 Sep, 2020 4 commits
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.9-2020-09-16' of... · 5925fa68
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.9-2020-09-16' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Set PERF_SAMPLE_PERIOD if attr->freq is set.
      
       - Remove trailing commas from AMD JSON vendor event files.
      
       - Don't clear event's period if set by a event definition term.
      
       - Leader sampling shouldn't clear sample period in 'perf test'.
      
       - Fix the "signal" test inline assembly when built with DEBUG=1.
      
       - Fix memory leaks detected by ASAN, some in normal paths, some in
         error paths.
      
       - Fix 2 memory sanitizer warnings in 'perf bench'.
      
       - Fix the ratio comments of miss-events in 'perf stat'.
      
       - Prevent override of attr->sample_period for libpfm4 events.
      
       - Sync kvm.h and in.h headers with the kernel sources.
      
      * tag 'perf-tools-fixes-for-v5.9-2020-09-16' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf stat: Fix the ratio comments of miss-events
        perf test: Free formats for perf pmu parse test
        perf metric: Do not free metric when failed to resolve
        perf metric: Free metric when it failed to resolve
        perf metric: Release expr_parse_ctx after testing
        perf test: Fix memory leaks in parse-metric test
        perf parse-event: Fix memory leak in evsel->unit
        perf evlist: Fix cpu/thread map leak
        perf metric: Fix some memory leaks - part 2
        perf metric: Fix some memory leaks
        perf test: Free aliases for PMU event map aliases test
        perf vendor events amd: Remove trailing commas
        perf test: Leader sampling shouldn't clear sample period
        perf record: Don't clear event's period if set by a term
        tools headers UAPI: update linux/in.h copy
        tools headers UAPI: Sync kvm.h headers with the kernel sources
        perf record: Prevent override of attr->sample_period for libpfm4 events
        perf record: Set PERF_RECORD_PERIOD if attr->freq is set.
        perf bench: Fix 2 memory sanitizer warnings
        perf test: Fix the "signal" test inline assembly
      5925fa68
    • Linus Torvalds's avatar
      Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · 05da40eb
      Linus Torvalds authored
      Pull clk driver fixes from Stephen Boyd:
       "A handful of clk driver fixes. Mostly they're for error paths or
        improper memory allocations sizes. Nothing as exciting as a wildfire"
      
      * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
        clk: qcom: lpass: Correct goto target in lpass_core_sc7180_probe()
        clk: versatile: Add of_node_put() before return statement
        clk: bcm: dvp: Select the reset framework
        clk: rockchip: Fix initialization of mux_pll_src_4plls_p
        clk: davinci: Use the correct size when allocating memory
      05da40eb
    • Leon Romanovsky's avatar
      MAINTAINERS: Fix Max's and Shravan's emails · 6279e774
      Leon Romanovsky authored
      Max's and Shravan's usernames were changed while @mellanox.com emails
      were transferred to be @nvidia.com.
      
      Fixes: f6da70d9 ("MAINTAINERS: Update Mellanox and Cumulus Network addresses to new domain")
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6279e774
    • Qi Liu's avatar
      perf stat: Fix the ratio comments of miss-events · ce9c13f3
      Qi Liu authored
      'perf stat' displays miss ratio of L1-dcache, L1-icache, dTLB cache,
      iTLB cache and LL-cache. Take L1-dcache for example, miss ratio is
      caculated as "L1-dcache-load-misses/L1-dcache-loads". So "of all
      L1-dcache hits" is unsuitable to describe it, and "of all L1-dcache
      accesses" seems better.
      
      The comments of L1-icache, dTLB cache, iTLB cache and LL-cache are
      fixed in the same way.
      Signed-off-by: default avatarQi Liu <liuqi115@huawei.com>
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1600253331-10535-1-git-send-email-liuqi115@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ce9c13f3
  4. 15 Sep, 2020 14 commits
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 9803ab17
      Linus Torvalds authored
      Pull SCSI fix from James Bottomley:
       "Just one fix in libsas for a resource leak in an error path"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: libsas: Fix error path in sas_notify_lldd_dev_found()
      9803ab17
    • Linus Torvalds's avatar
      Merge tag 'fixes-v5.9a' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security · 1e484d38
      Linus Torvalds authored
      Pull security layer fix from James  Morris:
       "A device_cgroup RCU warning fix from Amol Grover"
      
      * tag 'fixes-v5.9a' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
        device_cgroup: Fix RCU list debugging warning
      1e484d38
    • Linus Torvalds's avatar
      Merge tag 'hyperv-fixes-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux · 00acc505
      Linus Torvalds authored
      Pull hyperv fixes from Wei Liu:
       "Two patches from Michael and Dexuan to fix vmbus hanging issues"
      
      * tag 'hyperv-fixes-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
        Drivers: hv: vmbus: Add timeout to vmbus_wait_for_unload
        Drivers: hv: vmbus: hibernation: do not hang forever in vmbus_bus_resume()
      00acc505
    • Namhyung Kim's avatar
      perf test: Free formats for perf pmu parse test · d26383dc
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d26383dc
    • Namhyung Kim's avatar
      perf metric: Do not free metric when failed to resolve · 6f47ed6c
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6f47ed6c
    • Namhyung Kim's avatar
      perf metric: Free metric when it failed to resolve · 27adafcd
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      27adafcd
    • Namhyung Kim's avatar
      perf metric: Release expr_parse_ctx after testing · 437822bf
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      437822bf
    • Namhyung Kim's avatar
      perf test: Fix memory leaks in parse-metric test · f5a56570
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f5a56570
    • Namhyung Kim's avatar
      perf parse-event: Fix memory leak in evsel->unit · b12eea5a
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b12eea5a
    • Namhyung Kim's avatar
      perf evlist: Fix cpu/thread map leak · bfd1b83d
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bfd1b83d
    • Namhyung Kim's avatar
      perf metric: Fix some memory leaks - part 2 · b033ab11
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b033ab11
    • Namhyung Kim's avatar
      perf metric: Fix some memory leaks · 4f57a1ed
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4f57a1ed
    • Namhyung Kim's avatar
      perf test: Free aliases for PMU event map aliases test · 22fe5a25
      Namhyung Kim authored
      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: default avatarNamhyung Kim <namhyung@kernel.org>
      Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      22fe5a25
    • Henry Burns's avatar
      perf vendor events amd: Remove trailing commas · 56f3a1cd
      Henry Burns authored
      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: default avatarHenry Burns <henrywolfeburns@gmail.com>
      Acked-by: default avatarKim Phillips <kim.phillips@amd.com>
      Acked-by: default avatarNamhyung 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      56f3a1cd
  5. 14 Sep, 2020 10 commits
    • Linus Torvalds's avatar
      Merge tag 'for-5.9-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · fc4f28bb
      Linus Torvalds authored
      Pull btrfs fix from David Sterba:
       "One of the recent lockdep fixes introduced a bug that breaks the
        search ioctl, which is used by some applications (bees, compsize). The
        patch made it to stable trees so we need this fixup to make it work
        again"
      
      * tag 'for-5.9-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: fix wrong address when faulting in pages in the search ioctl
      fc4f28bb
    • Ian Rogers's avatar
      perf test: Leader sampling shouldn't clear sample period · 880a7843
      Ian Rogers authored
      Add test that a sibling with leader sampling doesn't have its period
      cleared.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      880a7843
    • Ian Rogers's avatar
      perf record: Don't clear event's period if set by a term · 3b0a18c1
      Ian Rogers authored
      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: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3b0a18c1
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: update linux/in.h copy · 2fa3fc95
      Arnaldo Carvalho de Melo authored
      To get the changes from:
      
        645f0897 ("net: Fix some comments")
      
      That don't cause any changes in tooling, its just a typo fix.
      
      This silences this tools/perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
        diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2fa3fc95
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync kvm.h headers with the kernel sources · 8d761d2c
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        15e9e35c ("KVM: MIPS: Change the definition of kvm type")
        004a0124 ("arm64/x86: KVM: Introduce steal-time cap")
      
      That do not result in any change in tooling, as the additions are not
      being used in any table generator.
      
      This silences these perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
        diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andrew Jones <drjones@redhat.com>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8d761d2c
    • Stephane Eranian's avatar
      perf record: Prevent override of attr->sample_period for libpfm4 events · ae5dcc8a
      Stephane Eranian authored
      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: default avatarStephane Eranian <eranian@google.com>
      Reviewed-by: default avatarIan 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: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae5dcc8a
    • David Sharp's avatar
      perf record: Set PERF_RECORD_PERIOD if attr->freq is set. · ce4326d2
      David Sharp authored
      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: default avatarDavid 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: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ce4326d2
    • Ian Rogers's avatar
      perf bench: Fix 2 memory sanitizer warnings · d2c73501
      Ian Rogers authored
      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: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d2c73501
    • Jiri Olsa's avatar
      perf test: Fix the "signal" test inline assembly · 8a39e8c4
      Jiri Olsa authored
      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: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8a39e8c4
    • Linus Torvalds's avatar
      vgacon: remove software scrollback support · 973c096f
      Linus Torvalds authored
      Yunhai Zhang recently fixed a VGA software scrollback bug in commit
      ebfdfeea ("vgacon: Fix for missing check in scrollback handling"),
      but that then made people look more closely at some of this code, and
      there were more problems on the vgacon side, but also the fbcon software
      scrollback.
      
      We don't really have anybody who maintains this code - probably because
      nobody actually _uses_ it any more.  Sure, people still use both VGA and
      the framebuffer consoles, but they are no longer the main user
      interfaces to the kernel, and haven't been for decades, so these kinds
      of extra features end up bitrotting and not really being used.
      
      So rather than try to maintain a likely unused set of code, I'll just
      aggressively remove it, and see if anybody even notices.  Maybe there
      are people who haven't jumped on the whole GUI badnwagon yet, and think
      it's just a fad.  And maybe those people use the scrollback code.
      
      If that turns out to be the case, we can resurrect this again, once
      we've found the sucker^Wmaintainer for it who actually uses it.
      Reported-by: default avatarNopNop Nop <nopitydays@gmail.com>
      Tested-by: default avatarWilly Tarreau <w@1wt.eu>
      Cc: 张云海 <zhangyunhai@nsfocus.com>
      Acked-by: default avatarAndy Lutomirski <luto@amacapital.net>
      Acked-by: default avatarWilly Tarreau <w@1wt.eu>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      973c096f