Linux 如何找出哪个进程正在消耗“等待 CPU”(即 I/O 阻塞)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/666783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find out which process is consuming "wait CPU" (i.e. I/O blocked)
提问by Michael Kuhn
With top
it's easy to find out how much CPU each job uses. However, I want to hunt down a job that causes a high wait CPU. Is there a way to find out which jobs are blocked on I/O?
有了top
它很容易找出多少CPU每个作业用途。但是,我想寻找导致高等待 CPU 的作业。有没有办法找出哪些作业在 I/O 上被阻塞?
采纳答案by ephemient
iotopand latencytopmay be helpful. Neither gives exactly "CPU wait time caused by a process" -- I'm not sure it even makes sense, because the CPU can and does go off to service other processes while waiting for IO -- but these two tools give overviews of (respectively) system I/O traffic and scheduling delays.
iotop和latencytop可能会有所帮助。两者都没有给出确切的“由进程引起的 CPU 等待时间”——我不确定这是否有意义,因为 CPU 可以并且确实在等待 IO 时为其他进程提供服务——但这两个工具概述了 (分别)系统 I/O 流量和调度延迟。
回答by Johannes Weiss
The processes blocked on IO are the ones marked as D
in the status column (S
column in top).
在 IO 上被阻止的进程是D
状态列(S
顶部的列)中标记的进程。
回答by quentinxue
To be more precise, use this command can easily find out which processes are "eating" your CPU cycles:
更准确地说,使用此命令可以轻松找出哪些进程正在“吃掉”您的 CPU 周期:
while true; do date; ps auxf | awk '{if($8=="D") print $0;}'; sleep 1; done
while true; do date; ps auxf | awk '{if($8=="D") print $0;}'; sleep 1; done
This url could be helpful: Linux Wait IO Problem
此网址可能会有所帮助:Linux 等待 IO 问题
回答by vicky
Do a top, then shift F , then choose m or n, will sort the listing of processes by CPU time used.
做一个 top,然后 shift F ,然后选择 m 或 n,将按 CPU 使用时间对进程列表进行排序。