睡眠进程的CPU使用率很高 [英] CPU Utilization high for sleeping processes

查看:802
本文介绍了睡眠进程的CPU使用率很高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个似乎陷入僵局的进程:

I have a process that appears to be deadlocked:

# strace -p 5075
Process 5075 attached - interrupt to quit
futex(0x419cf9d0, FUTEX_WAIT, 5095, NULL

它正坐在"futex"系统调用上,并且似乎无限期地等待着锁.当运行"top"时,该进程显示正在消耗大量CPU:

It is sitting on the "futex" system call, and seems to be indefinitely waiting on a lock. The process is shown to be consuming a large amount of CPU when "top" is run:

# top -b -n 1
top - 23:13:18 up 113 days,  4:19,  1 user,  load average: 1.69, 1.74, 1.72
Tasks: 269 total,   1 running, 268 sleeping,   0 stopped,   0 zombie
Cpu(s):  8.1%us,  0.1%sy,  0.0%ni, 91.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  12165696k total,  3810476k used,  8355220k free,    29440k buffers
Swap:  8388600k total,    43312k used,  8345288k free,   879988k cached

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
5075 omdb      18   0 2373m 1.7g  26m S 199.7 14.9 102804:11 java

该过程还显示为处于"S"状态-睡眠状态,这在它正在等待某些资源的情况下是有意义的.但是,我不明白,如果进程处于睡眠状态,为什么CPU利用率将接近200%.为什么top在休眠进程中报告了如此高的CPU使用率?它的CPU使用率不应该为零吗?

The process is also shown to be in a "S" - Sleep state, which makes sense if it's waiting on some resource. However, I don't understand why CPU utilization would be close to 200% if the process is in the sleep state. Why does top report such high CPU utilization on a sleeping process? Shouldn't its CPU utilization be zero?

推荐答案

top报告的CPU使用率与进程状态之间没有关联. 手册页说(强调我的):

There is no correlation between CPU usage as reported by top and process state. The man page says (emphasis mine):

%CPU -CPU使用率

自上次屏幕更新以来,任务在已用CPU时间中所占的份额,以占总CPU时间的百分比表示.

The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.

因此,自从上一次屏幕更新以来,您的过程确实花费了大量的处理器时间.是的,它正在休眠,但这是因为当前正在运行的进程是top本身(这很有意义,因为它当前正在更新屏幕).

So, your process indeed used a huge amount of processor time since the last screen update. It is sleeping, yes, but that's because the currently running process is top itself (which makes sense, since it's currently updating the screen).

这篇关于睡眠进程的CPU使用率很高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆