root@ubuntu:~# apt install linux-tools-common Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: linux-headers-5.4.0-92-generic : Depends: linux-headers-5.4.0-92 but it is not going to be installed linux-image-generic : Depends: linux-modules-extra-5.4.0-92-generic but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). root@ubuntu:~#
漂亮!报错了!
不要慌,我们要学会阅读报错信息,不怕它报错,就怕它不报错。
这里的意思大概是咱们要安装的linux-tools-common需要依赖linux-headers-5.4.0-92-generic和linux-image-generic并且它还给出了建议”You might want to run ‘apt –fix-broken install’ to correct these.”。那我们就按照它说的执行apt --fix-broken install然后再执行linux-tools-common就能成功安装。然后我们执行perf -h看一下。
root@ubuntu:~# perf -h WARNING: perf not found for kernel 5.4.0-91
You may need to install the following packages for this specific kernel: linux-tools-5.4.0-91-generic linux-cloud-tools-5.4.0-91-generic
You may also want to install one of the following packages to keep up to date: linux-tools-generic linux-cloud-tools-generic root@ubuntu:~#
The most commonly used perf commands are: annotate Read perf.data (created by perf record) and display annotated code archive Create archive with object files with build-ids found in perf.data file bench General framework for benchmark suites buildid-cache Manage build-id cache. buildid-list List the buildids in a perf.data file c2c Shared Data C2C/HITM Analyzer. config Get and set variables in a configuration file. data Data file related processing diff Read perf.data files and display the differential profile evlist List the event names in a perf.data file ftrace simple wrapper for kernel's ftrace functionality inject Filter to augment the events stream with additional information kallsyms Searches running kernel for symbols kmem Tool to trace/measure kernel memory properties kvm Tool to trace/measure kvm guest os list List all symbolic event types lock Analyze lock events mem Profile memory accesses record Run a command and record its profile into perf.data report Read perf.data (created by perf record) and display the profile sched Tool to trace/measure scheduler properties (latencies) script Read perf.data (created by perf record) and display trace output stat Run a command and gather performance counter statistics test Runs sanity tests. timechart Tool to visualize total system behavior during a workload top System profiling tool. version display the version of perf binary probe Define new dynamic tracepoints trace strace inspired tool
See 'perf help COMMAND' for more information on a specific command.
然后我们使用perf record -F 50 -a -p 2403020 -g -- sleep 60来采集数据。需要等待60s。
root@ubuntu:~# perf record -F 50 -a -p 2403020 -g -- sleep 60 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.064 MB perf.data (1117 samples) ] root@ubuntu:~#
解释一下:所有的参数和用法可以执行perf record -h查看。这里我就解释一下我上面用到几个参数: