目前從第二PERF命令從https://perf.wiki.kernel.org/index.php/Tutorial#Profiling_sleep_times一個錯誤信息 - perf inject -s
$ sudo perf inject -v -s -i ~/perf.data.raw -o ~/perf.data
build id event received for [kernel.kallsyms]: d62870685909222126e7070d2bafdf029f7ed3b6
failed to write feature 2
failed to write feature 2 doesn't look too user-friendly...
...但它加入to perf使錯誤更加用戶友好:http://lwn.net/Articles/460520/「perf:使perf.data更具自描述性(v5)」by Stephane Eranian,2011年9月22日:
+static int do_write_feat(int fd, struct perf_header *h, int type, ....
+ pr_debug("failed to write feature %d\n", type);
所有的功能都在這裏列出http://lxr.free-electrons.com/source/tools/perf/util/header.h#L13
15 HEADER_TRACING_DATA = 1,
16 HEADER_BUILD_ID,
所以,它聽起來就像PERF注入未能如果將信息寫入有關(從UTIL/header.c從功能write_build_id()
錯誤)建立IDS我沒錯。有兩種情況可以導致錯誤:perf_session__read_build_ids()
不成功的電話或書面buildid表dsos__write_buildid_table
失敗(因爲沒有「失敗寫buildid表」的錯誤信息,這不是我們的情況;檢查write_build_id
)
您可能檢查一下,你是否擁有會話所需的所有buildids。此外,清除buildid緩存(rm -rf ~/.debug
)可能會很有用,並檢查您是否擁有內核中啓用了調試信息或kallsyms的最新vmlinux。
UPDATE:在評論帕維爾說,他PREF紀錄曾寫信給perf.data沒有任何sched:sched_stat_sleep
事件:
sudo perf record -e sched:sched_stat_sleep -e sched:sched_switch -e sched:sched_process_exit -g -o ~/perf.data.raw ./a.out
正如他在his answer解釋說,他的默認的Debian內核有CONFIG_SCHEDSTATS
選項禁用與供應商的補丁。自3以來,redhat在發佈內核中採用了相同的選擇。11,並且這在Redhat Bug 1013225說明(書博耶2013年10月28日,註釋4):
We switched to enabling that only on debug builds a while ago. It seems that was turned off entirely with the final 3.11.0 build and has remained off since. Internal testing shows the option has a non-trivial performance impact for context switches.
We can turn this on in debug kernels again, but I'm not sure it's worthwhile.
約什Poimboeuf 2013年11月4日在評論8說,對性能的影響是可檢測的:
In my tests I did a lot of context switches under various CPU loads. I saw a ~5-10% drop in average context switch speed when CONFIG_SCHEDSTATS was enabled. ...The performance hit only seemed to happen on post-CFS kernels (>= 2.6.23). The previous O(1) scheduler didn't seem to have this issue.
在非調試內核的Fedora禁用CONFIG_SCHEDSTAT在2013 7月12日"[kernel] Disable LATENCYTOP/SCHEDSTATS in non-debug builds."戴維·瓊斯。第一個禁用的內核選項:3.11.0-0.rc0.git6.4。
爲了使用任何perf
軟件跟蹤點事件與名稱類似sched:sched_stat_*
(sched:sched_stat_wait
,sched:sched_stat_sleep
,sched:sched_stat_iowait
)我們必須重新編譯內核CONFIG_SCHEDSTATS
選項啓用和替換不具有此選項是默認Debian,紅帽或Fedora內核。
謝謝你,帕維爾·達維多夫。
我不認爲perf是正確的工具。它監視CPU使用情況,並且程序幾乎不使用CPU時間。 – ugoren
@ugoren這是用於分析睡眠時間的特殊模式,perf只查找調度程序切換事件,而不查找cpu週期。 –