是否可以使用 Linux 实时监控进程的调度方式?
Is it possible to monitor how a process is scheduled real-time with Linux?
我正在尝试使用 RaspberryPi 开发一个多进程系统,我想在其中监控所有主要进程以及它们如何使用 Linux 进行调度。也就是说,获取调度程序状态、开始时间、发布时间等。我一直在弄乱“/proc”文件夹以找到这样的信息,但到目前为止我还没有找到任何真正有用的东西。
例如,如果您进入 /proc/pid/task/pid,您可以看到:
se.exec_start
se.vruntime
se.sum_exec_runtime
se.statistics.wait_start
se.statistics.sleep_start
se.statistics.block_start
se.statistics.sleep_max
se.statistics.block_max
se.statistics.iowait_sum
se.statistics.wakeups
等等。现在,这看起来像是我在做某事,但还不够清楚。
我只想看看进程是如何在核心中安排的。即,Process1 在 0.30 发布,然后 Process2 在 0.70(系统计时器值)开始等
是否可以通过监视诸如“/proc”之类的内核文件夹来实现类似的功能?
如果不是,有没有办法使用其他跟踪工具或 Linux 的调度程序工具来确定这一点?
非常感谢任何指导。
请告诉我是否还有其他需要我提供的东西。
提前致谢。
编辑:使用 kernelshark,
我想确切地了解,对于其他流程,cpu 什么时候完成每个任务的一次迭代。
I want to just see how processes are scheduled in cores. i.e, Process1 released at 0.30, then Process2 started at 0.70 (system timer values) etc.
这称为跟踪,通常在用户请求后在内核中完成。 Linux 中有几个内核事件跟踪器。尝试
perf sched
(man, lwn commit; also http://www.brendangregg.com/perf.html#SchedulerAnalysis) 使用 perf sched record sleep 2
然后 perf sched script
得到 log
- 其他一些用于跟踪的 perf 命令,例如
perf record -e 'sched:sched_process_*' -a sleep 2
+ perf script
(来自 http://www.brendangregg.com/perf.html)
trace-cmd
(man; based on ftrace
- https://lwn.net/Articles/608497/ https://events.linuxfoundation.org/slides/2010/linuxcon_japan/linuxcon_jp2010_rostedt.pdf): trace-cmd record -e sched ./program
/ trace-cmd record -e sched_switch ...
, trace-cmd report
(or install and use kernelshark
GUI - https://lwn.net/Articles/425583/ http://static.lwn.net/images/2011/ks-success.png)
- 还有一些特殊的跟踪器,例如 LTT/LTTng(wiki, website). It has GUI plugin for Eclipse (Trace Compass): https://wiki.eclipse.org/images/4/49/X-axis-alignment-full-histogram-axis-bottom.png 带有过程图和 CPU 随时间变化的图
- 我认为,
sysdig
也可以跟踪调度程序...
Gregg 有一些 Linux 追踪的信息(使用 "pony-corn mascot" 魔法):http://www.brendangregg.com/blog/2015-07-08/choosing-a-linux-tracer.html (there should be some presentation about tracing in https://www.slideshare.net/brendangregg)...
Is something like this possible by monitoring kernel folders such as '/proc'
没有inotify
for /proc
(它里面没有真正的目录或真正的文件:),所以你不能监视变化,你只能重新读取定期一些 /proc(或一些 /sys)。
我正在尝试使用 RaspberryPi 开发一个多进程系统,我想在其中监控所有主要进程以及它们如何使用 Linux 进行调度。也就是说,获取调度程序状态、开始时间、发布时间等。我一直在弄乱“/proc”文件夹以找到这样的信息,但到目前为止我还没有找到任何真正有用的东西。
例如,如果您进入 /proc/pid/task/pid,您可以看到:
se.exec_start
se.vruntime
se.sum_exec_runtime
se.statistics.wait_start
se.statistics.sleep_start
se.statistics.block_start
se.statistics.sleep_max
se.statistics.block_max
se.statistics.iowait_sum
se.statistics.wakeups
等等。现在,这看起来像是我在做某事,但还不够清楚。 我只想看看进程是如何在核心中安排的。即,Process1 在 0.30 发布,然后 Process2 在 0.70(系统计时器值)开始等
是否可以通过监视诸如“/proc”之类的内核文件夹来实现类似的功能? 如果不是,有没有办法使用其他跟踪工具或 Linux 的调度程序工具来确定这一点?
非常感谢任何指导。 请告诉我是否还有其他需要我提供的东西。
提前致谢。
编辑:使用 kernelshark,
我想确切地了解,对于其他流程,cpu 什么时候完成每个任务的一次迭代。
I want to just see how processes are scheduled in cores. i.e, Process1 released at 0.30, then Process2 started at 0.70 (system timer values) etc.
这称为跟踪,通常在用户请求后在内核中完成。 Linux 中有几个内核事件跟踪器。尝试
perf sched
(man, lwn commit; also http://www.brendangregg.com/perf.html#SchedulerAnalysis) 使用perf sched record sleep 2
然后perf sched script
得到 log- 其他一些用于跟踪的 perf 命令,例如
perf record -e 'sched:sched_process_*' -a sleep 2
+perf script
(来自 http://www.brendangregg.com/perf.html) trace-cmd
(man; based onftrace
- https://lwn.net/Articles/608497/ https://events.linuxfoundation.org/slides/2010/linuxcon_japan/linuxcon_jp2010_rostedt.pdf):trace-cmd record -e sched ./program
/trace-cmd record -e sched_switch ...
,trace-cmd report
(or install and usekernelshark
GUI - https://lwn.net/Articles/425583/ http://static.lwn.net/images/2011/ks-success.png)- 还有一些特殊的跟踪器,例如 LTT/LTTng(wiki, website). It has GUI plugin for Eclipse (Trace Compass): https://wiki.eclipse.org/images/4/49/X-axis-alignment-full-histogram-axis-bottom.png 带有过程图和 CPU 随时间变化的图
- 我认为,
sysdig
也可以跟踪调度程序...
Gregg 有一些 Linux 追踪的信息(使用 "pony-corn mascot" 魔法):http://www.brendangregg.com/blog/2015-07-08/choosing-a-linux-tracer.html (there should be some presentation about tracing in https://www.slideshare.net/brendangregg)...
Is something like this possible by monitoring kernel folders such as '/proc'
没有inotify
for /proc
(它里面没有真正的目录或真正的文件:),所以你不能监视变化,你只能重新读取定期一些 /proc(或一些 /sys)。