Amo*_*ati 5 x86 profiling linux-kernel perf
我有一个在 Linux 内核 4.18 和 Intel CPU 的多线程框架上运行的程序。我跑去perf record -p pid -g -e cycles:u --call-graph lbr -F 99 -- sleep 20收集堆栈跟踪并生成火焰图。
我的程序在低工作负载下运行,因此所花费的时间futex_wait是预期的。但栈顶是一个内核函数native_write_msr。根据内核中的native_write_msr 做什么?和https://elixir.bootlin.com/linux/v4.18/source/arch/x86/include/asm/msr.h#L103,该函数用于性能计数器。我已禁用 中的跟踪点native_write_msr。
并 pidstat -p pid 1告诉我系统CPU使用率相当低。
05:44:34 PM UID PID %usr %system %guest %CPU CPU Command
05:44:35 PM 1001 67441 60.00 4.00 0.00 64.00 11 my_profram
05:44:36 PM 1001 67441 58.00 7.00 0.00 65.00 11 my_profram
05:44:37 PM 1001 67441 61.00 3.00 0.00 64.00 11 my_profram
Run Code Online (Sandbox Code Playgroud)
我的问题是
native_write_msr在堆栈跟踪中出现这么多次(因此,它在火焰图中占据了很大的空间,约占 80%)。是块操作,还是调用时释放CPU?%system而不是%usr.任何帮助表示赞赏。如果我错过任何有用的信息,请评论。
非常感谢!
小智 1
从火焰图中,您可以发现该native_write_msr函数是由 函数 调用的schedule。当正在运行的进程从一个核心中删除时(因为它被迁移到另一个核心或被调度程序停止以运行另一个进程),调度程序需要转储该进程的性能数据并清理其性能配置,这样我们就不会弄乱性能不同进程的数据。调度程序可能需要在这一步写入 msr,从而调用native_write_msr. 因为调度或核心迁移发生得太频繁,所以native_write_msr被调用了很多次。
| 归档时间: |
|
| 查看次数: |
751 次 |
| 最近记录: |