如何分析 perf sched 记录的 perf.data

How to analyze perf.data of perf sched record

我使用 :

收集了一些性能数据
perf sched record –g

我需要分析这个命令生成的perf.data

我正在使用以下命令进行分析:

perf report 

我看到多个预定事件:

62K sched:sched_switch                                                                                                  ▒
0 sched:sched_stat_wait                                                                                                 ▒
0 sched:sched_stat_sleep                                                                                                ▒
0 sched:sched_stat_iowait                                                                                               ▒
120K sched:sched_stat_runtime                                                                                           ▒
10 sched:sched_process_fork                                                                                             ▒
31K sched:sched_wakeup                                                                                                  ▒
10 sched:sched_wakeup_new                                                                                               ▒
873 sched:sched_migrate_task    

打开其中一个事件后,我看到类似这样的内容:

+   80.00%     0.00%  ksmtuned  bash               [.] make_child
+   80.00%     0.00%  ksmtuned  libc-2.17.so       [.] __libc_fork
+   80.00%     0.00%  ksmtuned  [kernel.kallsyms]  [k] stub_clone
+   80.00%     0.00%  ksmtuned  [kernel.kallsyms]  [k] sys_clone
+   80.00%    80.00%  ksmtuned  [kernel.kallsyms]  [k] do_fork
+   10.00%     0.00%      bash  bash               [.] make_child

我无法解读这些信息。 以下是我的问题:

1) 显示 % 值的前两列是什么? 2) 为什么 % 值加起来不等于 100 % ? 3) 这些数字有什么意义?

perf sched record 是 perf 的特殊变体,我认为使用 perf sched 子命令来分析生成的 perf.data 文件更正确。

perf sched 上有手册页:http://man7.org/linux/man-pages/man1/perf-sched.1.html

       'perf sched record <command>' to record the scheduling events
       of an arbitrary workload.

       'perf sched latency' to report the per task scheduling latencies
       and other scheduling properties of the workload.

       'perf sched script' to see a detailed trace of the workload that
        was recorded...

       'perf sched replay' to simulate the workload that was recorded
       via perf sched record. (this is done by starting up mockup threads
       that mimic the workload based on the events in the trace. These
       threads can then replay the timings (CPU runtime and sleep patterns)
       of the workload as it occurred when it was recorded - and can repeat
       it a number of times, measuring its performance.)

       'perf sched map' to print a textual context-switching outline of
       workload captured via perf sched record.  Columns stand for
       individual CPUs, and the two-letter shortcuts stand for tasks that
       are running on a CPU. A '*' denotes the CPU that had the event, and
       a dot signals an idle CPU.

还有一封来自 2009 年的信件描述了 perf sched 功能:https://lwn.net/Articles/353295/“[公告] 'perf sched':用于捕获、测量和分析调度程序延迟和行为的实用程序”以及推荐的perf sched record 结果的用法是 perf sched latency 而不是 perf report:

... experimental version of a utility that tries to meet this ambitious goal: the new 'perf sched' family of tools that uses performance events to objective characterise arbitrary workloads from a scheduling and latency point of view.

'perf sched' has five sub-commands currently:

  perf sched record            # low-overhead recording of arbitrary workloads
  perf sched latency           # output per task latency metrics
  perf sched map               # show summary/map of context-switching
  perf sched trace             # output finegrained trace
  perf sched replay            # replay a captured workload using simlated threads

Desktop users would generally use 'perf sched record' to capture a trace (which creates perf.data), and 'perf sched latency' tool to check latencies (which analyzes the trace in perf.data). The other tools too use an already recorded perf.data.